| 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 = {
|
| },
|
|
|
| /**
|
| + * 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) {
|
| + activeBox.clearSelection();
|
| + } else {
|
| + hideActiveSuggestions();
|
| + document.body.classList.remove(CLASSES.HIDE_NTP);
|
| + onThemeChange();
|
| + }
|
| + break;
|
| }
|
| }
|
|
|
|
|