3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
14 Ext.tree.TreeEventModel = function(tree){
\r
16 this.tree.on('render', this.initEvents, this);
\r
19 Ext.tree.TreeEventModel.prototype = {
\r
20 initEvents : function(){
\r
23 if(t.trackMouseOver !== false){
\r
26 mouseover: this.delegateOver,
\r
27 mouseout: this.delegateOut
\r
30 t.mon(t.getTreeEl(), {
\r
32 click: this.delegateClick,
\r
33 dblclick: this.delegateDblClick,
\r
34 contextmenu: this.delegateContextMenu
\r
38 getNode : function(e){
\r
40 if(t = e.getTarget('.x-tree-node-el', 10)){
\r
41 var id = Ext.fly(t, '_treeEvents').getAttribute('tree-node-id', 'ext');
\r
43 return this.tree.getNodeById(id);
\r
49 getNodeTarget : function(e){
\r
50 var t = e.getTarget('.x-tree-node-icon', 1);
\r
52 t = e.getTarget('.x-tree-node-el', 6);
\r
57 delegateOut : function(e, t){
\r
58 if(!this.beforeEvent(e)){
\r
61 if(e.getTarget('.x-tree-ec-icon', 1)){
\r
62 var n = this.getNode(e);
\r
63 this.onIconOut(e, n);
\r
64 if(n == this.lastEcOver){
\r
65 delete this.lastEcOver;
\r
68 if((t = this.getNodeTarget(e)) && !e.within(t, true)){
\r
69 this.onNodeOut(e, this.getNode(e));
\r
73 delegateOver : function(e, t){
\r
74 if(!this.beforeEvent(e)){
\r
77 if(Ext.isGecko && !this.trackingDoc){ // prevent hanging in FF
\r
78 Ext.getBody().on('mouseover', this.trackExit, this);
\r
79 this.trackingDoc = true;
\r
81 if(this.lastEcOver){ // prevent hung highlight
\r
82 this.onIconOut(e, this.lastEcOver);
\r
83 delete this.lastEcOver;
\r
85 if(e.getTarget('.x-tree-ec-icon', 1)){
\r
86 this.lastEcOver = this.getNode(e);
\r
87 this.onIconOver(e, this.lastEcOver);
\r
89 if(t = this.getNodeTarget(e)){
\r
90 this.onNodeOver(e, this.getNode(e));
\r
94 trackExit : function(e){
\r
95 if(this.lastOverNode && !e.within(this.lastOverNode.ui.getEl())){
\r
96 this.onNodeOut(e, this.lastOverNode);
\r
97 delete this.lastOverNode;
\r
98 Ext.getBody().un('mouseover', this.trackExit, this);
\r
99 this.trackingDoc = false;
\r
103 delegateClick : function(e, t){
\r
104 if(!this.beforeEvent(e)){
\r
108 if(e.getTarget('input[type=checkbox]', 1)){
\r
109 this.onCheckboxClick(e, this.getNode(e));
\r
111 else if(e.getTarget('.x-tree-ec-icon', 1)){
\r
112 this.onIconClick(e, this.getNode(e));
\r
114 else if(this.getNodeTarget(e)){
\r
115 this.onNodeClick(e, this.getNode(e));
\r
119 delegateDblClick : function(e, t){
\r
120 if(this.beforeEvent(e) && this.getNodeTarget(e)){
\r
121 this.onNodeDblClick(e, this.getNode(e));
\r
125 delegateContextMenu : function(e, t){
\r
126 if(this.beforeEvent(e) && this.getNodeTarget(e)){
\r
127 this.onNodeContextMenu(e, this.getNode(e));
\r
131 onNodeClick : function(e, node){
\r
132 node.ui.onClick(e);
\r
135 onNodeOver : function(e, node){
\r
136 this.lastOverNode = node;
\r
140 onNodeOut : function(e, node){
\r
144 onIconOver : function(e, node){
\r
145 node.ui.addClass('x-tree-ec-over');
\r
148 onIconOut : function(e, node){
\r
149 node.ui.removeClass('x-tree-ec-over');
\r
152 onIconClick : function(e, node){
\r
153 node.ui.ecClick(e);
\r
156 onCheckboxClick : function(e, node){
\r
157 node.ui.onCheckChange(e);
\r
160 onNodeDblClick : function(e, node){
\r
161 node.ui.onDblClick(e);
\r
164 onNodeContextMenu : function(e, node){
\r
165 node.ui.onContextMenu(e);
\r
168 beforeEvent : function(e){
\r
176 disable: function(){
\r
177 this.disabled = true;
\r
180 enable: function(){
\r
181 this.disabled = false;
\r