OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 ///////////////////////////////////////////////////////////////////////////// | 6 ///////////////////////////////////////////////////////////////////////////// |
7 // OptionsPage class: | 7 // OptionsPage class: |
8 | 8 |
9 /** | 9 /** |
10 * Base class for options page. | 10 * Base class for options page. |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 | 244 |
245 if (!overlay.visible) { | 245 if (!overlay.visible) { |
246 overlay.visible = true; | 246 overlay.visible = true; |
247 if (overlay.didShowPage) overlay.didShowPage(); | 247 if (overlay.didShowPage) overlay.didShowPage(); |
248 } | 248 } |
249 | 249 |
250 // Update tab title. | 250 // Update tab title. |
251 this.setTitle_(overlay.title); | 251 this.setTitle_(overlay.title); |
252 // Try to focus the first element of the new overlay. | 252 // Try to focus the first element of the new overlay. |
253 options.FocusManager.getInstance().focusFirstElement(); | 253 options.FocusManager.getInstance().focusFirstElement(); |
254 // Although FocusManager will correct erroneous focus in the settings frame, | |
255 // it only runs in that <iframe>, so it cannot ensure proper focus in the | |
256 // Uber frame where the navigation items reside. Thus, disable the ability | |
257 // for those items to be focused to prevent them from receiving focus in a | |
258 // page "behind" the overlay. | |
259 uber.invokeMethodOnParent('disableNavigationItemTabbing'); | |
Evan Stade
2012/05/08 23:23:00
this shouldn't be necessary. Just piggy back on be
Kyle Horimoto
2012/05/08 23:44:18
Done.
| |
254 | 260 |
255 return true; | 261 return true; |
256 }; | 262 }; |
257 | 263 |
258 /** | 264 /** |
259 * Returns whether or not an overlay is visible. | 265 * Returns whether or not an overlay is visible. |
260 * @return {boolean} True if an overlay is visible. | 266 * @return {boolean} True if an overlay is visible. |
261 * @private | 267 * @private |
262 */ | 268 */ |
263 OptionsPage.isOverlayVisible_ = function() { | 269 OptionsPage.isOverlayVisible_ = function() { |
(...skipping 28 matching lines...) Expand all Loading... | |
292 overlay.visible = false; | 298 overlay.visible = false; |
293 | 299 |
294 if (overlay.didClosePage) overlay.didClosePage(); | 300 if (overlay.didClosePage) overlay.didClosePage(); |
295 this.updateHistoryState_(false, {ignoreHash: true}); | 301 this.updateHistoryState_(false, {ignoreHash: true}); |
296 | 302 |
297 // Another page or overlay will now be displayed. If it previously had a | 303 // Another page or overlay will now be displayed. If it previously had a |
298 // focused element, restore this element's focus. | 304 // focused element, restore this element's focus. |
299 var currentPage = this.getTopmostVisiblePage(); | 305 var currentPage = this.getTopmostVisiblePage(); |
300 if (currentPage.lastFocusedElement) | 306 if (currentPage.lastFocusedElement) |
301 currentPage.lastFocusedElement.focus(); | 307 currentPage.lastFocusedElement.focus(); |
308 | |
309 // If the last overlay has just been closed, there is no longer an overlay | |
310 // to block the navigation elements, so allow them to receive focus. | |
311 if (!this.isOverlayVisible_()) | |
312 uber.invokeMethodOnParent('enableNavigationItemTabbing'); | |
302 }; | 313 }; |
303 | 314 |
304 /** | 315 /** |
305 * Cancels (closes) the overlay, due to the user pressing <Esc>. | 316 * Cancels (closes) the overlay, due to the user pressing <Esc>. |
306 */ | 317 */ |
307 OptionsPage.cancelOverlay = function() { | 318 OptionsPage.cancelOverlay = function() { |
308 // Blur the active element to ensure any changed pref value is saved. | 319 // Blur the active element to ensure any changed pref value is saved. |
309 document.activeElement.blur(); | 320 document.activeElement.blur(); |
310 var overlay = this.getVisibleOverlay_(); | 321 var overlay = this.getVisibleOverlay_(); |
311 // Let the overlay handle the <Esc> if it wants to. | 322 // Let the overlay handle the <Esc> if it wants to. |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
869 canShowPage: function() { | 880 canShowPage: function() { |
870 return true; | 881 return true; |
871 }, | 882 }, |
872 }; | 883 }; |
873 | 884 |
874 // Export | 885 // Export |
875 return { | 886 return { |
876 OptionsPage: OptionsPage | 887 OptionsPage: OptionsPage |
877 }; | 888 }; |
878 }); | 889 }); |
OLD | NEW |