| 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 = | 50 var extensionoptions = |
| 51 $('extension-options-overlay-guest') | 51 $('extension-options-overlay-guest') |
| 52 .querySelector('extensionoptions'); | 52 .querySelector('extensionoptions'); |
| 53 | 53 |
| 54 if (extensionoptions) | 54 if (extensionoptions) |
| 55 $('extension-options-overlay-guest').removeChild(extensionoptions); | 55 $('extension-options-overlay-guest').removeChild(extensionoptions); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 $('extension-options-overlay-guest').appendChild(extensionoptions); | 144 $('extension-options-overlay-guest').appendChild(extensionoptions); |
| 145 }, | 145 }, |
| 146 | 146 |
| 147 /** | 147 /** |
| 148 * Toggles the visibility of the ExtensionOptionsOverlay. | 148 * Toggles the visibility of the ExtensionOptionsOverlay. |
| 149 * @param {boolean} isVisible Whether the overlay should be visible. | 149 * @param {boolean} isVisible Whether the overlay should be visible. |
| 150 * @private | 150 * @private |
| 151 */ | 151 */ |
| 152 setVisible_: function(isVisible) { | 152 setVisible_: function(isVisible) { |
| 153 this.showOverlay_(isVisible ? $('extension-options-overlay') : null); | 153 this.showOverlay_(isVisible ? |
| 154 /** @type {HTMLDivElement} */($('extension-options-overlay')) : |
| 155 null); |
| 154 } | 156 } |
| 155 }; | 157 }; |
| 156 | 158 |
| 157 // Export | 159 // Export |
| 158 return { | 160 return { |
| 159 ExtensionOptionsOverlay: ExtensionOptionsOverlay | 161 ExtensionOptionsOverlay: ExtensionOptionsOverlay |
| 160 }; | 162 }; |
| 161 }); | 163 }); |
| OLD | NEW |