Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(322)

Side by Side Diff: chrome/browser/resources/extensions/extension_options_overlay.js

Issue 488293003: Embedded Extension Options: Improve the overlay popup UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 var icon = $('extension-options-overlay-icon').querySelector('img');
55 if (icon)
56 $('extension-options-overlay-icon').removeChild(icon);
not at google - send to devlin 2014/08/22 22:31:00 Should we basically be removing #extension-options
ericzeng 2014/08/23 00:14:50 No, every overlay's nodes remain in the DOM (not j
53 }, 57 },
54 58
55 /** 59 /**
56 * Associate an extension with the overlay and display it. 60 * Associate an extension with the overlay and display it.
57 * @param {string} extensionId The id of the extension whose options page 61 * @param {string} extensionId The id of the extension whose options page
58 * should be displayed in the overlay. 62 * should be displayed in the overlay.
59 * @param {string} extensionName The name of the extension, which is used 63 * @param {string} extensionName The name of the extension, which is used
60 * as the header of the overlay. 64 * as the header of the overlay.
65 * @param {string} extensionIcon The URL of the extension's icon.
61 */ 66 */
62 setExtensionAndShowOverlay: function(extensionId, extensionName) { 67 setExtensionAndShowOverlay: function(extensionId,
68 extensionName,
69 extensionIcon) {
63 $('extension-options-overlay-title').textContent = extensionName; 70 $('extension-options-overlay-title').textContent = extensionName;
64 71
72 var icon = document.createElement('img');
73 icon.setAttribute('src', extensionIcon);
74 $('extension-options-overlay-icon').appendChild(icon);
not at google - send to devlin 2014/08/22 22:31:00 Why not always have the img in the DOM, then set t
ericzeng 2014/08/23 00:14:50 Done
75
76 this.setVisible_(true);
77
65 var extensionoptions = new ExtensionOptions(); 78 var extensionoptions = new ExtensionOptions();
66 extensionoptions.extension = extensionId; 79 extensionoptions.extension = extensionId;
67 extensionoptions.autosize = 'on'; 80 extensionoptions.autosize = 'on';
68 81
69 // The <extensionoptions> content's size needs to be restricted to the 82 // The <extensionoptions> content's size needs to be restricted to the
70 // bounds of the overlay window. The overlay gives a min width and 83 // bounds of the overlay window. The overlay gives a min width and
71 // max height, but the maxheight does not include our header height 84 // 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 85 // (title and close button), so we need to subtract that to get the
73 // max height for the extension options. 86 // max height for the extension options.
74 var headerHeight = $('extension-options-overlay-title').offsetHeight; 87 var headerHeight = $('extension-options-overlay-header').offsetHeight;
75 var overlayMaxHeight = 88 var overlayMaxHeight =
76 parseInt($('extension-options-overlay').style.maxHeight); 89 parseInt($('extension-options-overlay').style.maxHeight);
77 extensionoptions.maxheight = overlayMaxHeight - headerHeight; 90 extensionoptions.maxheight = overlayMaxHeight - headerHeight;
78 91
79 extensionoptions.minwidth = 92 extensionoptions.minwidth =
80 parseInt(window.getComputedStyle($('extension-options-overlay')) 93 parseInt(window.getComputedStyle($('extension-options-overlay'))
81 .minWidth); 94 .minWidth);
82 95
83 // Resize the overlay if the <extensionoptions> changes size. 96 // Resize the overlay if the <extensionoptions> changes size.
84 extensionoptions.onsizechanged = function(evt) { 97 extensionoptions.onsizechanged = function(evt) {
(...skipping 30 matching lines...) Expand all
115 // Don't allow the <extensionoptions> to autosize until the overlay 128 // Don't allow the <extensionoptions> to autosize until the overlay
116 // animation is complete. 129 // animation is complete.
117 extensionoptions.setDeferAutoSize(true); 130 extensionoptions.setDeferAutoSize(true);
118 131
119 // Move the <extensionoptions> off screen until the overlay is ready 132 // Move the <extensionoptions> off screen until the overlay is ready
120 $('extension-options-overlay-guest').style.position = 'fixed'; 133 $('extension-options-overlay-guest').style.position = 'fixed';
121 $('extension-options-overlay-guest').style.left = 134 $('extension-options-overlay-guest').style.left =
122 window.outerWidth + 'px'; 135 window.outerWidth + 'px';
123 136
124 $('extension-options-overlay-guest').appendChild(extensionoptions); 137 $('extension-options-overlay-guest').appendChild(extensionoptions);
125 this.setVisible_(true);
126 }, 138 },
127 139
128 /** 140 /**
129 * Toggles the visibility of the ExtensionOptionsOverlay. 141 * Toggles the visibility of the ExtensionOptionsOverlay.
130 * @param {boolean} isVisible Whether the overlay should be visible. 142 * @param {boolean} isVisible Whether the overlay should be visible.
131 * @private 143 * @private
132 */ 144 */
133 setVisible_: function(isVisible) { 145 setVisible_: function(isVisible) {
134 this.showOverlay_(isVisible ? $('extension-options-overlay') : null); 146 this.showOverlay_(isVisible ? $('extension-options-overlay') : null);
135 } 147 }
136 }; 148 };
137 149
138 // Export 150 // Export
139 return { 151 return {
140 ExtensionOptionsOverlay: ExtensionOptionsOverlay 152 ExtensionOptionsOverlay: ExtensionOptionsOverlay
141 }; 153 };
142 }); 154 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698