Chromium Code Reviews| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 * Shows a registered Overlay page. Does not update history. | 227 * Shows a registered Overlay page. Does not update history. |
| 228 * @param {string} overlayName Page name. | 228 * @param {string} overlayName Page name. |
| 229 * @param {OptionPage} rootPage The currently visible root-level page. | 229 * @param {OptionPage} rootPage The currently visible root-level page. |
| 230 * @return {boolean} whether we showed an overlay. | 230 * @return {boolean} whether we showed an overlay. |
| 231 */ | 231 */ |
| 232 OptionsPage.showOverlay_ = function(overlayName, rootPage) { | 232 OptionsPage.showOverlay_ = function(overlayName, rootPage) { |
| 233 var overlay = this.registeredOverlayPages[overlayName.toLowerCase()]; | 233 var overlay = this.registeredOverlayPages[overlayName.toLowerCase()]; |
| 234 if (!overlay || !overlay.canShowPage()) | 234 if (!overlay || !overlay.canShowPage()) |
| 235 return false; | 235 return false; |
| 236 | 236 |
| 237 // The current topmost page will soon be obscured behind the new overlay | |
| 238 // to be shown. To prevent screen readers from reading this "hidden" | |
| 239 // information, enable the aria-hidden attribute on this page. | |
| 240 var topmostPage = this.getTopmostVisiblePage(); | |
|
Evan Stade
2012/05/09 22:37:37
seems like this might do the wrong thing in certai
Kyle Horimoto
2012/05/10 22:18:46
Done.
| |
| 241 topmostPage.pageDiv.setAttribute('aria-hidden', true); | |
| 242 | |
| 237 if ((!rootPage || !rootPage.sticky) && overlay.parentPage) | 243 if ((!rootPage || !rootPage.sticky) && overlay.parentPage) |
| 238 this.showPageByName(overlay.parentPage.name, false); | 244 this.showPageByName(overlay.parentPage.name, false); |
| 239 | 245 |
| 240 if (!overlay.visible) { | 246 if (!overlay.visible) { |
| 241 overlay.visible = true; | 247 overlay.visible = true; |
| 242 if (overlay.didShowPage) overlay.didShowPage(); | 248 if (overlay.didShowPage) overlay.didShowPage(); |
| 243 } | 249 } |
| 244 | 250 |
| 245 // Update tab title. | 251 // Update tab title. |
| 246 this.setTitle_(overlay.title); | 252 this.setTitle_(overlay.title); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 */ | 285 */ |
| 280 OptionsPage.closeOverlay = function() { | 286 OptionsPage.closeOverlay = function() { |
| 281 var overlay = this.getVisibleOverlay_(); | 287 var overlay = this.getVisibleOverlay_(); |
| 282 if (!overlay) | 288 if (!overlay) |
| 283 return; | 289 return; |
| 284 | 290 |
| 285 overlay.visible = false; | 291 overlay.visible = false; |
| 286 | 292 |
| 287 if (overlay.didClosePage) overlay.didClosePage(); | 293 if (overlay.didClosePage) overlay.didClosePage(); |
| 288 this.updateHistoryState_(false, {ignoreHash: true}); | 294 this.updateHistoryState_(false, {ignoreHash: true}); |
| 295 | |
| 296 // Since there is now a new topmost page, disable its aria-hidden attribute | |
| 297 // to allow screen readers to read its contents. | |
| 298 var topmostPage = this.getTopmostVisiblePage(); | |
| 299 topmostPage.pageDiv.removeAttribute('aria-hidden'); | |
| 289 }; | 300 }; |
| 290 | 301 |
| 291 /** | 302 /** |
| 292 * Cancels (closes) the overlay, due to the user pressing <Esc>. | 303 * Cancels (closes) the overlay, due to the user pressing <Esc>. |
| 293 */ | 304 */ |
| 294 OptionsPage.cancelOverlay = function() { | 305 OptionsPage.cancelOverlay = function() { |
| 295 // Blur the active element to ensure any changed pref value is saved. | 306 // Blur the active element to ensure any changed pref value is saved. |
| 296 document.activeElement.blur(); | 307 document.activeElement.blur(); |
| 297 var overlay = this.getVisibleOverlay_(); | 308 var overlay = this.getVisibleOverlay_(); |
| 298 // Let the overlay handle the <Esc> if it wants to. | 309 // Let the overlay handle the <Esc> if it wants to. |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 856 canShowPage: function() { | 867 canShowPage: function() { |
| 857 return true; | 868 return true; |
| 858 }, | 869 }, |
| 859 }; | 870 }; |
| 860 | 871 |
| 861 // Export | 872 // Export |
| 862 return { | 873 return { |
| 863 OptionsPage: OptionsPage | 874 OptionsPage: OptionsPage |
| 864 }; | 875 }; |
| 865 }); | 876 }); |
| OLD | NEW |