[Mapbender-commits] r6662 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Jul 30 05:36:04 EDT 2010


Author: christoph
Date: 2010-07-30 09:36:03 +0000 (Fri, 30 Jul 2010)
New Revision: 6662

Modified:
   trunk/mapbender/http/javascripts/mod_resize_mapsize.js
Log:
using jQuery getWidth and getHeight

bugfix in rebuild: problem with scrollbars

Modified: trunk/mapbender/http/javascripts/mod_resize_mapsize.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_resize_mapsize.js	2010-07-30 09:35:08 UTC (rev 6661)
+++ trunk/mapbender/http/javascripts/mod_resize_mapsize.js	2010-07-30 09:36:03 UTC (rev 6662)
@@ -67,12 +67,12 @@
 }
 var resize_option = options.resize_option;
 
-if (!options.adjust_width) {
+if (typeof options.adjust_width == "undefined") {
 	options.adjust_width = -45;
 }
 var adjust_width = options.adjust_width;
 
-if (!options.adjust_height) {
+if (typeof options.adjust_height === "undefined") {
 	options.adjust_height = -90;
 }
 var adjust_height = options.adjust_height;
@@ -88,23 +88,12 @@
 var width_temp, height_temp;
 
 function frameWidth(){
-  	if (window.innerWidth) {
-		return window.innerWidth;
-	}
-  	else if (document.body && document.body.offsetWidth) {
-		return document.body.offsetWidth;
-	}
-  	return 0;
+  	return $(window).width();
 }
 
 function frameHeight(){
-  	if (window.innerHeight) {
-		return window.innerHeight;
-	}
-	else if (document.body && document.body.offsetHeight) {
-		return document.body.offsetHeight;
-	}
-    return 0;
+  	return $(window).height();
+
 }
 
 function adjustDimension(skipMapRequest) {
@@ -128,26 +117,29 @@
 }
 
 function rebuild() {
-  	if (width_temp != frameWidth() || height_temp != frameHeight()) {
-		window.setTimeout(function () {
-			adjustDimension()
-		}, 500);
-	}
+	setTimeout(function () {
+		// has to be called twice: the first request does a resize, 
+		// which will remove potential scrollbars.
+		// After the scrollbars are removed, the window width and height
+		// have changed, so another functiona call is necessary to fill
+		// this space
+		adjustDimension(true);
+		//adjustDimension();
+		setTimeout(function () {
+			adjustDimension(false);
+		}, 300);
+	}, 100);
 }
 
 function control(skipMapRequest){
-  	adjustDimension(skipMapRequest);
-	if (!window.width_temp && window.innerWidth) {
-  	    window.onresize = rebuild;
-  	    width_temp = frameWidth();
-  	    height_temp = frameHeight();
-    }
+	adjustDimension(skipMapRequest);
+  
+	if (!width_temp && frameWidth()) {
+		$(window).bind("resize", rebuild);
+		width_temp = frameWidth();
+		height_temp = frameHeight();
+	}
 
-    if (!window.width_temp && document.body && document.body.offsetWidth) {
-  	    window.onresize = rebuild;
-  	    width_temp = frameWidth();
-  	    height_temp = frameHeight();
-    }
 }
 
 if (resize_option == 'auto'){



More information about the Mapbender_commits mailing list