Upgrade to ExtJS 3.2.0 - Released 03/30/2010
[extjs.git] / docs / source / TreeEventModel.html
index 5d695ee..eb13f5a 100644 (file)
-<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
-</head>\r
-<body  onload="prettyPrint();">\r
-    <pre class="prettyprint lang-js">Ext.tree.TreeEventModel = function(tree){\r
-    this.tree = tree;\r
-    this.tree.on('render', this.initEvents, this);\r
-}\r
-\r
-Ext.tree.TreeEventModel.prototype = {\r
-    initEvents : function(){\r
-        var t = this.tree;\r
-\r
-        if(t.trackMouseOver !== false){\r
-            t.mon(t.innerCt, {\r
-                scope: this,\r
-                mouseover: this.delegateOver,\r
-                mouseout: this.delegateOut\r
-            });\r
-        }\r
-        t.mon(t.getTreeEl(), {\r
-            scope: this,\r
-            click: this.delegateClick,\r
-            dblclick: this.delegateDblClick,\r
-            contextmenu: this.delegateContextMenu\r
-        });\r
-    },\r
-\r
-    getNode : function(e){\r
-        var t;\r
-        if(t = e.getTarget('.x-tree-node-el', 10)){\r
-            var id = Ext.fly(t, '_treeEvents').getAttribute('tree-node-id', 'ext');\r
-            if(id){\r
-                return this.tree.getNodeById(id);\r
-            }\r
-        }\r
-        return null;\r
-    },\r
-\r
-    getNodeTarget : function(e){\r
-        var t = e.getTarget('.x-tree-node-icon', 1);\r
-        if(!t){\r
-            t = e.getTarget('.x-tree-node-el', 6);\r
-        }\r
-        return t;\r
-    },\r
-\r
-    delegateOut : function(e, t){\r
-        if(!this.beforeEvent(e)){\r
-            return;\r
-        }\r
-        if(e.getTarget('.x-tree-ec-icon', 1)){\r
-            var n = this.getNode(e);\r
-            this.onIconOut(e, n);\r
-            if(n == this.lastEcOver){\r
-                delete this.lastEcOver;\r
-            }\r
-        }\r
-        if((t = this.getNodeTarget(e)) && !e.within(t, true)){\r
-            this.onNodeOut(e, this.getNode(e));\r
-        }\r
-    },\r
-\r
-    delegateOver : function(e, t){\r
-        if(!this.beforeEvent(e)){\r
-            return;\r
-        }\r
-        if(Ext.isGecko && !this.trackingDoc){ // prevent hanging in FF\r
-            Ext.getBody().on('mouseover', this.trackExit, this);\r
-            this.trackingDoc = true;\r
-        }\r
-        if(this.lastEcOver){ // prevent hung highlight\r
-            this.onIconOut(e, this.lastEcOver);\r
-            delete this.lastEcOver;\r
-        }\r
-        if(e.getTarget('.x-tree-ec-icon', 1)){\r
-            this.lastEcOver = this.getNode(e);\r
-            this.onIconOver(e, this.lastEcOver);\r
-        }\r
-        if(t = this.getNodeTarget(e)){\r
-            this.onNodeOver(e, this.getNode(e));\r
-        }\r
-    },\r
-\r
-    trackExit : function(e){\r
-        if(this.lastOverNode){\r
-            if(this.lastOverNode.ui && !e.within(this.lastOverNode.ui.getEl())){\r
-                this.onNodeOut(e, this.lastOverNode);\r
-            }\r
-            delete this.lastOverNode;\r
-            Ext.getBody().un('mouseover', this.trackExit, this);\r
-            this.trackingDoc = false;\r
-        }\r
-\r
-    },\r
-\r
-    delegateClick : function(e, t){\r
-        if(this.beforeEvent(e)){\r
-            if(e.getTarget('input[type=checkbox]', 1)){\r
-                this.onCheckboxClick(e, this.getNode(e));\r
-            }else if(e.getTarget('.x-tree-ec-icon', 1)){\r
-                this.onIconClick(e, this.getNode(e));\r
-            }else if(this.getNodeTarget(e)){\r
-                this.onNodeClick(e, this.getNode(e));\r
-            }else{\r
-                this.onContainerEvent(e, 'click');\r
-            }\r
-        }\r
-    },\r
-\r
-    delegateDblClick : function(e, t){\r
-        if(this.beforeEvent(e)){\r
-            if(this.getNodeTarget(e)){\r
-                this.onNodeDblClick(e, this.getNode(e));\r
-            }else{\r
-                this.onContainerEvent(e, 'dblclick');\r
-            }\r
-        }\r
-    },\r
-\r
-    delegateContextMenu : function(e, t){\r
-        if(this.beforeEvent(e)){\r
-            if(this.getNodeTarget(e)){\r
-                this.onNodeContextMenu(e, this.getNode(e));\r
-            }else{\r
-                this.onContainerEvent(e, 'contextmenu');\r
-            }\r
-        }\r
-    },\r
-\r
-    onContainerEvent: function(e, type){\r
-        this.tree.fireEvent('container' + type, this.tree, e);\r
-    },\r
-\r
-    onNodeClick : function(e, node){\r
-        node.ui.onClick(e);\r
-    },\r
-\r
-    onNodeOver : function(e, node){\r
-        this.lastOverNode = node;\r
-        node.ui.onOver(e);\r
-    },\r
-\r
-    onNodeOut : function(e, node){\r
-        node.ui.onOut(e);\r
-    },\r
-\r
-    onIconOver : function(e, node){\r
-        node.ui.addClass('x-tree-ec-over');\r
-    },\r
-\r
-    onIconOut : function(e, node){\r
-        node.ui.removeClass('x-tree-ec-over');\r
-    },\r
-\r
-    onIconClick : function(e, node){\r
-        node.ui.ecClick(e);\r
-    },\r
-\r
-    onCheckboxClick : function(e, node){\r
-        node.ui.onCheckChange(e);\r
-    },\r
-\r
-    onNodeDblClick : function(e, node){\r
-        node.ui.onDblClick(e);\r
-    },\r
-\r
-    onNodeContextMenu : function(e, node){\r
-        node.ui.onContextMenu(e);\r
-    },\r
-\r
-    beforeEvent : function(e){\r
-        var node = this.getNode(e);\r
-        if(this.disabled || !node || !node.ui){\r
-            e.stopEvent();\r
-            return false;\r
-        }\r
-        return true;\r
-    },\r
-\r
-    disable: function(){\r
-        this.disabled = true;\r
-    },\r
-\r
-    enable: function(){\r
-        this.disabled = false;\r
-    }\r
-};</pre>    \r
-</body>\r
+<html>
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
+  <title>The source code</title>
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+</head>
+<body  onload="prettyPrint();">
+    <pre class="prettyprint lang-js">/*!
+ * Ext JS Library 3.2.0
+ * Copyright(c) 2006-2010 Ext JS, Inc.
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+Ext.tree.TreeEventModel = function(tree){
+    this.tree = tree;
+    this.tree.on('render', this.initEvents, this);
+};
+
+Ext.tree.TreeEventModel.prototype = {
+    initEvents : function(){
+        var t = this.tree;
+
+        if(t.trackMouseOver !== false){
+            t.mon(t.innerCt, {
+                scope: this,
+                mouseover: this.delegateOver,
+                mouseout: this.delegateOut
+            });
+        }
+        t.mon(t.getTreeEl(), {
+            scope: this,
+            click: this.delegateClick,
+            dblclick: this.delegateDblClick,
+            contextmenu: this.delegateContextMenu
+        });
+    },
+
+    getNode : function(e){
+        var t;
+        if(t = e.getTarget('.x-tree-node-el', 10)){
+            var id = Ext.fly(t, '_treeEvents').getAttribute('tree-node-id', 'ext');
+            if(id){
+                return this.tree.getNodeById(id);
+            }
+        }
+        return null;
+    },
+
+    getNodeTarget : function(e){
+        var t = e.getTarget('.x-tree-node-icon', 1);
+        if(!t){
+            t = e.getTarget('.x-tree-node-el', 6);
+        }
+        return t;
+    },
+
+    delegateOut : function(e, t){
+        if(!this.beforeEvent(e)){
+            return;
+        }
+        if(e.getTarget('.x-tree-ec-icon', 1)){
+            var n = this.getNode(e);
+            this.onIconOut(e, n);
+            if(n == this.lastEcOver){
+                delete this.lastEcOver;
+            }
+        }
+        if((t = this.getNodeTarget(e)) && !e.within(t, true)){
+            this.onNodeOut(e, this.getNode(e));
+        }
+    },
+
+    delegateOver : function(e, t){
+        if(!this.beforeEvent(e)){
+            return;
+        }
+        if(Ext.isGecko && !this.trackingDoc){ // prevent hanging in FF
+            Ext.getBody().on('mouseover', this.trackExit, this);
+            this.trackingDoc = true;
+        }
+        if(this.lastEcOver){ // prevent hung highlight
+            this.onIconOut(e, this.lastEcOver);
+            delete this.lastEcOver;
+        }
+        if(e.getTarget('.x-tree-ec-icon', 1)){
+            this.lastEcOver = this.getNode(e);
+            this.onIconOver(e, this.lastEcOver);
+        }
+        if(t = this.getNodeTarget(e)){
+            this.onNodeOver(e, this.getNode(e));
+        }
+    },
+
+    trackExit : function(e){
+        if(this.lastOverNode){
+            if(this.lastOverNode.ui && !e.within(this.lastOverNode.ui.getEl())){
+                this.onNodeOut(e, this.lastOverNode);
+            }
+            delete this.lastOverNode;
+            Ext.getBody().un('mouseover', this.trackExit, this);
+            this.trackingDoc = false;
+        }
+
+    },
+
+    delegateClick : function(e, t){
+        if(this.beforeEvent(e)){
+            if(e.getTarget('input[type=checkbox]', 1)){
+                this.onCheckboxClick(e, this.getNode(e));
+            }else if(e.getTarget('.x-tree-ec-icon', 1)){
+                this.onIconClick(e, this.getNode(e));
+            }else if(this.getNodeTarget(e)){
+                this.onNodeClick(e, this.getNode(e));
+            }
+        }else{
+            this.checkContainerEvent(e, 'click');
+        }
+    },
+
+    delegateDblClick : function(e, t){
+        if(this.beforeEvent(e)){
+            if(this.getNodeTarget(e)){
+                this.onNodeDblClick(e, this.getNode(e));
+            }
+        }else{
+            this.checkContainerEvent(e, 'dblclick');
+        }
+    },
+
+    delegateContextMenu : function(e, t){
+        if(this.beforeEvent(e)){
+            if(this.getNodeTarget(e)){
+                this.onNodeContextMenu(e, this.getNode(e));
+            }
+        }else{
+            this.checkContainerEvent(e, 'contextmenu');
+        }
+    },
+    
+    checkContainerEvent: function(e, type){
+        if(this.disabled){
+            e.stopEvent();
+            return false;
+        }
+        this.onContainerEvent(e, type);    
+    },
+
+    onContainerEvent: function(e, type){
+        this.tree.fireEvent('container' + type, this.tree, e);
+    },
+
+    onNodeClick : function(e, node){
+        node.ui.onClick(e);
+    },
+
+    onNodeOver : function(e, node){
+        this.lastOverNode = node;
+        node.ui.onOver(e);
+    },
+
+    onNodeOut : function(e, node){
+        node.ui.onOut(e);
+    },
+
+    onIconOver : function(e, node){
+        node.ui.addClass('x-tree-ec-over');
+    },
+
+    onIconOut : function(e, node){
+        node.ui.removeClass('x-tree-ec-over');
+    },
+
+    onIconClick : function(e, node){
+        node.ui.ecClick(e);
+    },
+
+    onCheckboxClick : function(e, node){
+        node.ui.onCheckChange(e);
+    },
+
+    onNodeDblClick : function(e, node){
+        node.ui.onDblClick(e);
+    },
+
+    onNodeContextMenu : function(e, node){
+        node.ui.onContextMenu(e);
+    },
+
+    beforeEvent : function(e){
+        var node = this.getNode(e);
+        if(this.disabled || !node || !node.ui){
+            e.stopEvent();
+            return false;
+        }
+        return true;
+    },
+
+    disable: function(){
+        this.disabled = true;
+    },
+
+    enable: function(){
+        this.disabled = false;
+    }
+};</pre>    
+</body>
 </html>
\ No newline at end of file
 </html>
\ No newline at end of file