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

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

Issue 2032313002: MD WebUI: Add loading spinner to cr-toolbar, hook into MD History toolbar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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
11 properties: { 11 properties: {
12 narrow: { 12 narrow: {
13 type: Boolean, 13 type: Boolean,
14 reflectToAttribute: true, 14 reflectToAttribute: true,
15 }, 15 },
16 16
17 // Prompt text to display in the search field. 17 // Prompt text to display in the search field.
18 label: String, 18 label: String,
19 19
20 // Tooltip to display on the clear search button. 20 // Tooltip to display on the clear search button.
21 clearLabel: String, 21 clearLabel: String,
22
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.
25 processing: {
26 type: Boolean,
27 reflectToAttribute: true
28 },
22 }, 29 },
23 30
24 listeners: { 31 listeners: {
25 'tap': 'showSearch_', 32 'tap': 'showSearch_',
26 }, 33 },
27 34
28 /** 35 /**
29 * @param {boolean} narrow 36 * @param {boolean} narrow
30 * @return {number} 37 * @return {number}
31 * @private 38 * @private
32 */ 39 */
33 computeIconTabIndex_: function(narrow) { 40 computeIconTabIndex_: function(narrow) {
34 return narrow ? 0 : -1; 41 return narrow ? 0 : -1;
35 }, 42 },
36 43
44 isSpinnerActive_: function(processing, showingSearch) {
45 return processing && showingSearch;
46 },
47
37 /** @private */ 48 /** @private */
38 onInputBlur_: function() { 49 onInputBlur_: function() {
39 if (!this.hasSearchText) 50 if (!this.hasSearchText)
40 this.showingSearch = false; 51 this.showingSearch = false;
41 }, 52 },
42 53
43 /** 54 /**
44 * Expand the search field when a key is pressed with it focused. This ensures 55 * Expand the search field when a key is pressed with it focused. This ensures
45 * it can be used correctly by tab-focusing. 'keypress' is used instead of 56 * it can be used correctly by tab-focusing. 'keypress' is used instead of
46 * 'keydown' to avoid expanding on non-text keys (shift, escape, etc). 57 * 'keydown' to avoid expanding on non-text keys (shift, escape, etc).
(...skipping 14 matching lines...) Expand all
61 72
62 /** 73 /**
63 * @param {Event} e 74 * @param {Event} e
64 * @private 75 * @private
65 */ 76 */
66 hideSearch_: function(e) { 77 hideSearch_: function(e) {
67 this.showingSearch = false; 78 this.showingSearch = false;
68 e.stopPropagation(); 79 e.stopPropagation();
69 } 80 }
70 }); 81 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698