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. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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} e 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-guest').removeChild(extensionoptions); | 52 $('extension-options-overlay-guest').removeChild(extensionoptions); |
53 | |
54 $('extension-options-overlay-icon').removeAttribute('src'); | |
53 }, | 55 }, |
54 | 56 |
55 /** | 57 /** |
56 * Associate an extension with the overlay and display it. | 58 * Associate an extension with the overlay and display it. |
57 * @param {string} extensionId The id of the extension whose options page | 59 * @param {string} extensionId The id of the extension whose options page |
58 * should be displayed in the overlay. | 60 * should be displayed in the overlay. |
59 * @param {string} extensionName The name of the extension, which is used | 61 * @param {string} extensionName The name of the extension, which is used |
60 * as the header of the overlay. | 62 * as the header of the overlay. |
63 * @param {string} extensionIcon The URL of the extension's icon. | |
61 */ | 64 */ |
62 setExtensionAndShowOverlay: function(extensionId, extensionName) { | 65 setExtensionAndShowOverlay: function(extensionId, |
66 extensionName, | |
67 extensionIcon) { | |
63 $('extension-options-overlay-title').textContent = extensionName; | 68 $('extension-options-overlay-title').textContent = extensionName; |
69 $('extension-options-overlay-icon').src = extensionIcon; | |
not at google - send to devlin
2014/08/23 00:24:16
Should this be .setAttribute('src')? Even if .src
| |
70 | |
71 this.setVisible_(true); | |
64 | 72 |
65 var extensionoptions = new ExtensionOptions(); | 73 var extensionoptions = new ExtensionOptions(); |
66 extensionoptions.extension = extensionId; | 74 extensionoptions.extension = extensionId; |
67 extensionoptions.autosize = 'on'; | 75 extensionoptions.autosize = 'on'; |
68 | 76 |
69 // The <extensionoptions> content's size needs to be restricted to the | 77 // The <extensionoptions> content's size needs to be restricted to the |
70 // bounds of the overlay window. The overlay gives a min width and | 78 // bounds of the overlay window. The overlay gives a min width and |
71 // max height, but the maxheight does not include our header height | 79 // max height, but the maxheight does not include our header height |
72 // (title and close button), so we need to subtract that to get the | 80 // (title and close button), so we need to subtract that to get the |
73 // max height for the extension options. | 81 // max height for the extension options. |
74 var headerHeight = $('extension-options-overlay-title').offsetHeight; | 82 var headerHeight = $('extension-options-overlay-header').offsetHeight; |
75 var overlayMaxHeight = | 83 var overlayMaxHeight = |
76 parseInt($('extension-options-overlay').style.maxHeight); | 84 parseInt($('extension-options-overlay').style.maxHeight); |
77 extensionoptions.maxheight = overlayMaxHeight - headerHeight; | 85 extensionoptions.maxheight = overlayMaxHeight - headerHeight; |
78 | 86 |
79 extensionoptions.minwidth = | 87 extensionoptions.minwidth = |
80 parseInt(window.getComputedStyle($('extension-options-overlay')) | 88 parseInt(window.getComputedStyle($('extension-options-overlay')) |
81 .minWidth); | 89 .minWidth); |
82 | 90 |
83 // Resize the overlay if the <extensionoptions> changes size. | 91 // Resize the overlay if the <extensionoptions> changes size. |
84 extensionoptions.onsizechanged = function(evt) { | 92 extensionoptions.onsizechanged = function(evt) { |
(...skipping 30 matching lines...) Expand all Loading... | |
115 // Don't allow the <extensionoptions> to autosize until the overlay | 123 // Don't allow the <extensionoptions> to autosize until the overlay |
116 // animation is complete. | 124 // animation is complete. |
117 extensionoptions.setDeferAutoSize(true); | 125 extensionoptions.setDeferAutoSize(true); |
118 | 126 |
119 // Move the <extensionoptions> off screen until the overlay is ready | 127 // Move the <extensionoptions> off screen until the overlay is ready |
120 $('extension-options-overlay-guest').style.position = 'fixed'; | 128 $('extension-options-overlay-guest').style.position = 'fixed'; |
121 $('extension-options-overlay-guest').style.left = | 129 $('extension-options-overlay-guest').style.left = |
122 window.outerWidth + 'px'; | 130 window.outerWidth + 'px'; |
123 | 131 |
124 $('extension-options-overlay-guest').appendChild(extensionoptions); | 132 $('extension-options-overlay-guest').appendChild(extensionoptions); |
125 this.setVisible_(true); | |
126 }, | 133 }, |
127 | 134 |
128 /** | 135 /** |
129 * Toggles the visibility of the ExtensionOptionsOverlay. | 136 * Toggles the visibility of the ExtensionOptionsOverlay. |
130 * @param {boolean} isVisible Whether the overlay should be visible. | 137 * @param {boolean} isVisible Whether the overlay should be visible. |
131 * @private | 138 * @private |
132 */ | 139 */ |
133 setVisible_: function(isVisible) { | 140 setVisible_: function(isVisible) { |
134 this.showOverlay_(isVisible ? $('extension-options-overlay') : null); | 141 this.showOverlay_(isVisible ? $('extension-options-overlay') : null); |
135 } | 142 } |
136 }; | 143 }; |
137 | 144 |
138 // Export | 145 // Export |
139 return { | 146 return { |
140 ExtensionOptionsOverlay: ExtensionOptionsOverlay | 147 ExtensionOptionsOverlay: ExtensionOptionsOverlay |
141 }; | 148 }; |
142 }); | 149 }); |
OLD | NEW |