| OLD | NEW |
| 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 cr.define('extensions', function() { | 5 cr.define('extensions', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * The ExtensionOptionsOverlay will show an extension's options page using | 9 * The ExtensionOptionsOverlay will show an extension's options page using |
| 10 * an <extensionoptions> element. | 10 * an <extensionoptions> element. |
| 11 * @constructor | 11 * @constructor |
| 12 */ | 12 */ |
| 13 function ExtensionOptionsOverlay() {} | 13 function ExtensionOptionsOverlay() {} |
| 14 | 14 |
| 15 cr.addSingletonGetter(ExtensionOptionsOverlay); | 15 cr.addSingletonGetter(ExtensionOptionsOverlay); |
| 16 | 16 |
| 17 ExtensionOptionsOverlay.prototype = { | 17 ExtensionOptionsOverlay.prototype = { |
| 18 /** | 18 /** |
| 19 * The function that shows the given element in the overlay. | 19 * The function that shows the given element in the overlay. |
| 20 * @type {Function} | 20 * @type {?function(HTMLDivElement)} Function that receives the element to |
| 21 * @param {HTMLElement} The element to show in the overlay. | 21 * show in the overlay. |
| 22 * @private | 22 * @private |
| 23 */ | 23 */ |
| 24 showOverlay_: undefined, | 24 showOverlay_: null, |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * Initialize the page. | 27 * Initialize the page. |
| 28 * @param {function(HTMLDivElement)} showOverlay The function to show or | 28 * @param {function(HTMLDivElement)} showOverlay The function to show or |
| 29 * hide the ExtensionOptionsOverlay; this should take a single parameter | 29 * hide the ExtensionOptionsOverlay; this should take a single parameter |
| 30 * which is either the overlay Div if the overlay should be displayed, | 30 * which is either the overlay Div if the overlay should be displayed, |
| 31 * or null if the overlay should be hidden. | 31 * or null if the overlay should be hidden. |
| 32 */ | 32 */ |
| 33 initializePage: function(showOverlay) { | 33 initializePage: function(showOverlay) { |
| 34 var overlay = $('overlay'); | 34 var overlay = $('overlay'); |
| 35 | 35 |
| 36 cr.ui.overlay.setupOverlay(overlay); | 36 cr.ui.overlay.setupOverlay(overlay); |
| 37 cr.ui.overlay.globalInitialization(); | 37 cr.ui.overlay.globalInitialization(); |
| 38 overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this)); | 38 overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this)); |
| 39 | 39 |
| 40 this.showOverlay_ = showOverlay; | 40 this.showOverlay_ = showOverlay; |
| 41 }, | 41 }, |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * Handles a click on the close button. | 44 * Handles a click on the close button. |
| 45 * @param {Event} e The click event. | 45 * @param {Event} event The click event. |
| 46 * @private | 46 * @private |
| 47 */ | 47 */ |
| 48 handleDismiss_: function(event) { | 48 handleDismiss_: function(event) { |
| 49 this.setVisible_(false); | 49 this.setVisible_(false); |
| 50 var extensionoptions = document.querySelector('extensionoptions'); | 50 var extensionoptions = document.querySelector('extensionoptions'); |
| 51 if (extensionoptions) | 51 if (extensionoptions) |
| 52 $('extension-options-overlay').removeChild(extensionoptions); | 52 $('extension-options-overlay').removeChild(extensionoptions); |
| 53 }, | 53 }, |
| 54 | 54 |
| 55 /** | 55 /** |
| (...skipping 20 matching lines...) Expand all Loading... |
| 76 | 76 |
| 77 this.setVisible_(true); | 77 this.setVisible_(true); |
| 78 }, | 78 }, |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * Toggles the visibility of the ExtensionOptionsOverlay. | 81 * Toggles the visibility of the ExtensionOptionsOverlay. |
| 82 * @param {boolean} isVisible Whether the overlay should be visible. | 82 * @param {boolean} isVisible Whether the overlay should be visible. |
| 83 * @private | 83 * @private |
| 84 */ | 84 */ |
| 85 setVisible_: function(isVisible) { | 85 setVisible_: function(isVisible) { |
| 86 this.showOverlay_(isVisible ? $('extension-options-overlay') : null); | 86 this.showOverlay_(isVisible ? |
| 87 /** @type {HTMLDivElement} */($('extension-options-overlay')) : |
| 88 null); |
| 87 } | 89 } |
| 88 }; | 90 }; |
| 89 | 91 |
| 90 // Export | 92 // Export |
| 91 return { | 93 return { |
| 92 ExtensionOptionsOverlay: ExtensionOptionsOverlay | 94 ExtensionOptionsOverlay: ExtensionOptionsOverlay |
| 93 }; | 95 }; |
| 94 }); | 96 }); |
| OLD | NEW |