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

Unified Diff: chrome/browser/resources/md_downloads/toolbar.js

Issue 1308893009: [MD Extensions] Move search field out of downloads, use it in extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dan's + move search field to cr_search_field Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
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};
});

Powered by Google App Engine
This is Rietveld 408576698