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 36d6cf42a26bd6d5ad99941ed69a47f50a484608..ee77499a633e33e87a925437d328f80848cf06d9 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 {!cr.ui.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,43 +48,41 @@ cr.define('downloads', function() { |
| this.updateClearAll_(); |
| }, |
| - /** @private */ |
| - onSearchTermSearch_: function() { |
| - this.actionService_.search(this.$['search-input'].value); |
| + /** |
| + * @param {string} value |
| + */ |
| + 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_; |
| - |
| - 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 {cr.ui.SearchField.Delegate} |
| + */ |
| + function ToolbarSearchFieldDelegate(toolbar) { |
| + this.toolbar_ = toolbar; |
| + }; |
|
Dan Beam
2015/09/14 19:22:05
}; -> }
Devlin
2015/09/14 21:47:18
Done.
|
| + |
| + ToolbarSearchFieldDelegate.prototype = { |
| + /** @override */ |
| + onSearchTermSearch: function(value) { |
| + this.toolbar_.onSearchTermSearch(value); |
| + } |
| + }; |
| + |
| return {Toolbar: Toolbar}; |
| }); |