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

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: Addressed comments. 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..bc670e0b04cb6de14419932ae7becb483a145b01 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');
@@ -3498,7 +3500,7 @@ DialogType.isModal = function(type) {
/**
* Invoked when the search box is changed.
*
- * @param {Event} event The 'changed' event.
+ * @param {Event} event The changed event.
* @private
*/
FileManager.prototype.onSearchBoxUpdate_ = function(event) {
@@ -3523,6 +3525,25 @@ DialogType.isModal = function(type) {
};
/**
+ * Handles special keys such as Escape on the search box.
+ *
+ * @param {Event} event The keydown event.
+ * @private
+ */
+ FileManager.prototype.onSearchBoxKeyDown_ = function(event) {
+ // Handle only Esc key now.
+ if (event.keyCode != 27) return;
+ if (this.searchBox_.value) return;
+ var currentList = this.listType_ == FileManager.ListType.DETAIL ?
+ this.table_.list : this.grid_;
+ currentList.focus();
+ if (currentList.dataModel.length != 0 &&
+ currentList.selectionModel.selectedIndex == -1) {
+ currentList.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