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

Side by Side Diff: chrome/browser/resources/md_history/history_toolbar.js

Issue 2352293002: MD History: Replace app-route with a custom router (Closed)
Patch Set: Rebase Created 4 years, 2 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 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 // TODO(calamity): bind this to 9 // TODO(calamity): bind this to
10 // listContainer.selectedItem.selectedPaths.length. 10 // listContainer.selectedItem.selectedPaths.length.
11 count: { 11 count: {
12 type: Number, 12 type: Number,
13 value: 0, 13 value: 0,
14 observer: 'changeToolbarView_' 14 observer: 'changeToolbarView_'
15 }, 15 },
16 16
17 // True if 1 or more history items are selected. When this value changes 17 // True if 1 or more history items are selected. When this value changes
18 // the background colour changes. 18 // the background colour changes.
19 itemsSelected_: { 19 itemsSelected_: {
20 type: Boolean, 20 type: Boolean,
21 value: false, 21 value: false,
22 reflectToAttribute: true 22 reflectToAttribute: true
23 }, 23 },
24 24
25 // The most recent term entered in the search field. Updated incrementally 25 // The most recent term entered in the search field. Updated incrementally
26 // as the user types. 26 // as the user types.
27 searchTerm: { 27 searchTerm: {
28 type: String, 28 type: String,
29 observer: 'searchTermChanged_',
29 notify: true, 30 notify: true,
30 }, 31 },
31 32
32 // True if the backend is processing and a spinner should be shown in the 33 // True if the backend is processing and a spinner should be shown in the
33 // toolbar. 34 // toolbar.
34 spinnerActive: { 35 spinnerActive: {
35 type: Boolean, 36 type: Boolean,
36 value: false 37 value: false
37 }, 38 },
38 39
(...skipping 28 matching lines...) Expand all
67 // Whether to show the menu promo (a tooltip that points at the menu button 68 // Whether to show the menu promo (a tooltip that points at the menu button
68 // in narrow mode). 69 // in narrow mode).
69 showMenuPromo_: { 70 showMenuPromo_: {
70 type: Boolean, 71 type: Boolean,
71 value: function() { 72 value: function() {
72 return loadTimeData.getBoolean('showMenuPromo'); 73 return loadTimeData.getBoolean('showMenuPromo');
73 }, 74 },
74 }, 75 },
75 }, 76 },
76 77
78 /** @return {CrToolbarSearchFieldElement} */
79 get searchField() {
80 return /** @type {CrToolbarElement} */ (this.$['main-toolbar'])
81 .getSearchField();
82 },
83
84 showSearchField: function() {
85 this.searchField.showAndFocus();
86 },
87
77 /** 88 /**
78 * Changes the toolbar background color depending on whether any history items 89 * Changes the toolbar background color depending on whether any history items
79 * are currently selected. 90 * are currently selected.
80 * @private 91 * @private
81 */ 92 */
82 changeToolbarView_: function() { 93 changeToolbarView_: function() {
83 this.itemsSelected_ = this.count > 0; 94 this.itemsSelected_ = this.count > 0;
84 }, 95 },
85 96
86 /** 97 /**
87 * When changing the search term externally, update the search field to 98 * When changing the search term externally, update the search field to
88 * reflect the new search term. 99 * reflect the new search term.
89 * @param {string} search
90 */ 100 */
91 setSearchTerm: function(search) { 101 searchTermChanged_: function() {
92 if (this.searchTerm == search) 102 if (this.searchField.getValue() != this.searchTerm) {
93 return; 103 this.searchField.showAndFocus();
94 104 this.searchField.setValue(this.searchTerm);
95 this.searchTerm = search; 105 }
96 var searchField = /** @type {!CrToolbarElement} */(this.$['main-toolbar'])
97 .getSearchField();
98 searchField.showAndFocus();
99 searchField.setValue(search);
100 }, 106 },
101 107
102 /** @private */ 108 /** @private */
103 onMenuPromoShown_: function() { 109 onMenuPromoShown_: function() {
104 md_history.BrowserService.getInstance().menuPromoShown(); 110 md_history.BrowserService.getInstance().menuPromoShown();
105 }, 111 },
106 112
107 /** 113 /**
108 * @param {!CustomEvent} event 114 * @param {!CustomEvent} event
109 * @private 115 * @private
(...skipping 13 matching lines...) Expand all
123 }, 129 },
124 130
125 onClearSelectionTap_: function() { 131 onClearSelectionTap_: function() {
126 this.fire('unselect-all'); 132 this.fire('unselect-all');
127 }, 133 },
128 134
129 onDeleteTap_: function() { 135 onDeleteTap_: function() {
130 this.fire('delete-selected'); 136 this.fire('delete-selected');
131 }, 137 },
132 138
133 get searchBar() {
134 return this.$['main-toolbar'].getSearchField();
135 },
136
137 showSearchField: function() {
138 /** @type {!CrToolbarElement} */(this.$['main-toolbar'])
139 .getSearchField()
140 .showAndFocus();
141 },
142
143 /** 139 /**
144 * If the user is a supervised user the delete button is not shown. 140 * If the user is a supervised user the delete button is not shown.
145 * @private 141 * @private
146 */ 142 */
147 deletingAllowed_: function() { 143 deletingAllowed_: function() {
148 return loadTimeData.getBoolean('allowDeletingHistory'); 144 return loadTimeData.getBoolean('allowDeletingHistory');
149 }, 145 },
150 146
151 numberOfItemsSelected_: function(count) { 147 numberOfItemsSelected_: function(count) {
152 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : ''; 148 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : '';
153 }, 149 },
154 150
155 getHistoryInterval_: function(queryStartTime, queryEndTime) { 151 getHistoryInterval_: function(queryStartTime, queryEndTime) {
156 // TODO(calamity): Fix the format of these dates. 152 // TODO(calamity): Fix the format of these dates.
157 return loadTimeData.getStringF( 153 return loadTimeData.getStringF(
158 'historyInterval', queryStartTime, queryEndTime); 154 'historyInterval', queryStartTime, queryEndTime);
159 }, 155 },
160 156
161 /** @private */ 157 /** @private */
162 hasDrawerChanged_: function() { 158 hasDrawerChanged_: function() {
163 this.updateStyles(); 159 this.updateStyles();
164 }, 160 },
165 }); 161 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698