[fusion-commits] r1513 - sandbox/jx2/lib

svn_fusion at osgeo.org svn_fusion at osgeo.org
Wed Sep 10 08:15:02 EDT 2008


Author: pagameba
Date: 2008-09-10 08:15:02 -0400 (Wed, 10 Sep 2008)
New Revision: 1513

Modified:
   sandbox/jx2/lib/Widget.js
Log:
add shared active state amongst widgets of the same type so if you choose a tool in a menu, the corresponding tool in the toolbar also shows as active.

Modified: sandbox/jx2/lib/Widget.js
===================================================================
--- sandbox/jx2/lib/Widget.js	2008-09-10 11:46:10 UTC (rev 1512)
+++ sandbox/jx2/lib/Widget.js	2008-09-10 12:15:02 UTC (rev 1513)
@@ -45,10 +45,6 @@
     group: null,
     domObj: null,
     uiClass: null,
-    initializeWidget: function() {},
-    activate: function() {},
-    deactivate: function() {},
-    setUiObject: function(uiObj) { this.uiObj = uiObj; },
     
     /**
      * initialize the widget
@@ -59,6 +55,9 @@
         this.name = widgetTag.name;
         this.widgetTag = widgetTag;
         this.registerEventID(Fusion.Event.WIDGET_STATE_CHANGED);
+        if (!Fusion.Widget.uiInstances[this.type]) {
+            Fusion.Widget.uiInstances[this.type] = [];
+        }
         
         var group = widgetTag.extension.Group ? widgetTag.extension.Group[0] : '';
         if (group != '') {
@@ -78,6 +77,40 @@
         
         this.initializeWidget(widgetTag);
     },
+
+    initializeWidget: function() {},
+
+    activate: function() { },
+
+    deactivate: function() { },
+
+    setUiObject: function(uiObj) {
+        Fusion.Widget.uiInstances[this.type].push(uiObj);
+        if (Fusion.Widget.uiInstances[this.type][0].options.isActive) {
+            uiObj.options.isActive = true;
+            uiObj.domA.addClass('jx' + uiObj.options.type + 'Active');
+        }
+        uiObj.addEvents({
+            'up': (function() {
+                var instances = Fusion.Widget.uiInstances[this.type];
+                for (var i=0; i<instances.length; i++) {
+                    var instance = instances[i];
+                    instance.options.isActive = false;
+                    instance.domA.removeClass('jx' + instance.options.type + 'Active');
+                }
+            }).bind(this),
+            'down': (function() {
+                var instances = Fusion.Widget.uiInstances[this.type];
+                for (var i=0; i<instances.length; i++) {
+                    var instance = instances[i];
+                    instance.options.isActive = true;
+                    instance.domA.addClass('jx' + instance.options.type + 'Active');                        
+                }
+            }).bind(this)
+        });
+        this.uiObj = uiObj; 
+    },
+
     /**
      * set the map object that this widget is associated with
      * @param oMap {Object} the map
@@ -185,3 +218,5 @@
       this.paramRegister.push(param);
     }
 });
+
+Fusion.Widget.uiInstances = {};



More information about the fusion-commits mailing list