From 8c598cef1879f4bc1172caa3c8566e16c2c5ca4f Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Fri, 27 Jul 2012 13:19:17 +0100 Subject: [PATCH] MDL-34590 javascript-static: full-screep popups for Chrome. I have left in both: 1. the code to get the window size correct initially, becuase that seems sensible; and 2. the subsequent resize (with the setTimeout that Chrome requires, thanks Jeff Rader for finding that) becuase on Chrome, it gets the size a bit too big initially, so this correction is necessary. --- lib/javascript-static.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/javascript-static.js b/lib/javascript-static.js index 463f8249616..f8027763d53 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -1182,13 +1182,23 @@ function openpopup(event, args) { if (!args.url.match(/https?:\/\//)) { fullurl = M.cfg.wwwroot + args.url; } + if (args.fullscreen) { + args.options = args.options. + replace(/top=\d+/, 'top=0'). + replace(/left=\d+/, 'left=0'). + replace(/width=\d+/, 'width=' + screen.availWidth). + replace(/height=\d+/, 'height=' + screen.availHeight); + } var windowobj = window.open(fullurl,args.name,args.options); if (!windowobj) { return true; } + if (args.fullscreen) { - windowobj.moveTo(0,0); - windowobj.resizeTo(screen.availWidth,screen.availHeight); + setTimeout(function() { + windowobj.moveTo(0, 0); + windowobj.resizeTo(screen.availWidth, screen.availHeight) + }, 0); } windowobj.focus();