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

Side by Side Diff: chrome/browser/resources/md_downloads/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: Nit 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 cr.define('downloads', function() { 5 cr.define('downloads', function() {
6 var Toolbar = Polymer({ 6 var Toolbar = Polymer({
7 is: 'downloads-toolbar', 7 is: 'downloads-toolbar',
8 8
9 attached: function() { 9 attached: function() {
10 // isRTL() only works after i18n_template.js runs to set <html dir>. 10 // isRTL() only works after i18n_template.js runs to set <html dir>.
11 this.overflowAlign_ = isRTL() ? 'left' : 'right'; 11 this.overflowAlign_ = isRTL() ? 'left' : 'right';
12
13 /** @private {!SearchFieldDelegate} */
14 this.searchFieldDelegate_ = new ToolbarSearchFieldDelegate(this);
15 this.$['search-input'].setDelegate(this.searchFieldDelegate_);
16 }, 12 },
17 13
18 properties: { 14 properties: {
19 downloadsShowing: { 15 downloadsShowing: {
20 reflectToAttribute: true, 16 reflectToAttribute: true,
21 type: Boolean, 17 type: Boolean,
22 value: false, 18 value: false,
23 observer: 'downloadsShowingChanged_', 19 observer: 'downloadsShowingChanged_',
24 }, 20 },
25 21
(...skipping 21 matching lines...) Expand all
47 onClearAllTap_: function() { 43 onClearAllTap_: function() {
48 assert(this.canClearAll()); 44 assert(this.canClearAll());
49 downloads.ActionService.getInstance().clearAll(); 45 downloads.ActionService.getInstance().clearAll();
50 }, 46 },
51 47
52 /** @private */ 48 /** @private */
53 downloadsShowingChanged_: function() { 49 downloadsShowingChanged_: function() {
54 this.updateClearAll_(); 50 this.updateClearAll_();
55 }, 51 },
56 52
57 /** @param {string} searchTerm */ 53 /**
58 onSearchTermSearch: function(searchTerm) { 54 * @param {!Event} event
Dan Beam 2016/06/14 18:52:01 nit: CustomEvent
dpapad 2016/06/14 19:17:35 Done.
59 downloads.ActionService.getInstance().search(searchTerm); 55 * @private
56 */
57 onSearch_: function(event) {
58 downloads.ActionService.getInstance().search(event.detail);
60 this.updateClearAll_(); 59 this.updateClearAll_();
61 }, 60 },
62 61
63 /** @private */ 62 /** @private */
64 onOpenDownloadsFolderTap_: function() { 63 onOpenDownloadsFolderTap_: function() {
65 downloads.ActionService.getInstance().openDownloadsFolder(); 64 downloads.ActionService.getInstance().openDownloadsFolder();
66 }, 65 },
67 66
68 /** @private */ 67 /** @private */
69 updateClearAll_: function() { 68 updateClearAll_: function() {
70 this.$$('#actions .clear-all').hidden = !this.canClearAll(); 69 this.$$('#actions .clear-all').hidden = !this.canClearAll();
71 this.$$('paper-menu .clear-all').hidden = !this.canClearAll(); 70 this.$$('paper-menu .clear-all').hidden = !this.canClearAll();
72 }, 71 },
73 }); 72 });
74 73
75 /**
76 * @constructor
77 * @implements {SearchFieldDelegate}
78 */
79 // TODO(devlin): This is a bit excessive, and it would be better to just have
80 // Toolbar implement SearchFieldDelegate. But for now, we don't know how to
81 // make that happen with closure compiler.
82 function ToolbarSearchFieldDelegate(toolbar) {
83 this.toolbar_ = toolbar;
84 }
85
86 ToolbarSearchFieldDelegate.prototype = {
87 /** @override */
88 onSearchTermSearch: function(searchTerm) {
89 this.toolbar_.onSearchTermSearch(searchTerm);
90 }
91 };
92
93 return {Toolbar: Toolbar}; 74 return {Toolbar: Toolbar};
94 }); 75 });
95 76
96 // TODO(dbeam): https://github.com/PolymerElements/iron-dropdown/pull/16/files 77 // TODO(dbeam): https://github.com/PolymerElements/iron-dropdown/pull/16/files
97 /** @suppress {checkTypes} */ 78 /** @suppress {checkTypes} */
98 (function() { 79 (function() {
99 Polymer.IronDropdownScrollManager.pushScrollLock = function() {}; 80 Polymer.IronDropdownScrollManager.pushScrollLock = function() {};
100 })(); 81 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698