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

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: '' 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
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..cfe4770b703c304ea4c33f588a6109464bb7c59d 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
@@ -1311,15 +1318,19 @@ function setSuggestionStyles() {
* @param {Object} e The key being pressed.
*/
function handleKeyPress(e) {
- if (!activeBox)
- return;
-
switch (e.keyCode) {
case KEY_UP_ARROW:
- activeBox.selectPrevious();
+ if (activeBox)
+ activeBox.selectPrevious();
break;
case KEY_DOWN_ARROW:
- activeBox.selectNext();
+ if (activeBox)
+ activeBox.selectNext();
+ break;
+ case KEY_ESC:
+ hideActiveSuggestions();
samarth 2013/05/04 01:04:17 There are two cases here too :) 1) You type someth
kmadhusu 2013/05/04 03:34:38 Done.
+ document.body.classList.remove(CLASSES.HIDE_NTP);
+ onThemeChange();
samarth 2013/05/04 01:04:17 Not sure if this is the right way to go back to th
kmadhusu 2013/05/04 03:34:38 This call reloads the background theme if one exis
break;
}
}
« no previous file with comments | « no previous file | chrome/browser/ui/search/instant_controller.h » ('j') | chrome/browser/ui/search/instant_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698