| 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 searchTerm: { |
| 10 type: String, | 14 type: String, |
| 11 observer: 'onSearchTermChanged_', | 15 observer: 'onSearchTermChanged_', |
| 12 }, | 16 }, |
| 13 }, | 17 }, |
| 14 | 18 |
| 19 attached: function() { |
| 20 this.observe('searchTerm', function(state) { |
| 21 return state.search.term; |
| 22 }); |
| 23 }, |
| 24 |
| 15 /** @return {CrToolbarSearchFieldElement} */ | 25 /** @return {CrToolbarSearchFieldElement} */ |
| 16 get searchField() { | 26 get searchField() { |
| 17 return /** @type {CrToolbarElement} */ (this.$$('cr-toolbar')) | 27 return /** @type {CrToolbarElement} */ (this.$$('cr-toolbar')) |
| 18 .getSearchField(); | 28 .getSearchField(); |
| 19 }, | 29 }, |
| 20 | 30 |
| 21 /** | 31 /** |
| 22 * @param {Event} e | 32 * @param {Event} e |
| 23 * @private | 33 * @private |
| 24 */ | 34 */ |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 var menu = /** @type {!CrActionMenuElement} */ (this.$.dropdown); | 69 var menu = /** @type {!CrActionMenuElement} */ (this.$.dropdown); |
| 60 menu.close(); | 70 menu.close(); |
| 61 }, | 71 }, |
| 62 | 72 |
| 63 /** | 73 /** |
| 64 * @param {Event} e | 74 * @param {Event} e |
| 65 * @private | 75 * @private |
| 66 */ | 76 */ |
| 67 onSearchChanged_: function(e) { | 77 onSearchChanged_: function(e) { |
| 68 var searchTerm = /** @type {string} */ (e.detail); | 78 var searchTerm = /** @type {string} */ (e.detail); |
| 69 this.fire('search-term-changed', searchTerm); | 79 this.dispatch(bookmarks.actions.setSearchTerm(searchTerm)); |
| 70 }, | 80 }, |
| 71 | 81 |
| 72 /** @private */ | 82 /** @private */ |
| 73 onSearchTermChanged_: function() { | 83 onSearchTermChanged_: function() { |
| 74 this.searchField.setValue(this.searchTerm || ''); | 84 this.searchField.setValue(this.searchTerm || ''); |
| 75 }, | 85 }, |
| 76 }); | 86 }); |
| OLD | NEW |