]> git.mjollnir.org Git - moodle.git/commitdiff
Better resizing under all browsers (more accurate)
authorstronk7 <stronk7>
Sun, 2 Sep 2007 23:07:27 +0000 (23:07 +0000)
committerstronk7 <stronk7>
Sun, 2 Sep 2007 23:07:27 +0000 (23:07 +0000)
mod/resource/type/ims/resize.js

index 93913ad26a9b07215b0d0b422e225625b5ee7bb1..b05a768cb1267a1cdf036946eea035e2349dd2b0 100644 (file)
@@ -54,27 +54,27 @@ function resizeiframe (hasNav, customCorners) {
     if (imsnavbar) {
         imsnavHeight = imsnavbar.offsetHeight;
     }
-    
+
     var topMargin = parseInt(getElementStyle(document.getElementsByTagName('body')[0], 'marginTop', 'margin-top'));
     var bottomMargin = parseInt(getElementStyle(document.getElementsByTagName('body')[0], 'marginBottom', 'margin-bottom'));
-    
-    var totalHeight = headerHeight + 
-                        footerHeight + 
-                        imsnavHeight +
-                        topMargin +
-                        bottomMargin + 20; // +20 to save a minor vertical scroll always present!
-                        
-    
+    var leftMargin = parseInt(getElementStyle(document.getElementsByTagName('body')[0], 'marginLeft', 'margin-left'));
+    var rightMargin = parseInt(getElementStyle(document.getElementsByTagName('body')[0], 'marginRight', 'margin-right'));
+
+    var totalHeight = headerHeight +
+                      footerHeight +
+                      imsnavHeight +
+                      topMargin +
+                      bottomMargin;
 
     if (hasNav == true) {
         var navBarWidth = document.getElementById('ims-menudiv').offsetWidth;
-        var iframeWidth = (winWidth - navBarWidth - 30)+'px';
+        var iframeWidth = (winWidth - navBarWidth - leftMargin - rightMargin - 4)+'px'; // -4 for two divs borders I hope
         document.getElementById('ims-menudiv').style.height = (winHeight - totalHeight)+'px';
     }
     else {
-        var iframeWidth = (winWidth - 30)+'px';
+        var iframeWidth = (winWidth - leftMargin - rightMargin - 2)+'px'; // -2 for one div borders I hope
     }
-    
+
     if (hasNav == true) {
         document.getElementById('ims-contentframe').style.height = (winHeight - totalHeight)+'px';
         document.getElementById('ims-contentframe').style.width = iframeWidth;