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

Unified Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 16018008: Files.app: Added an Esc key handler to the search box. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/js/file_manager.js
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
index 8ae8d9d4e2a7536dcab3d66df1b1054e5d896c92..4795e94bc050e342d2e5f1f0bc5581fa76a7cf97 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -1049,6 +1049,8 @@ DialogType.isModal = function(type) {
this.searchBox_ = this.dialogDom_.querySelector('#search-box');
this.searchBox_.addEventListener(
'input', this.onSearchBoxUpdate_.bind(this));
+ this.searchBox_.addEventListener(
+ 'keydown', this.onSearchBoxKeyDown_.bind(this));
this.searchTextMeasure_ = new TextMeasure(this.searchBox_);
if (util.platform.newUI()) {
this.searchIcon_ = this.dialogDom_.querySelector('#search-icon');
@@ -3523,6 +3525,28 @@ DialogType.isModal = function(type) {
};
/**
+ * Handled to special key such as ESC.
mtomasz 2013/05/28 04:07:06 We usually start with a passive verb. Eg. Handles
hirono 2013/05/28 04:24:26 Done.
+ * Normal text inputs should not be handled by this, should be handled by
mtomasz 2013/05/28 04:07:06 I think that the second line is confusing. The fir
hirono 2013/05/28 04:24:26 Done.
+ * onSearchBoxUpdate_.
+ *
+ * @param {Event} event The 'keydown' event.
mtomasz 2013/05/28 04:07:06 Without '' for consistency.
hirono 2013/05/28 04:24:26 Done.
+ * @private
+ */
+ FileManager.prototype.onSearchBoxKeyDown_ = function(event) {
+ // Handle only Esc key now.
+ if (event.keyCode != 27) return;
+ if (this.searchBox_.value) return;
+ if (this.listType_ == FileManager.ListType.DETAIL) {
+ this.table_.list.focus();
+ } else if (this.listType_ == FileManager.ListType.THUMBNAIL) {
+ this.grid_.focus();
+ // The grid not selects its item when focused.
mtomasz 2013/05/28 04:07:06 not selects -> does not select
hirono 2013/05/28 04:24:26 Done.
+ if (this.grid_.dataModel.length != 0)
mtomasz 2013/05/28 04:07:06 Shall we do it for the table list too?
hirono 2013/05/28 04:24:26 Done.
+ this.grid_.selectionModel.selectedIndex = 0;
+ }
+ };
+
+ /**
* Updates search box's CSS classes.
* These classes are refered from CSS.
*
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698