Upgrade to ExtJS 3.1.1 - Released 02/08/2010
[extjs.git] / docs / source / TreeNodeUI.html
index e1e86ed..5820fcc 100644 (file)
@@ -1,5 +1,6 @@
 <html>\r
 <head>\r
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    \r
   <title>The source code</title>\r
     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
@@ -32,7 +33,7 @@ Ext.tree.TreeNodeUI.prototype = {
     removeChild : function(node){\r
         if(this.rendered){\r
             this.ctNode.removeChild(node.ui.getEl());\r
-        } \r
+        }\r
     },\r
 \r
     // private\r
@@ -55,14 +56,14 @@ Ext.tree.TreeNodeUI.prototype = {
     // private\r
     onDisableChange : function(node, state){\r
         this.disabled = state;\r
-               if (this.checkbox) {\r
-                       this.checkbox.disabled = state;\r
-               }        \r
+        if (this.checkbox) {\r
+            this.checkbox.disabled = state;\r
+        }\r
         if(state){\r
             this.addClass("x-tree-node-disabled");\r
         }else{\r
             this.removeClass("x-tree-node-disabled");\r
-        } \r
+        }\r
     },\r
 \r
     // private\r
@@ -113,7 +114,7 @@ Ext.tree.TreeNodeUI.prototype = {
  */\r
     removeClass : function(cls){\r
         if(this.elNode){\r
-            Ext.fly(this.elNode).removeClass(cls);  \r
+            Ext.fly(this.elNode).removeClass(cls);\r
         }\r
     },\r
 \r
@@ -122,12 +123,12 @@ Ext.tree.TreeNodeUI.prototype = {
         if(this.rendered){\r
             this.holder = document.createElement("div");\r
             this.holder.appendChild(this.wrap);\r
-        }  \r
+        }\r
     },\r
 \r
     // private\r
     fireEvent : function(){\r
-        return this.node.fireEvent.apply(this.node, arguments);  \r
+        return this.node.fireEvent.apply(this.node, arguments);\r
     },\r
 \r
     // private\r
@@ -135,10 +136,7 @@ Ext.tree.TreeNodeUI.prototype = {
         this.node.on("move", this.onMove, this);\r
 \r
         if(this.node.disabled){\r
-            this.addClass("x-tree-node-disabled");\r
-                       if (this.checkbox) {\r
-                               this.checkbox.disabled = true;\r
-                       }            \r
+            this.onDisableChange(this.node, true);\r
         }\r
         if(this.node.hidden){\r
             this.hide();\r
@@ -176,7 +174,7 @@ Ext.tree.TreeNodeUI.prototype = {
         this.node.hidden = false;\r
         if(this.wrap){\r
             this.wrap.style.display = "";\r
-        } \r
+        }\r
     },\r
 \r
     // private\r
@@ -223,13 +221,15 @@ Ext.tree.TreeNodeUI.prototype = {
         if(this.disabled){\r
             return;\r
         }\r
-        if(this.checkbox){\r
-            this.toggleCheck();\r
-        }\r
-        if(!this.animating && this.node.isExpandable()){\r
-            this.node.toggle();\r
+        if(this.fireEvent("beforedblclick", this.node, e) !== false){\r
+            if(this.checkbox){\r
+                this.toggleCheck();\r
+            }\r
+            if(!this.animating && this.node.isExpandable()){\r
+                this.node.toggle();\r
+            }\r
+            this.fireEvent("dblclick", this.node, e);\r
         }\r
-        this.fireEvent("dblclick", this.node, e);\r
     },\r
 \r
     onOver : function(e){\r
@@ -243,8 +243,8 @@ Ext.tree.TreeNodeUI.prototype = {
     // private\r
     onCheckChange : function(){\r
         var checked = this.checkbox.checked;\r
-               // fix for IE6\r
-               this.checkbox.defaultChecked = checked;         \r
+        // fix for IE6\r
+        this.checkbox.defaultChecked = checked;\r
         this.node.attributes.checked = checked;\r
         this.fireEvent('checkchange', this.node, checked);\r
     },\r
@@ -260,12 +260,12 @@ Ext.tree.TreeNodeUI.prototype = {
     startDrop : function(){\r
         this.dropping = true;\r
     },\r
-    \r
+\r
     // delayed drop so the click event doesn't get fired on a drop\r
-    endDrop : function(){ \r
+    endDrop : function(){\r
        setTimeout(function(){\r
            this.dropping = false;\r
-       }.createDelegate(this), 50); \r
+       }.createDelegate(this), 50);\r
     },\r
 \r
     // private\r
@@ -306,7 +306,7 @@ Ext.tree.TreeNodeUI.prototype = {
     blur : function(){\r
         try{\r
             this.anchor.blur();\r
-        }catch(e){} \r
+        }catch(e){}\r
     },\r
 \r
     // private\r
@@ -321,7 +321,7 @@ Ext.tree.TreeNodeUI.prototype = {
         }\r
         this.animating = true;\r
         this.updateExpandIcon();\r
-        \r
+\r
         ct.slideIn('t', {\r
            callback : function(){\r
                this.animating = false;\r
@@ -368,12 +368,15 @@ Ext.tree.TreeNodeUI.prototype = {
 \r
     // private\r
     getContainer : function(){\r
-        return this.ctNode;  \r
+        return this.ctNode;\r
     },\r
 \r
-    // private\r
+<div id="method-Ext.tree.TreeNodeUI-getEl"></div>/**\r
+ * Returns the element which encapsulates this node.\r
+ * @return {HtmlElement} The DOM element. The default implementation uses a <code>&lt;li></code>.\r
+ */\r
     getEl : function(){\r
-        return this.wrap;  \r
+        return this.wrap;\r
     },\r
 \r
     // private\r
@@ -388,15 +391,15 @@ Ext.tree.TreeNodeUI.prototype = {
 \r
     // private\r
     onRender : function(){\r
-        this.render();    \r
+        this.render();\r
     },\r
 \r
     // private\r
     render : function(bulkRender){\r
         var n = this.node, a = n.attributes;\r
-        var targetNode = n.parentNode ? \r
+        var targetNode = n.parentNode ?\r
               n.parentNode.ui.getContainer() : n.ownerTree.innerCt.dom;\r
-        \r
+\r
         if(!this.rendered){\r
             this.rendered = true;\r
 \r
@@ -413,7 +416,7 @@ Ext.tree.TreeNodeUI.prototype = {
                    if(a.qtipTitle){\r
                        this.textNode.setAttribute("ext:qtitle", a.qtipTitle);\r
                    }\r
-               } \r
+               }\r
             }else if(a.qtipCfg){\r
                 a.qtipCfg.target = Ext.id(this.textNode);\r
                 Ext.QuickTips.register(a.qtipCfg);\r
@@ -434,10 +437,10 @@ Ext.tree.TreeNodeUI.prototype = {
         // add some indent caching, this helps performance when rendering a large tree\r
         this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';\r
 \r
-        var cb = typeof a.checked == 'boolean';\r
-\r
-        var href = a.href ? a.href : Ext.isGecko ? "" : "#";\r
-        var buf = ['<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf x-unselectable ', a.cls,'" unselectable="on">',\r
+        var cb = Ext.isBoolean(a.checked),\r
+            nel,\r
+            href = a.href ? a.href : Ext.isGecko ? "" : "#",\r
+            buf = ['<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf x-unselectable ', a.cls,'" unselectable="on">',\r
             '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",\r
             '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow" />',\r
             '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on" />',\r
@@ -447,13 +450,12 @@ Ext.tree.TreeNodeUI.prototype = {
             '<ul class="x-tree-node-ct" style="display:none;"></ul>',\r
             "</li>"].join('');\r
 \r
-        var nel;\r
         if(bulkRender !== true && n.nextSibling && (nel = n.nextSibling.ui.getEl())){\r
             this.wrap = Ext.DomHelper.insertHtml("beforeBegin", nel, buf);\r
         }else{\r
             this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf);\r
         }\r
-        \r
+\r
         this.elNode = this.wrap.childNodes[0];\r
         this.ctNode = this.wrap.childNodes[1];\r
         var cs = this.elNode.childNodes;\r
@@ -463,8 +465,8 @@ Ext.tree.TreeNodeUI.prototype = {
         var index = 3;\r
         if(cb){\r
             this.checkbox = cs[3];\r
-                       // fix for IE6\r
-                       this.checkbox.defaultChecked = this.checkbox.checked;                                           \r
+            // fix for IE6\r
+            this.checkbox.defaultChecked = this.checkbox.checked;\r
             index++;\r
         }\r
         this.anchor = cs[index];\r
@@ -478,7 +480,7 @@ Ext.tree.TreeNodeUI.prototype = {
     getAnchor : function(){\r
         return this.anchor;\r
     },\r
-    \r
+\r
 <div id="method-Ext.tree.TreeNodeUI-getTextEl"></div>/**\r
  * Returns the text node.\r
  * @return {HtmlNode} The DOM text node.\r
@@ -486,7 +488,7 @@ Ext.tree.TreeNodeUI.prototype = {
     getTextEl : function(){\r
         return this.textNode;\r
     },\r
-    \r
+\r
 <div id="method-Ext.tree.TreeNodeUI-getIconEl"></div>/**\r
  * Returns the icon &lt;img> element.\r
  * @return {HtmlElement} The DOM image element.\r
@@ -501,15 +503,17 @@ Ext.tree.TreeNodeUI.prototype = {
  * @return {Boolean} The checked flag.\r
  */\r
     isChecked : function(){\r
-        return this.checkbox ? this.checkbox.checked : false; \r
+        return this.checkbox ? this.checkbox.checked : false;\r
     },\r
 \r
     // private\r
     updateExpandIcon : function(){\r
         if(this.rendered){\r
-            var n = this.node, c1, c2;\r
-            var cls = n.isLast() ? "x-tree-elbow-end" : "x-tree-elbow";\r
-            var hasChild = n.hasChildNodes();\r
+            var n = this.node,\r
+                c1,\r
+                c2,\r
+                cls = n.isLast() ? "x-tree-elbow-end" : "x-tree-elbow",\r
+                hasChild = n.hasChildNodes();\r
             if(hasChild || n.attributes.expandable){\r
                 if(n.expanded){\r
                     cls += "-minus";\r
@@ -530,7 +534,7 @@ Ext.tree.TreeNodeUI.prototype = {
                 }\r
             }else{\r
                 if(!this.wasLeaf){\r
-                    Ext.fly(this.elNode).replaceClass("x-tree-node-expanded", "x-tree-node-leaf");\r
+                    Ext.fly(this.elNode).replaceClass("x-tree-node-expanded", "x-tree-node-collapsed");\r
                     delete this.c1;\r
                     delete this.c2;\r
                     this.wasLeaf = true;\r
@@ -543,7 +547,7 @@ Ext.tree.TreeNodeUI.prototype = {
             }\r
         }\r
     },\r
-    \r
+\r
     // private\r
     onIdChange: function(id){\r
         if(this.rendered){\r
@@ -554,8 +558,8 @@ Ext.tree.TreeNodeUI.prototype = {
     // private\r
     getChildIndent : function(){\r
         if(!this.childIndent){\r
-            var buf = [];\r
-            var p = this.node;\r
+            var buf = [],\r
+                p = this.node;\r
             while(p){\r
                 if(!p.isRoot || (p.isRoot && p.ownerTree.rootVisible)){\r
                     if(!p.isLast()) {\r
@@ -574,8 +578,8 @@ Ext.tree.TreeNodeUI.prototype = {
     // private\r
     renderIndent : function(){\r
         if(this.rendered){\r
-            var indent = "";\r
-            var p = this.node.parentNode;\r
+            var indent = "",\r
+                p = this.node.parentNode;\r
             if(p){\r
                 indent = p.ui.getChildIndent();\r
             }\r
@@ -591,23 +595,14 @@ Ext.tree.TreeNodeUI.prototype = {
         if(this.elNode){\r
             Ext.dd.Registry.unregister(this.elNode.id);\r
         }\r
-        delete this.elNode;\r
-        delete this.ctNode;\r
-        delete this.indentNode;\r
-        delete this.ecNode;\r
-        delete this.iconNode;\r
-        delete this.checkbox;\r
-        delete this.anchor;\r
-        delete this.textNode;\r
-        \r
-        if (this.holder){\r
-             delete this.wrap;\r
-             Ext.removeNode(this.holder);\r
-             delete this.holder;\r
-        }else{\r
-            Ext.removeNode(this.wrap);\r
-            delete this.wrap;\r
-        }\r
+\r
+        Ext.each(['textnode', 'anchor', 'checkbox', 'indentNode', 'ecNode', 'iconNode', 'elNode', 'ctNode', 'wrap', 'holder'], function(el){\r
+            if(this[el]){\r
+                Ext.fly(this[el]).remove();\r
+                delete this[el];\r
+            }\r
+        }, this);\r
+        delete this.node;\r
     }\r
 };\r
 \r