| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 Polymer({ | 5 Polymer({ |
| 6 is: 'bookmarks-toolbar', | 6 is: 'bookmarks-toolbar', |
| 7 | 7 |
| 8 behaviors: [ |
| 9 bookmarks.StoreClient, |
| 10 ], |
| 11 |
| 8 properties: { | 12 properties: { |
| 9 searchTerm: { | 13 /** @private */ |
| 14 searchTerm_: { |
| 10 type: String, | 15 type: String, |
| 11 observer: 'onSearchTermChanged_', | 16 observer: 'onSearchTermChanged_', |
| 12 }, | 17 }, |
| 13 }, | 18 }, |
| 14 | 19 |
| 20 attached: function() { |
| 21 this.watch('searchTerm_', function(state) { |
| 22 return state.search.term; |
| 23 }); |
| 24 }, |
| 25 |
| 15 /** @return {CrToolbarSearchFieldElement} */ | 26 /** @return {CrToolbarSearchFieldElement} */ |
| 16 get searchField() { | 27 get searchField() { |
| 17 return /** @type {CrToolbarElement} */ (this.$$('cr-toolbar')) | 28 return /** @type {CrToolbarElement} */ (this.$$('cr-toolbar')) |
| 18 .getSearchField(); | 29 .getSearchField(); |
| 19 }, | 30 }, |
| 20 | 31 |
| 21 /** | 32 /** |
| 22 * @param {Event} e | 33 * @param {Event} e |
| 23 * @private | 34 * @private |
| 24 */ | 35 */ |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 var menu = /** @type {!CrActionMenuElement} */ (this.$.dropdown); | 70 var menu = /** @type {!CrActionMenuElement} */ (this.$.dropdown); |
| 60 menu.close(); | 71 menu.close(); |
| 61 }, | 72 }, |
| 62 | 73 |
| 63 /** | 74 /** |
| 64 * @param {Event} e | 75 * @param {Event} e |
| 65 * @private | 76 * @private |
| 66 */ | 77 */ |
| 67 onSearchChanged_: function(e) { | 78 onSearchChanged_: function(e) { |
| 68 var searchTerm = /** @type {string} */ (e.detail); | 79 var searchTerm = /** @type {string} */ (e.detail); |
| 69 this.fire('search-term-changed', searchTerm); | 80 this.dispatch(bookmarks.actions.setSearchTerm(searchTerm)); |
| 70 }, | 81 }, |
| 71 | 82 |
| 72 /** @private */ | 83 /** @private */ |
| 73 onSearchTermChanged_: function() { | 84 onSearchTermChanged_: function() { |
| 74 this.searchField.setValue(this.searchTerm || ''); | 85 this.searchField.setValue(this.searchTerm_ || ''); |
| 75 }, | 86 }, |
| 76 }); | 87 }); |
| OLD | NEW |