[Commits] r2319 - in core/trunk/geoext: lib/GeoExt/widgets tests/lib/GeoExt/widgets

commits at geoext.org commits at geoext.org
Fri Sep 10 14:09:25 CEST 2010


Author: ahocevar
Date: 2010-09-10 14:09:25 +0200 (Fri, 10 Sep 2010)
New Revision: 2319

Modified:
   core/trunk/geoext/lib/GeoExt/widgets/MapPanel.js
   core/trunk/geoext/lib/GeoExt/widgets/PrintMapPanel.js
   core/trunk/geoext/tests/lib/GeoExt/widgets/PrintMapPanel.html
Log:
fixe the order of function calls for size adjustments and destruction, and add logic to handle the case of zero sizes. r=pgiraud (closes #321)


Modified: core/trunk/geoext/lib/GeoExt/widgets/MapPanel.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/widgets/MapPanel.js	2010-09-08 07:39:47 UTC (rev 2318)
+++ core/trunk/geoext/lib/GeoExt/widgets/MapPanel.js	2010-09-10 12:09:25 UTC (rev 2319)
@@ -343,9 +343,6 @@
         if(this.ownerCt) {
             this.ownerCt.un("move", this.updateMapSize, this);
         }
-        GeoExt.MapPanel.superclass.beforeDestroy.apply(this, arguments);
-        // if the map panel was passed a map instance, this map instance
-        // is under the user's responsibility
         if(this.map && this.map.events) {
             this.map.events.un({
                 "moveend": this.onMoveend,
@@ -353,6 +350,8 @@
                 scope: this
             });
         }
+        // if the map panel was passed a map instance, this map instance
+        // is under the user's responsibility
         if(!this.initialConfig.map ||
            !(this.initialConfig.map instanceof OpenLayers.Map)) {
             // we created the map, we destroy it
@@ -361,6 +360,7 @@
             }
         }
         delete this.map;
+        GeoExt.MapPanel.superclass.beforeDestroy.apply(this, arguments);
     }
     
 });

Modified: core/trunk/geoext/lib/GeoExt/widgets/PrintMapPanel.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/widgets/PrintMapPanel.js	2010-09-08 07:39:47 UTC (rev 2318)
+++ core/trunk/geoext/lib/GeoExt/widgets/PrintMapPanel.js	2010-09-10 12:09:25 UTC (rev 2319)
@@ -215,8 +215,10 @@
     },
     
     /** private: method[adjustSize]
-     *  :param width: ``Number``
-     *  :param height: ``Number``
+     *  :param width: ``Number`` If not provided or 0, initialConfig.width will
+     *      be used.
+     *  :param height: ``Number`` If not provided or 0, initialConfig.height
+     *      will be used.
      *  Private override - sizing this component always takes the aspect ratio
      *  of the print page into account.
      */
@@ -227,8 +229,10 @@
         // aspect ratio - do not exceed either, but don't take values for
         // granted if container is configured with autoWidth or autoHeight.
         var ownerCt = this.ownerCt;
-        var targetWidth = (ownerCt && ownerCt.autoWidth) ? 0 : width;
-        var targetHeight = (ownerCt && ownerCt.autoHeight) ? 0 : height;
+        var targetWidth = (ownerCt && ownerCt.autoWidth) ? 0 :
+            (width || this.initialConfig.width);
+        var targetHeight = (ownerCt && ownerCt.autoHeight) ? 0 :
+            (height || this.initialConfig.height);
         if (targetWidth) {
             height = targetWidth / ratio;
             if (targetHeight && height > targetHeight) {

Modified: core/trunk/geoext/tests/lib/GeoExt/widgets/PrintMapPanel.html
===================================================================
--- core/trunk/geoext/tests/lib/GeoExt/widgets/PrintMapPanel.html	2010-09-08 07:39:47 UTC (rev 2318)
+++ core/trunk/geoext/tests/lib/GeoExt/widgets/PrintMapPanel.html	2010-09-10 12:09:25 UTC (rev 2319)
@@ -16,9 +16,9 @@
                 renderTo: "mappanel",
                 width: 256,
                 height: 256,
-                layers: [new OpenLayers.Layer.WMS("Tasmania State Boundaries",
-                    "http://demo.opengeo.org/geoserver/wms",
-                    {layers: "topp:tasmania_state_boundaries"}, {singleTile: true})],
+                layers: [new OpenLayers.Layer("Empty",
+                    {isBaseLayer: true}
+                )],
                 center: [146.56, -41.56],
                 zoom: 7
             });
@@ -42,7 +42,7 @@
             });
             
             var printSize = printMapPanel.printProvider.layout.get("size");
-            var size = printMapPanel.getSize();
+            var size = printMapPanel.map.getSize();
             var center = mapPanel.map.getCenter();
             var pageCenter = printMapPanel.printPage.center;
             
@@ -50,7 +50,7 @@
             t.ok(printMapPanel.map.controls[0] instanceof OpenLayers.Control.PanPanel, "which is a PanPanel.");
             t.eq(printMapPanel.map.layers[0].name, mapPanel.map.layers[0].name, "Preview map has the same visible layer as the source map.");
             t.eq(log.preaddlayer.name, printMapPanel.map.layers[0].name, "preaddlayer listener noticed addition of the layer.");
-            t.eq((size.width/size.height).toPrecision(2), (printSize.width/printSize.height).toPrecision(2), "Aspect ratio of the preview map is the same as of the print layout.");
+            t.eq((size.w/size.h).toPrecision(2), (printSize.width/printSize.height).toPrecision(2), "Aspect ratio of the preview map is the same as of the print layout.");
             t.ok(Math.abs(center.lon - pageCenter.lon) < 0.0000001 && Math.abs(center.lat - pageCenter.lat) < 0.0000001, "Print page has the same center as the source map.");
 
             printMapPanel.destroy();



More information about the Commits mailing list