[Commits] r1296 - in sandbox/elemoine/playground/geoext: examples lib/GeoExt/widgets/tree

commits at geoext.org commits at geoext.org
Wed Jul 29 16:34:26 CEST 2009


Author: elemoine
Date: 2009-07-29 16:34:26 +0200 (Wed, 29 Jul 2009)
New Revision: 1296

Modified:
   sandbox/elemoine/playground/geoext/examples/tree-tools.html
   sandbox/elemoine/playground/geoext/examples/tree-tools.js
   sandbox/elemoine/playground/geoext/lib/GeoExt/widgets/tree/LayerNode.js
Log:
(1) move the creation of the toolbar outside the LayerNodeUI class, (2) add tips, (3) add a show/hide toolbar action


Modified: sandbox/elemoine/playground/geoext/examples/tree-tools.html
===================================================================
--- sandbox/elemoine/playground/geoext/examples/tree-tools.html	2009-07-29 14:06:15 UTC (rev 1295)
+++ sandbox/elemoine/playground/geoext/examples/tree-tools.html	2009-07-29 14:34:26 UTC (rev 1296)
@@ -41,6 +41,9 @@
         .x-tree-node-actions .move-down {
             background:transparent url(move_down.png);
         }
+        .x-tree-node-actions .toggle-tbar {
+            background:transparent url(info.png);
+        }
         .info {
             background-image:url(info.png) !important;
             height:20px !important;

Modified: sandbox/elemoine/playground/geoext/examples/tree-tools.js
===================================================================
--- sandbox/elemoine/playground/geoext/examples/tree-tools.js	2009-07-29 14:06:15 UTC (rev 1295)
+++ sandbox/elemoine/playground/geoext/examples/tree-tools.js	2009-07-29 14:34:26 UTC (rev 1296)
@@ -7,6 +7,7 @@
  */
 
 Ext.onReady(function() {
+    Ext.QuickTips.init();
 
     var mapPanel = new GeoExt.MapPanel({
         border: true,
@@ -59,7 +60,30 @@
                 })
         ]
     });
-    
+
+    function createTbar(node, ct) {
+        return new Ext.Toolbar({
+            renderTo: ct,
+            cls: "gx-toolbar",
+            hidden: true,
+            buttons: [new GeoExt.LayerOpacitySlider({
+                layer: node.layer,
+                width: 200
+            }), "->", {
+                iconCls: "info",
+                tooltip: "layer info",
+                handler: function() {
+                    new Ext.Window({
+                        html: this.layer.name,
+                        height: 200,
+                        width: 200
+                    }).show();
+                },
+                scope: node
+            }]
+        });
+    }
+
     var tree = new Ext.tree.TreePanel({
         border: true,
         region: "west",
@@ -79,7 +103,23 @@
                     deleteAction: true,
                     upAction: true,
                     downAction: true,
-                    opacitySlider: true
+                    actions: [{
+                        action: "toggle-tbar",
+                        qtip: "show/hide toolbar"
+                    }],
+                    component: createTbar,
+                    listeners: {
+                        action: function(node, action, e) {
+                            if(action == "toggle-tbar") {
+                                var c = node.component;
+                                if(node.component.hidden) {
+                                    c.show();
+                                } else {
+                                    c.hide();
+                                }
+                            }
+                        }
+                    }
                 }
             }
         },

Modified: sandbox/elemoine/playground/geoext/lib/GeoExt/widgets/tree/LayerNode.js
===================================================================
--- sandbox/elemoine/playground/geoext/lib/GeoExt/widgets/tree/LayerNode.js	2009-07-29 14:06:15 UTC (rev 1295)
+++ sandbox/elemoine/playground/geoext/lib/GeoExt/widgets/tree/LayerNode.js	2009-07-29 14:34:26 UTC (rev 1296)
@@ -62,7 +62,8 @@
             }
             this.enforceOneVisible();
 
-            var actions = a.actions || this.actions || [];
+            var actions = a.actions || this.actions;
+            actions = [].concat(actions);
             var deleteAction = a.deleteAction || this.deleteAction;
             if(deleteAction) {
                 if(typeof deleteAction != "object") {
@@ -108,41 +109,19 @@
             }
 
             var component = a.component || this.component;
-            var opacitySlider = a.opacitySlider || this.opacitySlider;
-            if(opacitySlider) {
-                // add div in the node
+            if(component) {
                 var elt = Ext.DomHelper.append(this.elNode, [
-                    {"tag": "div"}//, "style": "position:relative;left:20"}
+                    {"tag": "div"}//, "style": "position:relative;left:20"
                 ]);
-                var slider = new GeoExt.LayerOpacitySlider({
-                    layer: this.node.layer,
-                    width: 200
-                });
-                new Ext.Toolbar({
-                    renderTo: elt,
-                    cls: "gx-toolbar",
-                    buttons: [slider, "->", {
-                        iconCls: "info",
-                        handler: function() {
-                            new Ext.Window({
-                                html: this.node.layer.name,
-                                height: 200,
-                                width: 200
-                            }).show();
-                        },
-                        scope: this
-                    }]
-                });
-                /*
-                if(typeof comp == "function") {
-                    comp(this.node, elt);
-                } else if(typeof comp == "object" &&
-                          typeof comp.fn == "function") {
-                    comp.apply(comp.scope, [this.node, elt]);
-                } else if(comp instanceof Ext.Component) {
-                    comp.render(elt);
+                if(typeof component == "function") {
+                    this.node.component = component(this.node, elt);
+                } else if(typeof component == "object" &&
+                          typeof component.fn == "function") {
+                    this.node.component = component.apply(component.scope, [this.node, elt]);
+                } else if(component instanceof Ext.Component) {
+                    component.render(elt);
+                    this.node.component = component;
                 }
-                */
             }
         }
     },
@@ -156,9 +135,11 @@
         } else if(e.getTarget('.x-tree-node-cb', 1)) {
             this.onCheckChange();
         } else if(e.getTarget('.' + this.actionCls, 1)) {
-            //var action = t.className.replace(this.actionCls + ' ', '');
-            //FIXME
-            alert("yo");
+            var t = e.getTarget('.' + this.actionCls, 1);
+            var action = t.className.replace(this.actionCls + ' ', '');
+            if (this.fireEvent("action", this.node, action, e) === false) {
+                return;
+            }
         } else {
             GeoExt.tree.LayerNodeUI.superclass.onClick.apply(this, arguments);
         }



More information about the Commits mailing list