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

Side by Side Diff: ui/webui/resources/js/cr/ui/page_manager/page.js

Issue 862403006: extensions: fix focus management for all dialogs (not just options). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@classList-fix
Patch Set: toggle Created 5 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 <include src="../node_utils.js"> 5 <include src="../node_utils.js">
6 6
7 cr.define('cr.ui.pageManager', function() { 7 cr.define('cr.ui.pageManager', function() {
8 var PageManager = cr.ui.pageManager.PageManager; 8 var PageManager = cr.ui.pageManager.PageManager;
9 9
10 /** 10 /**
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 * Called by the PageManager when this.hash changes while the page is 72 * Called by the PageManager when this.hash changes while the page is
73 * already visible. This is analogous to the hashchange DOM event. 73 * already visible. This is analogous to the hashchange DOM event.
74 */ 74 */
75 didChangeHash: function() {}, 75 didChangeHash: function() {},
76 76
77 /** 77 /**
78 * Sets focus on the first focusable element. Override for a custom focus 78 * Sets focus on the first focusable element. Override for a custom focus
79 * strategy. 79 * strategy.
80 */ 80 */
81 focus: function() { 81 focus: function() {
82 // Do not change focus if any control on this page is already focused. 82 cr.ui.setInitialFocus(this.pageDiv);
83 if (this.pageDiv.contains(document.activeElement))
84 return;
85
86 var elements = this.pageDiv.querySelectorAll(
87 'input, list, select, textarea, button');
88 for (var i = 0; i < elements.length; i++) {
89 var element = elements[i];
90 // Try to focus. If fails, then continue.
91 element.focus();
92 if (document.activeElement == element)
93 return;
94 }
95 }, 83 },
96 84
97 /** 85 /**
98 * Reverse any buttons strips in this page (only applies to overlays). 86 * Reverse any buttons strips in this page (only applies to overlays).
99 * @see cr.ui.reverseButtonStrips for an explanation of why this is 87 * @see cr.ui.reverseButtonStrips for an explanation of why this is
100 * necessary and when it's done. 88 * necessary and when it's done.
101 */ 89 */
102 reverseButtonStrip: function() { 90 reverseButtonStrip: function() {
103 assert(this.isOverlay); 91 assert(this.isOverlay);
104 cr.ui.reverseButtonStrips(this.pageDiv); 92 cr.ui.reverseButtonStrips(this.pageDiv);
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 PageManager.onPageVisibilityChanged(this); 298 PageManager.onPageVisibilityChanged(this);
311 } 299 }
312 }, 300 },
313 }; 301 };
314 302
315 // Export 303 // Export
316 return { 304 return {
317 Page: Page 305 Page: Page
318 }; 306 };
319 }); 307 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698