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

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

Issue 1613233003: MD Downloads: make Ctrl+f invoke in-page search (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dl-vulcanize
Patch Set: Created 4 years, 11 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/crisper.js
diff --git a/chrome/browser/resources/md_downloads/crisper.js b/chrome/browser/resources/md_downloads/crisper.js
index 49a250bcb188dbd7d5067557fd3422590f8622d2..ed14c889aa053be468139c46b8612e9a21f282d7 100644
--- a/chrome/browser/resources/md_downloads/crisper.js
+++ b/chrome/browser/resources/md_downloads/crisper.js
@@ -16875,15 +16875,15 @@ var SearchField = Polymer({
value: '',
},
- showingSearch_: {
+ showingSearch: {
type: Boolean,
value: false,
+ observer: 'showingSearchChanged_',
},
},
- /** @param {SearchFieldDelegate} delegate */
- setDelegate: function(delegate) {
- this.delegate_ = delegate;
+ focus: function() {
+ this.$$('#search-input').focus();
},
/**
@@ -16895,6 +16895,11 @@ var SearchField = Polymer({
return searchInput ? searchInput.value : '';
},
+ /** @param {SearchFieldDelegate} delegate */
+ setDelegate: function(delegate) {
+ this.delegate_ = delegate;
+ },
+
/** @private */
onSearchTermSearch_: function() {
if (this.delegate_)
@@ -16903,17 +16908,19 @@ var SearchField = Polymer({
/** @private */
onSearchTermKeydown_: function(e) {
- assert(this.showingSearch_);
if (e.keyIdentifier == 'U+001B') // Escape.
- this.toggleShowingSearch_();
+ this.showingSearch = false;
},
/** @private */
- toggleShowingSearch_: function() {
- this.showingSearch_ = !this.showingSearch_;
+ showingSearchChanged_: function() {
this.async(function() {
var searchInput = this.$$('#search-input');
- if (this.showingSearch_) {
+
+ if (!searchInput)
+ return;
+
+ if (this.showingSearch) {
searchInput.focus();
} else {
searchInput.value = '';
@@ -16921,6 +16928,11 @@ var SearchField = Polymer({
}
});
},
+
+ /** @private */
+ toggleShowingSearch_: function() {
+ this.showingSearch = !this.showingSearch;
+ },
});
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
@@ -16944,7 +16956,7 @@ cr.define('downloads', function() {
reflectToAttribute: true,
type: Boolean,
value: false,
- observer: 'onDownloadsShowingChange_',
+ observer: 'downloadsShowingChanged_',
},
overflowAlign_: {
@@ -16963,6 +16975,15 @@ cr.define('downloads', function() {
return !this.$['search-input'].getValue() && this.downloadsShowing;
},
+ onFindCommand: function() {
+ var searchInput = this.$ && this.$['search-input'];
+ if (!searchInput)
+ return;
+
+ searchInput.showingSearch = true;
+ searchInput.focus();
+ },
+
/** @private */
onClearAllTap_: function() {
assert(this.canClearAll());
@@ -16970,7 +16991,7 @@ cr.define('downloads', function() {
},
/** @private */
- onDownloadsShowingChange_: function() {
+ downloadsShowingChanged_: function() {
this.updateClearAll_();
},
@@ -17099,6 +17120,9 @@ cr.define('downloads', function() {
case 'clear-all-command':
e.canExecute = this.$.toolbar.canClearAll();
break;
+ case 'find-command':
+ e.canExecute = true;
+ break;
}
},
@@ -17111,6 +17135,8 @@ cr.define('downloads', function() {
downloads.ActionService.getInstance().clearAll();
else if (e.command.id == 'undo-command')
downloads.ActionService.getInstance().undo();
+ else if (e.command.id == 'find-command' && this.$ && this.$.toolbar)
+ this.$.toolbar.onFindCommand();
},
/** @private */
« no previous file with comments | « no previous file | chrome/browser/resources/md_downloads/downloads.html » ('j') | chrome/browser/resources/md_downloads/toolbar.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698