Chromium Code Reviews| Index: ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js |
| diff --git a/ui/webui/resources/cr_elements/cr_search_field/cr_search_field.js b/ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js |
| similarity index 83% |
| copy from ui/webui/resources/cr_elements/cr_search_field/cr_search_field.js |
| copy to ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js |
| index a507fc34f663939c5889c21c3a7455d533265b6d..cd06ac9d1b440fd10413e15e79cd04b925e5d9a7 100644 |
| --- a/ui/webui/resources/cr_elements/cr_search_field/cr_search_field.js |
| +++ b/ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js |
| @@ -1,4 +1,4 @@ |
| -// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| @@ -12,9 +12,12 @@ SearchFieldDelegate.prototype = { |
| onSearchTermSearch: assertNotReached, |
| }; |
| -var SearchField = Polymer({ |
| - is: 'cr-search-field', |
| - |
| +/** |
| + * Implements an incremental search field which can be shown and hidden. |
| + * Canonical implementation is <cr-search-field>. |
| + * @polymerBehavior |
| + */ |
| +var CrSearchFieldBehavior = { |
| properties: { |
| label: { |
| type: String, |
| @@ -30,7 +33,12 @@ var SearchField = Polymer({ |
| type: Boolean, |
| value: false, |
| observer: 'showingSearchChanged_', |
| + reflectToAttribute: true |
| }, |
| + |
| + hasSearchText_: { |
|
dpapad
2016/05/19 23:19:47
@private
tsergeant
2016/05/20 00:27:12
Done.
|
| + type: Boolean, |
| + } |
| }, |
| /** |
| @@ -50,6 +58,7 @@ var SearchField = Polymer({ |
| var searchInput = this.getSearchInput_(); |
| if (searchInput) |
| searchInput.value = value; |
| + this.hasSearchText_ = this.getValue() != ''; |
| }, |
| /** @param {SearchFieldDelegate} delegate */ |
| @@ -85,11 +94,12 @@ var SearchField = Polymer({ |
| * @private |
| */ |
| getSearchInput_: function() { |
| - return this.$$('#search-input'); |
| + return this.$$('#searchInput'); |
| }, |
| /** @private */ |
| onSearchTermSearch_: function() { |
| + this.hasSearchText_ = this.getValue() != ''; |
| if (this.delegate_) |
| this.delegate_.onSearchTermSearch(this.getValue()); |
| }, |
| @@ -118,5 +128,5 @@ var SearchField = Polymer({ |
| /** @private */ |
| toggleShowingSearch_: function() { |
| this.showingSearch_ = !this.showingSearch_; |
| - }, |
| -}); |
| + } |
| +}; |