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

Unified Diff: chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js

Issue 23514006: [Wallpaper Picker] Pressing <Escape> closes the active overlay (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added TODO Created 7 years, 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js
diff --git a/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js b/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js
index be090ff18d4d8c9a55d477dd671deab3cad8a174..d7232175edfc5f7b4ffc724bc838e842af72ca32 100644
--- a/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js
+++ b/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js
@@ -274,6 +274,8 @@ function WallpaperManager(dialogDom) {
});
this.document_.defaultView.addEventListener(
'resize', this.onResize_.bind(this));
+ this.document_.defaultView.addEventListener(
+ 'keydown', this.onKeyDown_.bind(this));
$('learn-more').href = LearnMoreURL;
$('close-error').addEventListener('click', function() {
$('error-container').hidden = true;
@@ -653,6 +655,25 @@ function WallpaperManager(dialogDom) {
};
/**
+ * Close the last opened overlay on pressing the Escape key.
+ * @param {Event} event A keydown event.
+ */
+ WallpaperManager.prototype.onKeyDown_ = function(event) {
+ if (event.keyCode == 27) {
+ // The last opened overlay coincides with the first match of querySelector
+ // because the Error Container is declared in the DOM before the Wallpaper
+ // Selection Container.
+ // TODO(bshe): Make the overlay selection not dependent on the DOM.
+ var closeButtonSelector = '.overlay-container:not([hidden]) .close';
+ var closeButton = this.document_.querySelector(closeButtonSelector);
+ if (closeButton) {
+ closeButton.click();
+ event.preventDefault();
+ }
+ }
+ };
+
+ /**
* Constructs the categories list.
*/
WallpaperManager.prototype.initCategoriesList_ = function() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698