| Index: chrome/browser/resources/extensions/extension_options_overlay.js
|
| diff --git a/chrome/browser/resources/extensions/extension_options_overlay.js b/chrome/browser/resources/extensions/extension_options_overlay.js
|
| index db03e08ce7f1e3af02e873b8dfba1ebb092c72db..08949bbf609446205b6e01b9c25819c16e104ddd 100644
|
| --- a/chrome/browser/resources/extensions/extension_options_overlay.js
|
| +++ b/chrome/browser/resources/extensions/extension_options_overlay.js
|
| @@ -63,24 +63,74 @@ cr.define('extensions', function() {
|
| * as the header of the overlay.
|
| */
|
| setExtensionAndShowOverlay: function(extensionId, extensionName) {
|
| + $('extension-options-overlay-title').textContent = extensionName;
|
| +
|
| var extensionoptions = new ExtensionOptions();
|
| extensionoptions.extension = extensionId;
|
| extensionoptions.autosize = 'on';
|
|
|
| + // The <extensionoptions> content's size needs to be restricted to the
|
| + // bounds of the overlay window. The overlay gives a min width and
|
| + // max height, but the maxheight does not include our header height
|
| + // (title and close button), so we need to subtract that to get the
|
| + // max height for the extension options.
|
| + var headerHeight = $('extension-options-overlay-title').offsetHeight;
|
| + var overlayMaxHeight =
|
| + parseInt($('extension-options-overlay').style.maxHeight);
|
| + extensionoptions.maxheight = overlayMaxHeight - headerHeight;
|
| +
|
| + extensionoptions.minwidth =
|
| + parseInt(window.getComputedStyle($('extension-options-overlay'))
|
| + .minWidth);
|
| +
|
| + extensionoptions.setDeferAutoSize(true);
|
| +
|
| extensionoptions.onclose = function() {
|
| this.handleDismiss_();
|
| }.bind(this);
|
|
|
| - // TODO(ericzeng): Resize in a non-jarring way.
|
| + // Resize the overlay if the <extensionoptions> changes size.
|
| extensionoptions.onsizechanged = function(evt) {
|
| - $('extension-options-overlay').style.width = evt.width;
|
| - $('extension-options-overlay').style.height = evt.height;
|
| + var overlayStyle =
|
| + window.getComputedStyle($('extension-options-overlay'));
|
| + var oldWidth = parseInt(overlayStyle.width);
|
| + var oldHeight = parseInt(overlayStyle.height);
|
| +
|
| + // animationTime is the amount of time in ms that will be used to resize
|
| + // the overlay. It is calculated by multiplying the pythagorean distance
|
| + // between old and the new size (in px) with a constant speed of
|
| + // 0.25 ms/px.
|
| + var animationTime = 0.25 * Math.sqrt(
|
| + Math.pow(evt.newWidth - oldWidth, 2) +
|
| + Math.pow(evt.newHeight - oldHeight, 2));
|
| +
|
| + var player = $('extension-options-overlay').animate([
|
| + {width: oldWidth + 'px', height: oldHeight + 'px'},
|
| + {width: evt.newWidth + 'px', height: evt.newHeight + 'px'}
|
| + ], {
|
| + duration: animationTime,
|
| + delay: 0
|
| + });
|
| +
|
| + player.onfinish = function(e) {
|
| + // Allow the <extensionoptions> to autosize now that the overlay
|
| + // has resized, and move it back on-screen.
|
| + extensionoptions.resumeDeferredAutoSize();
|
| + $('extension-options-overlay-guest').style.position = 'static';
|
| + $('extension-options-overlay-guest').style.left = 'auto';
|
| + };
|
| }.bind(this);
|
|
|
| - $('extension-options-overlay-guest').appendChild(extensionoptions);
|
| + // Don't allow the <extensionoptions> to autosize until the overlay
|
| + // animation is complete.
|
| + extensionoptions.setDeferAutoSize(true);
|
|
|
| - $('extension-options-overlay-title').textContent = extensionName;
|
| + // Move the <extensionoptions> off screen until the overlay is ready
|
| + $('extension-options-overlay-guest').style.position = 'fixed';
|
| + $('extension-options-overlay-guest').style.left =
|
| + window.outerWidth + 'px';
|
|
|
| + $('extension-options-overlay-guest').appendChild(extensionoptions);
|
| this.setVisible_(true);
|
| },
|
|
|
|
|