| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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: 'history-toolbar', | 6 is: 'history-toolbar', |
| 7 properties: { | 7 properties: { |
| 8 // Number of history items currently selected. | 8 // Number of history items currently selected. |
| 9 count: { | 9 count: { |
| 10 type: Number, | 10 type: Number, |
| 11 value: 0, | 11 value: 0, |
| 12 observer: 'changeToolbarView_' | 12 observer: 'changeToolbarView_' |
| 13 }, | 13 }, |
| 14 |
| 14 // True if 1 or more history items are selected. When this value changes | 15 // True if 1 or more history items are selected. When this value changes |
| 15 // the background colour changes. | 16 // the background colour changes. |
| 16 itemsSelected_: { | 17 itemsSelected_: { |
| 17 type: Boolean, | 18 type: Boolean, |
| 18 value: false, | 19 value: false, |
| 19 reflectToAttribute: true | 20 reflectToAttribute: true |
| 21 }, |
| 22 |
| 23 searchTerm: { |
| 24 type: String, |
| 25 value: '' |
| 20 } | 26 } |
| 21 }, | 27 }, |
| 22 | 28 |
| 23 /** | 29 /** |
| 24 * Changes the toolbar background color depending on whether any history items | 30 * Changes the toolbar background color depending on whether any history items |
| 25 * are currently selected. | 31 * are currently selected. |
| 26 * @private | 32 * @private |
| 27 */ | 33 */ |
| 28 changeToolbarView_: function() { | 34 changeToolbarView_: function() { |
| 29 this.itemsSelected_ = this.count != 0; | 35 this.itemsSelected_ = this.count != 0; |
| 30 }, | 36 }, |
| 31 | 37 |
| 38 /** |
| 39 * If the search term has changed reload for the new search. |
| 40 */ |
| 41 onSearchTermSearch: function(searchTerm) { |
| 42 if (searchTerm != this.searchTerm) |
| 43 this.fire('refresh-results', {search: searchTerm}); |
| 44 this.searchTerm = searchTerm; |
| 45 }, |
| 46 |
| 47 attached: function() { |
| 48 this.async(function() { |
| 49 this.searchFieldDelegate_ = new ToolbarSearchFieldDelegate(this); |
| 50 this.$$('#search-input').setDelegate(this.searchFieldDelegate_); |
| 51 }); |
| 52 }, |
| 53 |
| 32 onClearSelectionTap_: function() { | 54 onClearSelectionTap_: function() { |
| 33 this.fire('unselect-all'); | 55 this.fire('unselect-all'); |
| 34 } | 56 } |
| 35 }); | 57 }); |
| 58 |
| 59 /** |
| 60 * @constructor |
| 61 * @implements {SearchFieldDelegate} |
| 62 * @param {object} toolbar This history-toolbar. |
| 63 */ |
| 64 function ToolbarSearchFieldDelegate(toolbar) { |
| 65 this.toolbar_ = toolbar; |
| 66 } |
| 67 |
| 68 ToolbarSearchFieldDelegate.prototype = { |
| 69 /** @override */ |
| 70 onSearchTermSearch: function(searchTerm) { |
| 71 this.toolbar_.onSearchTermSearch(searchTerm); |
| 72 } |
| 73 }; |
| OLD | NEW |