[fusion-commits] r1814 - in trunk: lib widgets

svn_fusion at osgeo.org svn_fusion at osgeo.org
Wed Mar 11 16:11:42 EDT 2009


Author: pagameba
Date: 2009-03-11 16:11:42 -0400 (Wed, 11 Mar 2009)
New Revision: 1814

Modified:
   trunk/lib/Widget.js
   trunk/widgets/Select.js
   trunk/widgets/Zoom.js
Log:
closes #223.  Modify widget activation to only activate other widgets if they should be activated and provide a hook for individual widgets to determine whether they should be activated or not.  Modified Zoom and Select to use this new feature.  Other widgets that have problems should be reported as separate tickets.

Modified: trunk/lib/Widget.js
===================================================================
--- trunk/lib/Widget.js	2009-03-10 16:14:16 UTC (rev 1813)
+++ trunk/lib/Widget.js	2009-03-11 20:11:42 UTC (rev 1814)
@@ -85,7 +85,7 @@
     deactivate: function() { },
 
     setUiObject: function(uiObj) {
-        Fusion.Widget.uiInstances[this.type].push(uiObj);
+        Fusion.Widget.uiInstances[this.type].push(this);
         if (this.widgetTag.tooltip) {
           uiObj.setTooltip(this.widgetTag.tooltip);
         }
@@ -96,7 +96,8 @@
             this.activate();
         }
         if (uiObj.addEvents) {
-            if (Fusion.Widget.uiInstances[this.type][0].options.active) {
+            if (Fusion.Widget.uiInstances[this.type][0].uiObj &&
+                Fusion.Widget.uiInstances[this.type][0].uiObj.options.active) {
                 uiObj.options.active = true;
                 if (uiObj.domA) {
                     uiObj.domA.addClass('jx' + uiObj.options.type + 'Active');
@@ -111,9 +112,11 @@
                     var instances = Fusion.Widget.uiInstances[this.type];
                     for (var i=0; i<instances.length; i++) {
                         var instance = instances[i];
-                        instance.options.active = false;
-                        if (instance.domA) {
-                            instance.domA.removeClass('jx' + instance.options.type + 'Active');
+                        if (instance.shouldActivateWith(this) && instance.uiObj) {
+                            instance.uiObj.options.active = false;
+                            if (instance.uiObj.domA) {
+                                instance.uiObj.domA.removeClass('jx' + instance.uiObj.options.type + 'Active');
+                            }                            
                         }
                     }
                     this.deactivate();
@@ -122,9 +125,11 @@
                     var instances = Fusion.Widget.uiInstances[this.type];
                     for (var i=0; i<instances.length; i++) {
                         var instance = instances[i];
-                        instance.options.active = true;
-                        if (instance.domA) {
-                            instance.domA.addClass('jx' + instance.options.type + 'Active');
+                        if (instance.shouldActivateWith(this) && instance.uiObj) {
+                            instance.uiObj.options.active = true;
+                            if (instance.uiObj.domA) {
+                                instance.uiObj.domA.addClass('jx' + instance.uiObj.options.type + 'Active');
+                            }                            
                         }
                     }
                     this.activate();
@@ -133,6 +138,12 @@
         }
         this.uiObj = uiObj; 
     },
+    
+    /**
+     */
+    shouldActivateWith: function(widget) {
+        return true;
+    },
 
     /**
      * set the map object that this widget is associated with

Modified: trunk/widgets/Select.js
===================================================================
--- trunk/widgets/Select.js	2009-03-10 16:14:16 UTC (rev 1813)
+++ trunk/widgets/Select.js	2009-03-11 20:11:42 UTC (rev 1814)
@@ -83,6 +83,11 @@
 
     },
 
+    shouldActivateWith: function(widget) {
+        return (widget instanceof Fusion.Widget.Select &&
+                widget.bActiveOnly == this.bActiveOnly);
+        
+    }
     enable: function() {
         if (this.bActiveOnly) {
             var layer = this.getMap().getActiveLayer();

Modified: trunk/widgets/Zoom.js
===================================================================
--- trunk/widgets/Zoom.js	2009-03-10 16:14:16 UTC (rev 1813)
+++ trunk/widgets/Zoom.js	2009-03-11 20:11:42 UTC (rev 1814)
@@ -58,7 +58,14 @@
         mapWidget.handlers.push(this.handler);
         mapWidget.handlers.push(this.shiftHandler);
     },
-
+    
+    shouldActivateWith: function(widget) {
+        return (widget instanceof Fusion.Widget.Zoom &&
+                widget.zoomIn == this.zoomIn &&
+                widget.factor == this.factor &&
+                widget.tolerance == this.tolerance);
+    },
+    
    /**
      * activate the widget (listen to mouse events and change cursor)
      * This function should be defined for all functions that register



More information about the fusion-commits mailing list