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

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

Issue 480243003: Implement smoother autosizing of the extension options overlay (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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 * @param {string} extensionId The id of the extension whose options page 57 * @param {string} extensionId The id of the extension whose options page
58 * should be displayed in the overlay. 58 * should be displayed in the overlay.
59 * @param {string} extensionName The name of the extension, which is used 59 * @param {string} extensionName The name of the extension, which is used
60 * as the header of the overlay. 60 * as the header of the overlay.
61 */ 61 */
62 setExtensionAndShowOverlay: function(extensionId, extensionName) { 62 setExtensionAndShowOverlay: function(extensionId, extensionName) {
63 var extensionoptions = new ExtensionOptions(); 63 var extensionoptions = new ExtensionOptions();
64 extensionoptions.extension = extensionId; 64 extensionoptions.extension = extensionId;
65 extensionoptions.autosize = 'on'; 65 extensionoptions.autosize = 'on';
66 66
67 // TODO(ericzeng): Resize in a non-jarring way. 67 // maxheight is the overlay window's max height minus the header's height
not at google - send to devlin 2014/08/19 17:02:48 Nit: end comment in a period. If it fits on 80 cha
ericzeng 2014/08/19 18:20:12 Done.
68 extensionoptions.maxheight =
69 parseInt($('extension-options-overlay').style.maxHeight) - 42;
not at google - send to devlin 2014/08/19 17:02:48 42...?
ericzeng 2014/08/19 18:20:12 Fixed
70 extensionoptions.minwidth = 400;
not at google - send to devlin 2014/08/19 17:02:48 400...?
ericzeng 2014/08/19 18:20:12 Fixed
71
68 extensionoptions.onsizechanged = function(evt) { 72 extensionoptions.onsizechanged = function(evt) {
69 $('extension-options-overlay').style.width = evt.width; 73 var animationTime = 0.25 * Math.sqrt(
not at google - send to devlin 2014/08/19 17:02:48 Maybe you want to explain this formula :)
ericzeng 2014/08/19 18:20:12 Done.
70 $('extension-options-overlay').style.height = evt.height; 74 Math.pow(evt.newWidth - evt.oldWidth, 2) +
75 Math.pow(evt.newHeight - evt.oldHeight, 2));
76
77 $('extension-options-overlay').animate([
78 {width: evt.oldWidth + 'px', height: evt.oldHeight + 'px'},
79 {width: evt.newWidth + 'px', height: evt.newHeight + 'px'}
80 ], {
81 duration: animationTime,
82 delay: 0
83 });
71 }.bind(this); 84 }.bind(this);
72 85
73 $('extension-options-overlay').appendChild(extensionoptions); 86 $('extension-options-overlay').appendChild(extensionoptions);
74
75 $('extension-options-overlay-title').textContent = extensionName; 87 $('extension-options-overlay-title').textContent = extensionName;
76 88
77 this.setVisible_(true); 89 this.setVisible_(true);
78 }, 90 },
79 91
80 /** 92 /**
81 * Toggles the visibility of the ExtensionOptionsOverlay. 93 * Toggles the visibility of the ExtensionOptionsOverlay.
82 * @param {boolean} isVisible Whether the overlay should be visible. 94 * @param {boolean} isVisible Whether the overlay should be visible.
83 * @private 95 * @private
84 */ 96 */
85 setVisible_: function(isVisible) { 97 setVisible_: function(isVisible) {
86 this.showOverlay_(isVisible ? $('extension-options-overlay') : null); 98 this.showOverlay_(isVisible ? $('extension-options-overlay') : null);
87 } 99 }
88 }; 100 };
89 101
90 // Export 102 // Export
91 return { 103 return {
92 ExtensionOptionsOverlay: ExtensionOptionsOverlay 104 ExtensionOptionsOverlay: ExtensionOptionsOverlay
93 }; 105 };
94 }); 106 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698