| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 Polymer({ |
| 6 /** |
| 7 * This element is a one way bound interface that routes the page URL to |
| 8 * the searchTerm and selectedId. Clients must initialize themselves by |
| 9 * reading the router's fields after attach. |
| 10 */ |
| 11 is: 'bookmarks-router', |
| 12 |
| 13 properties: { |
| 14 // Parameter q is routed to the searchTerm. |
| 15 // Parameter id is routed to the selectedId. |
| 16 queryParams_: Object, |
| 17 |
| 18 searchTerm: { |
| 19 type: String, |
| 20 observer: 'onSearchTermChanged_', |
| 21 }, |
| 22 |
| 23 /** @type {?string} */ |
| 24 selectedId: { |
| 25 type: String, |
| 26 observer: 'onSelectedChanged_', |
| 27 }, |
| 28 }, |
| 29 |
| 30 observers: [ |
| 31 'onQueryChanged_(queryParams_.*)', |
| 32 ], |
| 33 |
| 34 /** @private */ |
| 35 onQueryChanged_: function() { |
| 36 this.searchTerm = this.queryParams_.q || ''; |
| 37 this.selectedId = this.queryParams_.id; |
| 38 |
| 39 if (this.searchTerm) { |
| 40 this.fire('search-term-changed', this.searchTerm); |
| 41 } else { |
| 42 this.fire('selected-folder-changed', this.selectedId); |
| 43 } |
| 44 }, |
| 45 |
| 46 /** @private */ |
| 47 onSelectedChanged_: function() { |
| 48 this.set('queryParams_.id', this.selectedId || null); |
| 49 }, |
| 50 |
| 51 /** @private */ |
| 52 onSearchTermChanged_: function() { |
| 53 this.set('queryParams_.q', this.searchTerm || null); |
| 54 }, |
| 55 }); |
| OLD | NEW |