MDL-34590 javascript-static: nuclear option in openpopup

I think we have finally tamed Chrome on all platforms. (Crosses fingers.)
This commit is contained in:
Tim Hunt
2012-08-09 17:17:50 +02:00
committed by Eloy Lafuente (stronk7)
parent 072af5529b
commit 8cec008393
+22 -3
View File
@@ -1126,10 +1126,29 @@ function openpopup(event, args) {
}
if (args.fullscreen) {
setTimeout(function() {
// In some browser / OS combinations (E.g. Chrome on Windows), the
// window initially opens slighly too big. The width and heigh options
// seem to control the area inside the browser window, so what with
// scroll-bars, etc. the actual window is bigger than the screen.
// Therefore, we need to fix things up after the window is open.
var hackcount = 100;
var get_size_exactly_right = function() {
windowobj.moveTo(0, 0);
windowobj.resizeTo(screen.availWidth, screen.availHeight)
}, 0);
windowobj.resizeTo(screen.availWidth, screen.availHeight);
// Unfortunately, it seems that in Chrome on Ubuntu, if you call
// something like windowobj.resizeTo(1280, 1024) too soon (up to
// about 50ms) after the window is open, then it actually behaves
// as if you called windowobj.resizeTo(0, 0). Therefore, we need to
// check that the resize actually worked, and if not, repeatedly try
// again after a short delay until it works (but with a limit of
// hackcount repeats.
if (hackcount > 0 && (windowobj.innerHeight < 10 || windowobj.innerWidth < 10)) {
hackcount -= 1;
setTimeout(get_size_exactly_right, 10);
}
}
setTimeout(get_size_exactly_right, 0);
}
windowobj.focus();