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

Unified Diff: remoting/webapp/base/js/base.js

Issue 1081813007: Make loading dialog prettier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer feedback. Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/webapp/base/html/message_window.css ('k') | remoting/webapp/base/js/message_window.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/base/js/base.js
diff --git a/remoting/webapp/base/js/base.js b/remoting/webapp/base/js/base.js
index 3be8c8fb6db7fcb958d6dc78c78637408e23a32b..48e2a84461a14c1b58e7bf7f3a84de1b23bdb41a 100644
--- a/remoting/webapp/base/js/base.js
+++ b/remoting/webapp/base/js/base.js
@@ -783,14 +783,27 @@ base.timestamp = function() {
};
/**
- * Size the current window to fit its content vertically.
+ * Size the current window to fit its content.
+ * @param {boolean=} opt_centerWindow If true, position the window in the
+ * center of the screen after resizing it.
*/
-base.resizeWindowToContent = function() {
+base.resizeWindowToContent = function(opt_centerWindow) {
var appWindow = chrome.app.window.current();
var outerBounds = appWindow.outerBounds;
+ var borderX = outerBounds.width - appWindow.innerBounds.width;
var borderY = outerBounds.height - appWindow.innerBounds.height;
- appWindow.resizeTo(outerBounds.width, document.body.clientHeight + borderY);
+ var newWidth = document.documentElement.scrollWidth + borderX;
+ var newHeight = document.documentElement.scrollHeight + borderY;
+ appWindow.resizeTo(newWidth, newHeight);
+ var left = outerBounds.left;
+ var top = outerBounds.top;
+ if (opt_centerWindow) {
+ var screenWidth = screen.availWidth;
+ var screenHeight = screen.availHeight;
+ left = (screenWidth - newWidth) / 2;
+ top = (screenHeight - newHeight) / 2;
+ }
// Sometimes, resizing the window causes its position to be reset to (0, 0),
- // so restore it explicitly.
- appWindow.moveTo(outerBounds.left, outerBounds.top);
+ // so restore it explicitly, even if it doesn't need to be centered.
+ appWindow.moveTo(left, top);
};
« no previous file with comments | « remoting/webapp/base/html/message_window.css ('k') | remoting/webapp/base/js/message_window.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698