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="../../../../ui/webui/resources/js/cr/ui/focus_row.js"> | 5 <include src="../../../../ui/webui/resources/js/cr/ui/focus_row.js"> |
6 <include src="../../../../ui/webui/resources/js/cr/ui/focus_grid.js"> | 6 <include src="../../../../ui/webui/resources/js/cr/ui/focus_grid.js"> |
7 <include src="../uber/uber_utils.js"> | 7 <include src="../uber/uber_utils.js"> |
8 <include src="extension_code.js"> | 8 <include src="extension_code.js"> |
9 <include src="extension_commands_overlay.js"> | 9 <include src="extension_commands_overlay.js"> |
10 <include src="extension_error_overlay.js"> | 10 <include src="extension_error_overlay.js"> |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 345 |
346 /** | 346 /** |
347 * Returns the current overlay or null if one does not exist. | 347 * Returns the current overlay or null if one does not exist. |
348 * @return {Element} The overlay element. | 348 * @return {Element} The overlay element. |
349 */ | 349 */ |
350 ExtensionSettings.getCurrentOverlay = function() { | 350 ExtensionSettings.getCurrentOverlay = function() { |
351 return document.querySelector('#overlay .page.showing'); | 351 return document.querySelector('#overlay .page.showing'); |
352 }; | 352 }; |
353 | 353 |
354 /** | 354 /** |
355 * Sets the given overlay to show. This hides whatever overlay is currently | 355 * Sets the given overlay to show. If the overlay is already showing, this is |
356 * showing, if any. | 356 * a no-op; otherwise, hides any currently-showing overlay. |
357 * @param {HTMLElement} node The overlay page to show. If null, all overlays | 357 * @param {HTMLElement} node The overlay page to show. If null, all overlays |
358 * are hidden. | 358 * are hidden. |
359 */ | 359 */ |
360 ExtensionSettings.showOverlay = function(node) { | 360 ExtensionSettings.showOverlay = function(node) { |
361 var pageDiv = $('extension-settings'); | 361 var pageDiv = $('extension-settings'); |
362 pageDiv.style.width = node ? window.getComputedStyle(pageDiv).width : ''; | 362 pageDiv.style.width = node ? window.getComputedStyle(pageDiv).width : ''; |
363 document.body.classList.toggle('no-scroll', !!node); | 363 document.body.classList.toggle('no-scroll', !!node); |
364 | 364 |
365 var currentlyShowingOverlay = ExtensionSettings.getCurrentOverlay(); | 365 var currentlyShowingOverlay = ExtensionSettings.getCurrentOverlay(); |
366 if (currentlyShowingOverlay) { | 366 if (currentlyShowingOverlay) { |
| 367 if (currentlyShowingOverlay == node) // Already displayed. |
| 368 return; |
367 currentlyShowingOverlay.classList.remove('showing'); | 369 currentlyShowingOverlay.classList.remove('showing'); |
368 cr.dispatchSimpleEvent($('overlay'), 'cancelOverlay'); | 370 cr.dispatchSimpleEvent($('overlay'), 'cancelOverlay'); |
369 } | 371 } |
370 | 372 |
371 if (node) { | 373 if (node) { |
372 var lastFocused = document.activeElement; | 374 var lastFocused = document.activeElement; |
373 $('overlay').addEventListener('cancelOverlay', function f() { | 375 $('overlay').addEventListener('cancelOverlay', function f() { |
374 lastFocused.focus(); | 376 lastFocused.focus(); |
375 $('overlay').removeEventListener('cancelOverlay', f); | 377 $('overlay').removeEventListener('cancelOverlay', f); |
376 }); | 378 }); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 | 441 |
440 // Export | 442 // Export |
441 return { | 443 return { |
442 ExtensionSettings: ExtensionSettings | 444 ExtensionSettings: ExtensionSettings |
443 }; | 445 }; |
444 }); | 446 }); |
445 | 447 |
446 window.addEventListener('load', function(e) { | 448 window.addEventListener('load', function(e) { |
447 extensions.ExtensionSettings.getInstance().initialize(); | 449 extensions.ExtensionSettings.getInstance().initialize(); |
448 }); | 450 }); |
OLD | NEW |