[Commits] r1916 - in core/trunk/geoext/lib/GeoExt: data plugins

commits at geoext.org commits at geoext.org
Thu Feb 25 00:28:39 CET 2010


Author: ahocevar
Date: 2010-02-25 00:28:39 +0100 (Thu, 25 Feb 2010)
New Revision: 1916

Modified:
   core/trunk/geoext/lib/GeoExt/data/PrintPage.js
   core/trunk/geoext/lib/GeoExt/plugins/PrintExtent.js
Log:
make PrintPage's change event always report a center change, and simplify code that checks for TransformFeature changes. r=bartvde (closes #227)

Modified: core/trunk/geoext/lib/GeoExt/data/PrintPage.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/data/PrintPage.js	2010-02-24 14:13:11 UTC (rev 1915)
+++ core/trunk/geoext/lib/GeoExt/data/PrintPage.js	2010-02-24 23:28:39 UTC (rev 1916)
@@ -174,10 +174,9 @@
                 return;
             }
         }
+        this._updating = true;
         var center = extent.getCenterLonLat();
-        this.suspendEvents();
         this.setCenter(center);
-        this.resumeEvents();
         var units = map.getUnits();
         var scale, looseScale, contains;
         this.printProvider.scales.each(function(rec) {
@@ -187,7 +186,13 @@
                 this.calculatePageBounds(scale, units));
             return !contains
         }, this);
-        this.setScale(loose && contains ? looseScale : scale, units);
+        scale = loose && contains ? looseScale : scale;
+        this.setScale(scale, units);
+        delete this._updating;
+        this.updateFeature(this.feature.geometry, {
+            center: center,
+            scale: scale
+        });
     },
 
     /** private: method[updateFeature]
@@ -201,22 +206,25 @@
      *  of changed page properties.
      */
     updateFeature: function(geometry, mods) {
-        var modified = false;
-        for(var property in mods) {
-            if(mods[property] === this[property]) {
-                delete mods[property];
-            } else {
-                this[property] = mods[property];
-                modified = true;
-            }
-        }
-        Ext.apply(this, mods);
         var f = this.feature;
         geometry.id = f.geometry.id;
         f.geometry = geometry;
-        f.layer && f.layer.drawFeature(f);
         
-        modified && this.fireEvent("change", this, mods);
+        if(!this._updating) {
+            var modified = false;
+            for(var property in mods) {
+                if(mods[property] === this[property]) {
+                    delete mods[property];
+                } else {
+                    this[property] = mods[property];
+                    modified = true;
+                }
+            }
+            Ext.apply(this, mods);
+            
+            f.layer && f.layer.drawFeature(f);
+            modified && this.fireEvent("change", this, mods);
+        }
     },    
     
     /** private: method[calculatePageBounds]

Modified: core/trunk/geoext/lib/GeoExt/plugins/PrintExtent.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/plugins/PrintExtent.js	2010-02-24 14:13:11 UTC (rev 1915)
+++ core/trunk/geoext/lib/GeoExt/plugins/PrintExtent.js	2010-02-24 23:28:39 UTC (rev 1916)
@@ -273,6 +273,7 @@
                         }
                     },
                     "beforetransform": function(e) {
+                        this._updating = true;
                         var page = this.page;
                         if(e.rotation) {
                             if(this.printProvider.layout.get("rotation")) {
@@ -299,6 +300,7 @@
                                 this.updateBox();
                             }
                         }
+                        delete this._updating;
                         return false;
                     },
                     "transformcomplete": this.updateBox,
@@ -330,7 +332,7 @@
      *  Handler for a page's change event.
      */
     onPageChange: function(page, mods) {
-        if(mods.scale || this.control.feature !== page.feature) {
+        if(!this._updating) {
             this.control.setFeature(page.feature, {rotation: -page.rotation});
         }
     }



More information about the Commits mailing list