[Commits] r1612 - in sandbox/ahocevar/playground/ux/Printing/ux: data plugins widgets/form

commits at geoext.org commits at geoext.org
Thu Dec 24 23:44:45 CET 2009


Author: ahocevar
Date: 2009-12-24 23:44:45 +0100 (Thu, 24 Dec 2009)
New Revision: 1612

Modified:
   sandbox/ahocevar/playground/ux/Printing/ux/data/PrintPage.js
   sandbox/ahocevar/playground/ux/Printing/ux/plugins/PrintPageField.js
   sandbox/ahocevar/playground/ux/Printing/ux/plugins/PrintProviderField.js
   sandbox/ahocevar/playground/ux/Printing/ux/widgets/form/SimplePrint.js
Log:
added destroy methods that take care of unregistering events.

Modified: sandbox/ahocevar/playground/ux/Printing/ux/data/PrintPage.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/ux/data/PrintPage.js	2009-12-24 22:20:44 UTC (rev 1611)
+++ sandbox/ahocevar/playground/ux/Printing/ux/data/PrintPage.js	2009-12-24 22:44:45 UTC (rev 1612)
@@ -103,9 +103,7 @@
         }
         
         this.printProvider.on({
-            "layoutchange": function() {
-                this.updateByHandle();
-            },
+            "layoutchange": this.updateByHandle,
             scope: this
         });
 
@@ -304,6 +302,13 @@
         
         return new OpenLayers.Bounds(center.lon - w, center.lat - h,
             center.lon + w, center.lat + h);
+    },
+    
+    /** private: method[destroy]
+     */
+    destroy: function() {
+        this.printProvider.un("layoutchange", this.updateByHandle, this);
+        GeoExt.ux.data.PrintPage.superclass.destroy.apply(this, arguments);
     }
 
 });
\ No newline at end of file

Modified: sandbox/ahocevar/playground/ux/Printing/ux/plugins/PrintPageField.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/ux/plugins/PrintPageField.js	2009-12-24 22:20:44 UTC (rev 1611)
+++ sandbox/ahocevar/playground/ux/Printing/ux/plugins/PrintPageField.js	2009-12-24 22:44:45 UTC (rev 1612)
@@ -95,6 +95,15 @@
             t.setDisabled(!page.printProvider.layout.get("rotation"));
         }
         t.resumeEvents();
+    },
+    
+    /** private: method[destroy]
+     */
+    destroy: function() {
+        this.target.un("select", this.onFieldChange, this);
+        this.target.un("valid", this.onFieldChange, this);
+        this.page.un("change", this.onPageChange, this);
+        GeoExt.ux.plugins.PrintPageField.superclass.destroy.apply(this, arguments);
     }
 
 });

Modified: sandbox/ahocevar/playground/ux/Printing/ux/plugins/PrintProviderField.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/ux/plugins/PrintProviderField.js	2009-12-24 22:20:44 UTC (rev 1611)
+++ sandbox/ahocevar/playground/ux/Printing/ux/plugins/PrintProviderField.js	2009-12-24 22:44:45 UTC (rev 1612)
@@ -60,16 +60,14 @@
         if(field.store === printProvider.layouts) {
             field.setValue(printProvider.layout.get(field.displayField));
             printProvider.on({
-                "layoutchange": function(printProvider, layout) {
-                    field.setValue(layout.get(field.displayField));
-                }
+                "layoutchange": this.onLayoutChange,
+                scope: this
             });
         } else if(field.store === printProvider.dpis) {
             field.setValue(printProvider.dpi.get(field.displayField));
             printProvider.on({
-                "dpichange": function(printProvider, dpi) {
-                    field.setValue(dpi.get(field.displayField));
-                }
+                "dpichange": this.onDpiChange,
+                scope: this
             });
         } else {
             field.setValue(printProvider.customParams[field.name]);
@@ -96,7 +94,40 @@
         } else {
             printProvider.customParams[field.name] = value;
         }
+    },
+    
+    /** private: method[onLayoutChange]
+     *  :param printProvider: :class:`GeoExt.ux.data.PrintProvider`
+     *  :param layout: ``Ext.data.Record``
+     *  
+     *  Handler function for the printProvider's layoutchange event
+     */
+    onLayoutChange: function(printProvider, layout) {
+        this.target.setValue(layout.get(this.target.displayField));
+    },
+    
+    /** private: method[onDpiChange]
+     *  :param printProvider: :class:`GeoExt.ux.data.PrintProvider`
+     *  :param layout: ``Ext.data.Record``
+     *  
+     *  Handler function for the printProvider's dpichange event
+     */
+    onDpiChange: function(printProvider, dpi) {
+        this.target.setValue(dpi.get(this.target.displayField));
+    },
+    
+    /** private: method[destroy]
+     */
+    destroy: function() {
+        var printProvider = this.target.ownerCt.printProvider;
+        printProvider.un("layoutchange", this.onLayoutChange, this);
+        printProvider.un("dpichange", this.onDpiChange, this);
+        this.target.un("select", this.onFieldChange, this);
+        this.target.un("valid", this.onFieldChange, this);
+        this.target.un("render", this.onRender, this);
+        GeoExt.ux.plugins.PrintProviderField.superclass.destroy.apply(this, arguments);
     }
+        
 });
 
 /** api: ptype = gx_printproviderfield */

Modified: sandbox/ahocevar/playground/ux/Printing/ux/widgets/form/SimplePrint.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/ux/widgets/form/SimplePrint.js	2009-12-24 22:20:44 UTC (rev 1611)
+++ sandbox/ahocevar/playground/ux/Printing/ux/widgets/form/SimplePrint.js	2009-12-24 22:44:45 UTC (rev 1612)
@@ -177,11 +177,11 @@
         this.doLayout();
     },
     
+    /** private: method[beforeDestroy]
+     */
     beforeDestroy: function() {
-        this.printProvider.un({
-            "beforePrint": this.busyMask.show,
-            "print": this.busyMask.hide
-        });
+        this.printProvider.un("beforePrint", this.busyMask.show, this.busyMask);
+        this.printProvider.un("print", this.busyMask.hide, this.busyMask);
         GeoExt.ux.SimplePrint.superclass.beforeDestroy.apply(this, arguments);
     }
     



More information about the Commits mailing list