Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.js

Issue 2311093002: MD WebUI: Use dom-if to control hidden elements in <cr-toolbar> (Closed)
Patch Set: Fix tests Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // TODO(tsergeant): Add tests for cr-toolbar-search-field. 5 // TODO(tsergeant): Add tests for cr-toolbar-search-field.
6 Polymer({ 6 Polymer({
7 is: 'cr-toolbar-search-field', 7 is: 'cr-toolbar-search-field',
8 8
9 behaviors: [CrSearchFieldBehavior], 9 behaviors: [CrSearchFieldBehavior],
10 10
(...skipping 11 matching lines...) Expand all
22 22
23 // When true, show a loading spinner to indicate that the backend is 23 // When true, show a loading spinner to indicate that the backend is
24 // processing the search. Will only show if the search field is open. 24 // processing the search. Will only show if the search field is open.
25 spinnerActive: { 25 spinnerActive: {
26 type: Boolean, 26 type: Boolean,
27 reflectToAttribute: true 27 reflectToAttribute: true
28 }, 28 },
29 29
30 /** @private */ 30 /** @private */
31 hasSearchText_: Boolean, 31 hasSearchText_: Boolean,
32
33 isSpinnerShown_: {
34 type: Boolean,
35 computed: 'computeIsSpinnerShown_(spinnerActive, showingSearch)'
36 }
32 }, 37 },
33 38
34 listeners: { 39 listeners: {
35 'tap': 'showSearch_', 40 'tap': 'showSearch_',
36 'searchInput.bind-value-changed': 'onBindValueChanged_', 41 'searchInput.bind-value-changed': 'onBindValueChanged_',
37 }, 42 },
38 43
39 /** @return {!HTMLInputElement} */ 44 /** @return {!HTMLInputElement} */
40 getSearchInput: function() { 45 getSearchInput: function() {
41 return this.$.searchInput; 46 return this.$.searchInput;
42 }, 47 },
43 48
44 /** @return {boolean} */ 49 /** @return {boolean} */
45 isSearchFocused: function() { 50 isSearchFocused: function() {
46 return this.$.searchTerm.focused; 51 return this.$.searchTerm.focused;
47 }, 52 },
48 53
49 /** 54 /**
50 * @param {boolean} narrow 55 * @param {boolean} narrow
51 * @return {number} 56 * @return {number}
52 * @private 57 * @private
53 */ 58 */
54 computeIconTabIndex_: function(narrow) { 59 computeIconTabIndex_: function(narrow) {
55 return narrow ? 0 : -1; 60 return narrow ? 0 : -1;
56 }, 61 },
57 62
58 /** 63 /**
59 * @param {boolean} spinnerActive
60 * @param {boolean} showingSearch
61 * @return {boolean} 64 * @return {boolean}
62 * @private 65 * @private
63 */ 66 */
64 isSpinnerShown_: function(spinnerActive, showingSearch) { 67 computeIsSpinnerShown_: function() {
65 return spinnerActive && showingSearch; 68 return this.spinnerActive && this.showingSearch;
66 }, 69 },
67 70
68 /** @private */ 71 /** @private */
69 onInputBlur_: function() { 72 onInputBlur_: function() {
70 if (!this.hasSearchText_) 73 if (!this.hasSearchText_)
71 this.showingSearch = false; 74 this.showingSearch = false;
72 }, 75 },
73 76
74 /** 77 /**
75 * Update the state of the search field whenever the underlying input value 78 * Update the state of the search field whenever the underlying input value
(...skipping 19 matching lines...) Expand all
95 98
96 /** 99 /**
97 * @param {Event} e 100 * @param {Event} e
98 * @private 101 * @private
99 */ 102 */
100 hideSearch_: function(e) { 103 hideSearch_: function(e) {
101 this.showingSearch = false; 104 this.showingSearch = false;
102 e.stopPropagation(); 105 e.stopPropagation();
103 } 106 }
104 }); 107 });
OLDNEW
« no previous file with comments | « ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698