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

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

Issue 14562006: Handle Esc key press event in Local NTP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated description and added a TODO to handle !full_text.empty case. Created 7 years, 8 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 | chrome/browser/ui/search/instant_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/local_ntp/local_ntp.js
diff --git a/chrome/browser/resources/local_ntp/local_ntp.js b/chrome/browser/resources/local_ntp/local_ntp.js
index 43b0f717ac4c5173b699fbb2499c33b1a5fba58a..b0caa6430c29a828f3cd53846d080cea625a0355 100644
--- a/chrome/browser/resources/local_ntp/local_ntp.js
+++ b/chrome/browser/resources/local_ntp/local_ntp.js
@@ -648,6 +648,13 @@ var KEY_UP_ARROW = 38;
var KEY_DOWN_ARROW = 40;
/**
+ * "Esc" keycode.
+ * @type {number}
+ * @const
+ */
+var KEY_ESC = 27;
+
+/**
* Pixels of padding inside a suggestion div for displaying its icon.
* @type {number}
* @const
@@ -1074,6 +1081,16 @@ SuggestionsBox.prototype = {
},
/**
+ * Clears the selected suggestion.
+ */
+ clearSelection: function() {
+ this.selectedIndex_ = -1;
+ var oldSelection = this.container_.querySelector('.' + CLASSES.SELECTED);
+ if (oldSelection)
+ oldSelection.classList.remove(CLASSES.SELECTED);
+ },
+
+ /**
* Changes the current selected suggestion index.
* @param {number} index The new selection to suggest.
* @private
@@ -1153,6 +1170,13 @@ SuggestionsBox.prototype = {
},
/**
jeremycho 2013/05/04 23:07:06 nit: move this alongside the other selection funct
kmadhusu 2013/05/05 22:44:54 Done.
+ * Returns the selected suggestion index.
+ */
+ selectedIndex: function() {
+ return this.selectedIndex_;
+ },
+
+ /**
* Redraws the mouse hover background.
* @private
*/
@@ -1321,6 +1345,15 @@ function handleKeyPress(e) {
case KEY_DOWN_ARROW:
activeBox.selectNext();
break;
+ case KEY_ESC:
+ if (activeBox.selectedIndex() != -1) {
jeremycho 2013/05/04 23:07:06 Make this check a function and use it elsewhere.
kmadhusu 2013/05/05 22:44:54 Done.
+ activeBox.clearSelection();
+ } else {
+ hideActiveSuggestions();
+ document.body.classList.remove(CLASSES.HIDE_NTP);
jeremycho 2013/05/04 23:07:06 Can you factor the show/hide logic into a helper f
kmadhusu 2013/05/05 22:44:54 Done. Added showNtp().
+ onThemeChange();
+ }
+ break;
}
}
« no previous file with comments | « no previous file | chrome/browser/ui/search/instant_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698