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 <include src="../uber/uber_utils.js"> | 5 <include src="../uber/uber_utils.js"> |
| 6 <include src="extension_code.js"> | 6 <include src="extension_code.js"> |
| 7 <include src="extension_commands_overlay.js"> | 7 <include src="extension_commands_overlay.js"> |
| 8 <include src="extension_error_overlay.js"> | 8 <include src="extension_error_overlay.js"> |
| 9 <include src="extension_focus_manager.js"> | 9 <include src="extension_focus_manager.js"> |
| 10 <include src="extension_list.js"> | 10 <include src="extension_list.js"> |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 * Returns the current overlay or null if one does not exist. | 367 * Returns the current overlay or null if one does not exist. |
| 368 * @return {Element} The overlay element. | 368 * @return {Element} The overlay element. |
| 369 */ | 369 */ |
| 370 ExtensionSettings.getCurrentOverlay = function() { | 370 ExtensionSettings.getCurrentOverlay = function() { |
| 371 return document.querySelector('#overlay .page.showing'); | 371 return document.querySelector('#overlay .page.showing'); |
| 372 }; | 372 }; |
| 373 | 373 |
| 374 /** | 374 /** |
| 375 * Sets the given overlay to show. This hides whatever overlay is currently | 375 * Sets the given overlay to show. This hides whatever overlay is currently |
| 376 * showing, if any. | 376 * showing, if any. |
| 377 * @param {HTMLElement} node The overlay page to show. If falsey, all overlays | 377 * @param {HTMLElement} node The overlay page to show. If falsey, all overlays |
|
not at google - send to devlin
2015/02/06 21:31:38
You might as well fix this comment - |node| certai
Dan Beam
2015/02/06 21:50:02
Done.
| |
| 378 * are hidden. | 378 * are hidden. |
| 379 */ | 379 */ |
| 380 ExtensionSettings.showOverlay = function(node) { | 380 ExtensionSettings.showOverlay = function(node) { |
| 381 var pageDiv = $('extension-settings'); | 381 var pageDiv = $('extension-settings'); |
| 382 if (node) { | 382 pageDiv.style.width = node ? window.getComputedStyle(pageDiv).width : ''; |
| 383 pageDiv.style.width = window.getComputedStyle(pageDiv).width; | 383 document.body.classList.toggle('no-scroll', node); |
| 384 document.body.classList.add('no-scroll'); | |
| 385 } else { | |
| 386 document.body.classList.remove('no-scroll'); | |
| 387 pageDiv.style.width = ''; | |
| 388 } | |
| 389 | 384 |
| 390 var currentlyShowingOverlay = ExtensionSettings.getCurrentOverlay(); | 385 var currentlyShowingOverlay = ExtensionSettings.getCurrentOverlay(); |
| 391 if (currentlyShowingOverlay) { | 386 if (currentlyShowingOverlay) { |
| 392 currentlyShowingOverlay.classList.remove('showing'); | 387 currentlyShowingOverlay.classList.remove('showing'); |
| 393 cr.dispatchSimpleEvent($('overlay'), 'cancelOverlay'); | 388 cr.dispatchSimpleEvent($('overlay'), 'cancelOverlay'); |
| 394 } | 389 } |
| 395 | 390 |
| 396 if (node) { | 391 if (node) { |
| 397 if (document.activeElement != document.body) | 392 var lastFocused = document.activeElement; |
| 398 document.activeElement.blur(); | 393 $('overlay').addEventListener('cancelOverlay', function f() { |
| 394 lastFocused.focus(); | |
|
not at google - send to devlin
2015/02/06 21:31:38
Correct me if I'm wrong (in which case I'm trying
Dan Beam
2015/02/06 21:50:02
i know
| |
| 395 $('overlay').removeEventListener('cancelOverlay', f); | |
| 396 }); | |
| 399 node.classList.add('showing'); | 397 node.classList.add('showing'); |
| 400 } | 398 } |
| 401 | 399 |
| 402 var pages = document.querySelectorAll('.page'); | 400 var pages = document.querySelectorAll('.page'); |
| 403 for (var i = 0; i < pages.length; i++) { | 401 for (var i = 0; i < pages.length; i++) { |
| 404 pages[i].setAttribute('aria-hidden', node ? 'true' : 'false'); | 402 pages[i].setAttribute('aria-hidden', node ? 'true' : 'false'); |
| 405 } | 403 } |
| 406 | 404 |
| 407 $('overlay').hidden = !node; | 405 $('overlay').hidden = !node; |
| 406 | |
| 407 if (node) | |
| 408 ExtensionSettings.focusOverlay(); | |
| 409 | |
| 408 uber.invokeMethodOnParent(node ? 'beginInterceptingEvents' : | 410 uber.invokeMethodOnParent(node ? 'beginInterceptingEvents' : |
| 409 'stopInterceptingEvents'); | 411 'stopInterceptingEvents'); |
| 410 }; | 412 }; |
| 411 | 413 |
| 414 ExtensionSettings.focusOverlay = function() { | |
| 415 var currentlyShowingOverlay = ExtensionSettings.getCurrentOverlay(); | |
| 416 assert(currentlyShowingOverlay); | |
| 417 | |
| 418 if (cr.ui.FocusOutlineManager.forDocument(document).visible) { | |
| 419 var extraToFocus = '#extension-options-overlay-guest extensionoptions'; | |
| 420 cr.ui.setInitialFocus(currentlyShowingOverlay, extraToFocus); | |
| 421 } | |
| 422 | |
| 423 if (!currentlyShowingOverlay.contains(document.activeElement)) { | |
| 424 // Make sure focus isn't stuck behind the overlay. | |
| 425 document.activeElement.blur(); | |
| 426 } | |
| 427 }; | |
| 428 | |
| 412 /** | 429 /** |
| 413 * Utility function to find the width of various UI strings and synchronize | 430 * Utility function to find the width of various UI strings and synchronize |
| 414 * the width of relevant spans. This is crucial for making sure the | 431 * the width of relevant spans. This is crucial for making sure the |
| 415 * Enable/Enabled checkboxes align, as well as the Developer Mode checkbox. | 432 * Enable/Enabled checkboxes align, as well as the Developer Mode checkbox. |
| 416 */ | 433 */ |
| 417 function measureCheckboxStrings() { | 434 function measureCheckboxStrings() { |
| 418 var trashWidth = 30; | 435 var trashWidth = 30; |
| 419 var measuringDiv = $('font-measuring-div'); | 436 var measuringDiv = $('font-measuring-div'); |
| 420 measuringDiv.textContent = | 437 measuringDiv.textContent = |
| 421 loadTimeData.getString('extensionSettingsEnabled'); | 438 loadTimeData.getString('extensionSettingsEnabled'); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 444 | 461 |
| 445 // Export | 462 // Export |
| 446 return { | 463 return { |
| 447 ExtensionSettings: ExtensionSettings | 464 ExtensionSettings: ExtensionSettings |
| 448 }; | 465 }; |
| 449 }); | 466 }); |
| 450 | 467 |
| 451 window.addEventListener('load', function(e) { | 468 window.addEventListener('load', function(e) { |
| 452 extensions.ExtensionSettings.getInstance().initialize(); | 469 extensions.ExtensionSettings.getInstance().initialize(); |
| 453 }); | 470 }); |
| OLD | NEW |