Chromium Code Reviews| 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; |
| } |
| } |