diff options
Diffstat (limited to 'chrome/browser/resources/options/options_page.js')
-rw-r--r-- | chrome/browser/resources/options/options_page.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/chrome/browser/resources/options/options_page.js b/chrome/browser/resources/options/options_page.js index 4afad5b..4059117 100644 --- a/chrome/browser/resources/options/options_page.js +++ b/chrome/browser/resources/options/options_page.js @@ -33,7 +33,7 @@ cr.define('options', function() { OptionsPage.registeredSubPages_ = {}; /** - * Pages which are meant to behave like model dialogs. + * Pages which are meant to behave like modal dialogs. */ OptionsPage.registeredOverlayPages_ = {}; @@ -68,6 +68,9 @@ cr.define('options', function() { } }; + /** + * Clears overlays (i.e. hide all overlays). + */ OptionsPage.clearOverlays = function() { for (var name in OptionsPage.registeredOverlayPages_) { var page = OptionsPage.registeredOverlayPages_[name]; @@ -76,6 +79,17 @@ cr.define('options', function() { }; /** + * Clears overlays if the key event is ESC. + * @param {Event} e Key event. + * @private + */ + OptionsPage.clearOverlaysOnEsc_ = function(e) { + if (e.keyCode == 27) { // Esc + OptionsPage.clearOverlays(); + } + }; + + /** * Shows the tab contents for the given navigation tab. * @param {!Element} tab The tab that the user clicked. */ @@ -208,6 +222,8 @@ cr.define('options', function() { if (this.isOverlay) { var overlay = $('overlay'); overlay.classList.remove('hidden'); + document.addEventListener('keydown', + OptionsPage.clearOverlaysOnEsc_); } else { var banner = $('managed-prefs-banner'); banner.style.display = this.managed ? 'block' : 'none'; @@ -225,6 +241,8 @@ cr.define('options', function() { if (this.isOverlay) { var overlay = $('overlay'); overlay.classList.add('hidden'); + document.removeEventListener('keydown', + OptionsPage.clearOverlaysOnEsc_); } this.pageDiv.style.display = 'none'; if (this.tab) { |