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 /** | 5 /** |
6 * Helper functions for implementing an incremental search field. See | 6 * Helper functions for implementing an incremental search field. See |
7 * <settings-subpage-search> for a simple implementation. | 7 * <settings-subpage-search> for a simple implementation. |
8 * @polymerBehavior | 8 * @polymerBehavior |
9 */ | 9 */ |
10 var CrSearchFieldBehavior = { | 10 var CrSearchFieldBehavior = { |
(...skipping 18 matching lines...) Expand all Loading... |
29 /** | 29 /** |
30 * @abstract | 30 * @abstract |
31 * @return {!HTMLInputElement} The input field element the behavior should | 31 * @return {!HTMLInputElement} The input field element the behavior should |
32 * use. | 32 * use. |
33 */ | 33 */ |
34 getSearchInput: function() {}, | 34 getSearchInput: function() {}, |
35 | 35 |
36 /** | 36 /** |
37 * @return {string} The value of the search field. | 37 * @return {string} The value of the search field. |
38 */ | 38 */ |
39 getValue: function() { | 39 getValue: function() { return this.getSearchInput().value; }, |
40 return this.getSearchInput().value; | |
41 }, | |
42 | 40 |
43 /** | 41 /** |
44 * Sets the value of the search field. | 42 * Sets the value of the search field. |
45 * @param {string} value | 43 * @param {string} value |
46 * @param {boolean=} opt_noEvent Whether to prevent a 'search-changed' event | 44 * @param {boolean=} opt_noEvent Whether to prevent a 'search-changed' event |
47 * firing for this change. | 45 * firing for this change. |
48 */ | 46 */ |
49 setValue: function(value, opt_noEvent) { | 47 setValue: function(value, opt_noEvent) { |
50 var searchInput = this.getSearchInput(); | 48 var searchInput = this.getSearchInput(); |
51 searchInput.value = value; | 49 searchInput.value = value; |
(...skipping 15 matching lines...) Expand all Loading... |
67 onValueChanged_: function(newValue, noEvent) { | 65 onValueChanged_: function(newValue, noEvent) { |
68 if (newValue == this.lastValue_) | 66 if (newValue == this.lastValue_) |
69 return; | 67 return; |
70 | 68 |
71 this.lastValue_ = newValue; | 69 this.lastValue_ = newValue; |
72 | 70 |
73 if (!noEvent) | 71 if (!noEvent) |
74 this.fire('search-changed', newValue); | 72 this.fire('search-changed', newValue); |
75 }, | 73 }, |
76 }; | 74 }; |
OLD | NEW |