Chromium Code Reviews| Index: chrome/browser/resources/md_downloads/toolbar.js |
| diff --git a/chrome/browser/resources/md_downloads/toolbar.js b/chrome/browser/resources/md_downloads/toolbar.js |
| index 0611152c87c03b7b99a9dea2ed223176651808ee..f9d7b989073671234b893338cb0e13a230e1c6d8 100644 |
| --- a/chrome/browser/resources/md_downloads/toolbar.js |
| +++ b/chrome/browser/resources/md_downloads/toolbar.js |
| @@ -12,6 +12,12 @@ cr.define('downloads', function() { |
| this.actionService_ = actionService; |
| }, |
| + attached: function() { |
| + /** @private {!SearchField.Delegate} */ |
| + this.searchFieldDelegate_ = new ToolbarSearchFieldDelegate(this); |
| + this.$['search-input'].setDelegate(this.searchFieldDelegate_); |
| + }, |
| + |
| properties: { |
| downloadsShowing: { |
| reflectToAttribute: true, |
| @@ -19,11 +25,6 @@ cr.define('downloads', function() { |
| value: false, |
| observer: 'onDownloadsShowingChange_', |
| }, |
| - |
| - showingSearch_: { |
| - type: Boolean, |
| - value: false, |
| - }, |
| }, |
| /** @return {boolean} Whether removal can be undone. */ |
| @@ -33,7 +34,7 @@ cr.define('downloads', function() { |
| /** @return {boolean} Whether "Clear all" should be allowed. */ |
| canClearAll: function() { |
| - return !this.$['search-input'].value && this.downloadsShowing; |
| + return !this.$['search-input'].getValue() && this.downloadsShowing; |
| }, |
| /** @private */ |
| @@ -47,44 +48,41 @@ cr.define('downloads', function() { |
| this.updateClearAll_(); |
| }, |
| - /** @private */ |
| - onSearchTermSearch_: function() { |
| - this.actionService_.search(this.$['search-input'].value); |
| + /** |
| + * @param {string} value |
|
Dan Beam
2015/09/14 23:16:06
nit: /** @param {string} ... */ if it fits in one
Dan Beam
2015/09/14 23:16:06
nit: value -> searchText
Devlin
2015/09/15 17:24:06
Done.
Devlin
2015/09/15 17:24:06
Done.
|
| + */ |
| + onSearchTermSearch: function(value) { |
| + this.actionService_.search(value); |
| this.updateClearAll_(); |
| }, |
| /** @private */ |
| - onSearchTermKeydown_: function(e) { |
| - assert(this.showingSearch_); |
| - if (e.keyIdentifier == 'U+001B') // Escape. |
| - this.toggleShowingSearch_(); |
| - }, |
| - |
| - /** @private */ |
| onOpenDownloadsFolderClick_: function() { |
| this.actionService_.openDownloadsFolder(); |
| }, |
| /** @private */ |
| - toggleShowingSearch_: function() { |
| - this.showingSearch_ = !this.showingSearch_; |
| - this.$['search-button'].disabled = this.showingSearch_; |
| - |
| - if (this.showingSearch_) { |
| - this.$['search-input'].focus(); |
| - } else { |
| - this.$['search-input'].value = ''; |
| - this.onSearchTermSearch_(); |
| - } |
| - }, |
| - |
| - /** @private */ |
| updateClearAll_: function() { |
| this.$$('#actions .clear-all').hidden = !this.canClearAll(); |
| this.$$('paper-menu .clear-all').hidden = !this.canClearAll(); |
| }, |
| }); |
| + /** |
| + * @constructor |
| + * @implements {SearchField.Delegate} |
| + */ |
| + function ToolbarSearchFieldDelegate(toolbar) { |
| + this.toolbar_ = toolbar; |
| + } |
| + |
| + ToolbarSearchFieldDelegate.prototype = { |
| + /** @override */ |
| + onSearchTermSearch: function(value) { |
|
Dan Beam
2015/09/14 23:16:06
can downloads.Toolbar just implement SearchField.D
Dan Beam
2015/09/14 23:52:54
safe to ignore if this isn't currently feasible
|
| + this.toolbar_.onSearchTermSearch(value); |
| + } |
| + }; |
| + |
| return {Toolbar: Toolbar}; |
| }); |