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

commits at geoext.org commits at geoext.org
Fri May 29 16:58:58 CEST 2009


Author: tschaub
Date: 2009-05-29 16:58:58 +0200 (Fri, 29 May 2009)
New Revision: 904

Modified:
   core/trunk/geoext/examples/popup.js
   core/trunk/geoext/lib/GeoExt/widgets/MapPanel.js
   core/trunk/geoext/lib/GeoExt/widgets/Popup.js
   core/trunk/geoext/tests/lib/GeoExt/widgets/Popup.html
Log:
Pulling out the unintential changes that I got in to r863.  These belong to #45 and still need approval from a reviewer.

Modified: core/trunk/geoext/examples/popup.js
===================================================================
--- core/trunk/geoext/examples/popup.js	2009-05-29 14:10:20 UTC (rev 903)
+++ core/trunk/geoext/examples/popup.js	2009-05-29 14:58:58 UTC (rev 904)
@@ -36,7 +36,7 @@
                 }
             }
         });
-        mapPanel.add(popup);
+        popup.addToMapPanel(mapPanel);
     }
 
     // create popup on "featureselected"

Modified: core/trunk/geoext/lib/GeoExt/widgets/MapPanel.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/widgets/MapPanel.js	2009-05-29 14:10:20 UTC (rev 903)
+++ core/trunk/geoext/lib/GeoExt/widgets/MapPanel.js	2009-05-29 14:58:58 UTC (rev 904)
@@ -188,26 +188,6 @@
         this.updateMapSize();
     },
     
-    /** private: method[onBeforeAdd]
-     *  Private method called before a component is added to the panel.
-     */
-    onBeforeAdd: function(item) {
-        if(typeof item.addToMapPanel === "function") {
-            item.addToMapPanel(this);
-        }
-        GeoExt.MapPanel.superclass.onBeforeAdd.apply(this, arguments);
-    },
-    
-    /** private: method[remove]
-     *  Private method called when a component is removed from the panel.
-     */
-    remove: function(item, autoDestroy) {
-        if(typeof item.removeFromMapPanel === "function") {
-            item.removeFromMapPanel(this);
-        }
-        GeoExt.MapPanel.superclass.remove.apply(this, arguments);
-    },
-
     /** private: method[beforeDestroy]
      *  Private method called during the destroy sequence.
      */

Modified: core/trunk/geoext/lib/GeoExt/widgets/Popup.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/widgets/Popup.js	2009-05-29 14:10:20 UTC (rev 903)
+++ core/trunk/geoext/lib/GeoExt/widgets/Popup.js	2009-05-29 14:58:58 UTC (rev 904)
@@ -146,36 +146,34 @@
         GeoExt.Popup.superclass.initTools.call(this);
     },
 
-    /** private: method[addToMapPanel]
+    /** api: method[addToMapPanel]
      *  :param mapPanel: :class:`MapPanel` The panel to which this popup should
      *      be added.
      *  
      *  Adds this popup to a :class:`MapPanel`.  Assumes that the
      *  MapPanel's map is already initialized and that the
-     *  Popup's feature is on the map.  This method is called by the MapPanel's
-     *  add method.
+     *  Popup's feature is on the map.
      */
     addToMapPanel: function(mapPanel) {
         this.mapPanel = mapPanel;
         this.map = this.mapPanel.map;
-        
-        mapPanel.on({
-            "add": {
-                fn: function() {
-                    mapPanel.doLayout();
-                    this.position();
-                    if(this.anchored) {
-                        this.anchorPopup();
-                    }
-                    this.show();
-                    if(this.panIn) {
-                        this.panIntoView();
-                    }
-                },
-                single: true,
-                scope: this
-            }
-        });
+
+        mapPanel.add(this);
+        mapPanel.doLayout();
+
+        this.position();
+
+        /* Anchoring */
+        if(this.anchored) {
+            this.anchorPopup();
+        }
+
+        this.show();
+
+        /* Panning */
+        if(this.panIn) {
+            this.panIntoView();
+        }
     },
 
     /** api: method[setSize]
@@ -251,6 +249,7 @@
      *  MapPanel and adds it to the page body.
      */
     unanchorPopup: function() {
+        this.unbindFromMapPanel();
 
         //make the window draggable
         this.draggable = true;
@@ -285,11 +284,10 @@
         }
     },
 
-    /** private: method[removeFromMapPanel]
+    /** private: method[unbindFromMapPanel]
      *  Utility method for unbinding events that call for popup repositioning.
-     *  Called from the panel during panel.remove(popup).
      */
-    removeFromMapPanel: function() {
+    unbindFromMapPanel: function() {
         if(this.map && this.map.events) {
             //stop position with feature
             this.map.events.un({
@@ -298,12 +296,9 @@
             });
         }
 
-        this.un("resize", this.position, this);
-        this.un("collapse", this.position, this);
-        this.un("expand", this.position, this);
-
-        delete this.mapPanel;
-        delete this.map;
+        this.un("resize", this.position);
+        this.un("collapse", this.position);
+        this.un("expand", this.position);
     },
 
     /** private: method[panIntoView]
@@ -359,7 +354,7 @@
      *  Cleanup events before destroying the popup.
      */
     beforeDestroy: function() {
-        this.removeFromMapPanel();
+        this.unbindFromMapPanel();
         GeoExt.Popup.superclass.beforeDestroy.call(this);
     }
 });

Modified: core/trunk/geoext/tests/lib/GeoExt/widgets/Popup.html
===================================================================
--- core/trunk/geoext/tests/lib/GeoExt/widgets/Popup.html	2009-05-29 14:10:20 UTC (rev 903)
+++ core/trunk/geoext/tests/lib/GeoExt/widgets/Popup.html	2009-05-29 14:58:58 UTC (rev 904)
@@ -63,7 +63,7 @@
 
             var pop = popup(context.feature);
 
-            context.mapPanel.add(pop);
+            pop.addToMapPanel(context.mapPanel);
 
             t.ok(context.mapPanel.el.child("div." + pop.popupCls),"Map panel contains popup");
             
@@ -77,7 +77,7 @@
 
             var pop = popup(context.feature);
 
-            context.mapPanel.add(pop);
+            pop.addToMapPanel(context.mapPanel);
 
             pop.on({
                 'move' : function(c,x,y){
@@ -108,7 +108,7 @@
 
             var pop = popup(context.feature, context.mapPanel);
 
-            context.mapPanel.add(pop);
+            pop.addToMapPanel(context.mapPanel);
         
             pop.collapse();
 
@@ -145,25 +145,31 @@
 
         }
 
-        function test_Popup_destroy(t){
+        function test_Popup_beforeDestroy(t){
 
-            t.plan(1);
+            t.plan(0);
 
             var context = setupContext();
             var pop = popup(context.feature);
-            context.mapPanel.add(pop);
-            
-            var called = false;
+            pop.addToMapPanel(context.mapPanel);
+
             pop.on({
-                move: function() {
-                    called = true;
-                }
+                'move' : function(c,x,y){
+                    t.ok(false,"Move event fired improperly on " + action); //should happen twice, on call to position()
+                },
+                scope : this
             });
-            pop.destroy();
 
+            pop.beforeDestroy();
+
+            var action = "map move";
             context.map.events.triggerEvent("move");
+
+            action = "popup expand"
+            pop.expand();
             
-            t.ok(!called, "pop is not moved after it is destroyed");
+            action = "popup collapse";
+            pop.collapse();
             
             tearDown(context);
         }



More information about the Commits mailing list