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

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

Issue 2060023002: WebUI: cr-search-field: Remove delegation pattern, use simple event instead. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@search_box0
Patch Set: Address comments, fix compilation. 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 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 /**
6 * @constructor
7 * @implements {SearchFieldDelegate}
8 * @param {!HistoryToolbarElement} toolbar This history-toolbar.
9 */
10 function ToolbarSearchFieldDelegate(toolbar) {
11 this.toolbar_ = toolbar;
12 }
13
14 ToolbarSearchFieldDelegate.prototype = {
15 /** @override */
16 onSearchTermSearch: function(searchTerm) {
17 this.toolbar_.onSearch(searchTerm);
18 }
19 };
20
21 Polymer({ 5 Polymer({
22 is: 'history-toolbar', 6 is: 'history-toolbar',
23 properties: { 7 properties: {
24 // Number of history items currently selected. 8 // Number of history items currently selected.
25 count: { 9 count: {
26 type: Number, 10 type: Number,
27 value: 0, 11 value: 0,
28 observer: 'changeToolbarView_' 12 observer: 'changeToolbarView_'
29 }, 13 },
30 14
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 return; 74 return;
91 75
92 this.searchTerm = search; 76 this.searchTerm = search;
93 var searchField = /** @type {!CrToolbarElement} */(this.$['main-toolbar']) 77 var searchField = /** @type {!CrToolbarElement} */(this.$['main-toolbar'])
94 .getSearchField(); 78 .getSearchField();
95 searchField.showAndFocus(); 79 searchField.showAndFocus();
96 searchField.setValue(search); 80 searchField.setValue(search);
97 }, 81 },
98 82
99 /** 83 /**
100 * @param {string} searchTerm 84 * @param {!CustomEvent} event
85 * @private
101 */ 86 */
102 onSearch: function(searchTerm) { 87 onSearchChanged_: function(event) {
103 this.searchTerm = searchTerm; 88 this.searchTerm = /** @type {string} */ (event.detail);
104 },
105
106 attached: function() {
107 this.searchFieldDelegate_ = new ToolbarSearchFieldDelegate(this);
108 /** @type {!CrToolbarElement} */(this.$['main-toolbar']).getSearchField()
109 .setDelegate(this.searchFieldDelegate_);
110 }, 89 },
111 90
112 onClearSelectionTap_: function() { 91 onClearSelectionTap_: function() {
113 this.fire('unselect-all'); 92 this.fire('unselect-all');
114 }, 93 },
115 94
116 onDeleteTap_: function() { 95 onDeleteTap_: function() {
117 this.fire('delete-selected'); 96 this.fire('delete-selected');
118 }, 97 },
119 98
120 /** 99 /**
121 * If the user is a supervised user the delete button is not shown. 100 * If the user is a supervised user the delete button is not shown.
122 * @private 101 * @private
123 */ 102 */
124 deletingAllowed_: function() { 103 deletingAllowed_: function() {
125 return loadTimeData.getBoolean('allowDeletingHistory'); 104 return loadTimeData.getBoolean('allowDeletingHistory');
126 }, 105 },
127 106
128 numberOfItemsSelected_: function(count) { 107 numberOfItemsSelected_: function(count) {
129 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : ''; 108 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : '';
130 }, 109 },
131 110
132 getHistoryInterval_: function(queryStartTime, queryEndTime) { 111 getHistoryInterval_: function(queryStartTime, queryEndTime) {
133 // TODO(calamity): Fix the format of these dates. 112 // TODO(calamity): Fix the format of these dates.
134 return loadTimeData.getStringF( 113 return loadTimeData.getStringF(
135 'historyInterval', queryStartTime, queryEndTime); 114 'historyInterval', queryStartTime, queryEndTime);
136 } 115 }
137 }); 116 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698