]> dev.renevier.net Git - syp.git/commitdiff
another try to fix popup sizing problem in Firefox mainrepo/master v0.3 v0.3b
authorarno <arenevier@fdn.fr>
Mon, 24 Aug 2009 22:48:12 +0000 (00:48 +0200)
committerarno <arenevier@fdn.fr>
Mon, 24 Aug 2009 22:48:12 +0000 (00:48 +0200)
js/syp.js

index 1f4d632d087c5f2f8afa1108e1e3784329f28bed..e9d3f41431ccc8bb68254d4a9c30debe04535731 100644 (file)
--- a/js/syp.js
+++ b/js/syp.js
@@ -419,45 +419,49 @@ OpenLayers.Console.userError = function(error) {
 // least as big as content. To achieve that, we need to override
 // OpenLayers.Popup.Anchored.prototype.updateSize to modify it slightly.
 OpenLayers.Popup.Anchored.prototype.updateSize = function() {
-    // determine actual render dimensions of the contents by putting its
-    // contents into a fake contentDiv (for the CSS) and then measuring it
-    var preparedHTML = "<div class='" + this.contentDisplayClass+ "'>" + 
-        this.contentDiv.innerHTML + 
-        "</div>";
-
-    var containerElement = (this.map) ? this.map.layerContainerDiv
-                                      : document.body;
-    var realSize = OpenLayers.Util.getRenderedDimensions(
-        preparedHTML, null,    {
-            displayClass: this.displayClass,
-            containerElement: containerElement
+    var self = this;
+
+    window.setTimeout(function() { // timeout added by SYP
+
+        // determine actual render dimensions of the contents by putting its
+        // contents into a fake contentDiv (for the CSS) and then measuring it
+        var preparedHTML = "<div class='" + self.contentDisplayClass+ "'>" + 
+            self.contentDiv.innerHTML + 
+            "</div>";
+
+        var containerElement = (self.map) ? self.map.layerContainerDiv
+                                          : document.body;
+        var realSize = OpenLayers.Util.getRenderedDimensions(
+            preparedHTML, null,        {
+                displayClass: self.displayClass,
+                containerElement: containerElement
+            }
+        );
+
+        /*
+         * XXX: next four lines are added by SYP!
+         */
+        if (self.contentDiv) {
+            realSize.w = Math.max (realSize.w, self.contentDiv.scrollWidth);
+            realSize.h = Math.max (realSize.h, self.contentDiv.scrollHeight);
         }
-    );
-
-    /*
-     * XXX: next four lines are added by SYP!
-     */
-    if (this.contentDiv) {
-        realSize.w = Math.max (realSize.w, this.contentDiv.scrollWidth);
-        realSize.h = Math.max (realSize.h, this.contentDiv.scrollHeight);
-    }
 
-    // is the "real" size of the div is safe to display in our map?
-    var safeSize = this.getSafeContentSize(realSize);
+        // is the "real" size of the div is safe to display in our map?
+        var safeSize = self.getSafeContentSize(realSize);
 
-    var newSize = null;
-    if (safeSize.equals(realSize)) {
-        //real size of content is small enough to fit on the map, 
-        // so we use real size.
-        newSize = realSize;
+        var newSize = null;
+        if (safeSize.equals(realSize)) {
+            //real size of content is small enough to fit on the map, 
+            // so we use real size.
+            newSize = realSize;
 
-    } else {
+        } else {
 
-        //make a new OL.Size object with the clipped dimensions 
-        // set or null if not clipped.
-        var fixedSize = new OpenLayers.Size();
-        fixedSize.w = (safeSize.w < realSize.w) ? safeSize.w : null;
-        fixedSize.h = (safeSize.h < realSize.h) ? safeSize.h : null;
+            //make a new OL.Size object with the clipped dimensions 
+            // set or null if not clipped.
+            var fixedSize = new OpenLayers.Size();
+            fixedSize.w = (safeSize.w < realSize.w) ? safeSize.w : null;
+            fixedSize.h = (safeSize.h < realSize.h) ? safeSize.h : null;
 
             if (fixedSize.w && fixedSize.h) {
                 //content is too big in both directions, so we will use 
@@ -469,7 +473,7 @@ OpenLayers.Popup.Anchored.prototype.updateSize = function() {
                 // run getRenderedDimensions() again with a fixed dimension
                 var clippedSize = OpenLayers.Util.getRenderedDimensions(
                     preparedHTML, fixedSize, {
-                        displayClass: this.contentDisplayClass,
+                        displayClass: self.contentDisplayClass,
                         containerElement: containerElement
                     }
                 );
@@ -481,7 +485,7 @@ OpenLayers.Popup.Anchored.prototype.updateSize = function() {
                 // adjust for that.
                 //
                 var currentOverflow = OpenLayers.Element.getStyle(
-                    this.contentDiv, "overflow"
+                    self.contentDiv, "overflow"
                 );
                 if ( (currentOverflow != "hidden") && 
                      (clippedSize.equals(safeSize)) ) {
@@ -493,8 +497,9 @@ OpenLayers.Popup.Anchored.prototype.updateSize = function() {
                     }
                 }
 
-                newSize = this.getSafeContentSize(clippedSize);
+                newSize = self.getSafeContentSize(clippedSize);
             }
         }                        
-        this.setSize(newSize);     
+        self.setSize(newSize);     
+    }, 0);
 }