3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
15 Ext.tree.TreeEventModel = function(tree){
17 this.tree.on('render', this.initEvents, this);
20 Ext.tree.TreeEventModel.prototype = {
21 initEvents : function(){
24 if(t.trackMouseOver !== false){
27 mouseover: this.delegateOver,
28 mouseout: this.delegateOut
31 t.mon(t.getTreeEl(), {
33 click: this.delegateClick,
34 dblclick: this.delegateDblClick,
35 contextmenu: this.delegateContextMenu
39 getNode : function(e){
41 if(t = e.getTarget('.x-tree-node-el', 10)){
42 var id = Ext.fly(t, '_treeEvents').getAttribute('tree-node-id', 'ext');
44 return this.tree.getNodeById(id);
50 getNodeTarget : function(e){
51 var t = e.getTarget('.x-tree-node-icon', 1);
53 t = e.getTarget('.x-tree-node-el', 6);
58 delegateOut : function(e, t){
59 if(!this.beforeEvent(e)){
62 if(e.getTarget('.x-tree-ec-icon', 1)){
63 var n = this.getNode(e);
65 if(n == this.lastEcOver){
66 delete this.lastEcOver;
69 if((t = this.getNodeTarget(e)) && !e.within(t, true)){
70 this.onNodeOut(e, this.getNode(e));
74 delegateOver : function(e, t){
75 if(!this.beforeEvent(e)){
78 if(Ext.isGecko && !this.trackingDoc){ // prevent hanging in FF
79 Ext.getBody().on('mouseover', this.trackExit, this);
80 this.trackingDoc = true;
82 if(this.lastEcOver){ // prevent hung highlight
83 this.onIconOut(e, this.lastEcOver);
84 delete this.lastEcOver;
86 if(e.getTarget('.x-tree-ec-icon', 1)){
87 this.lastEcOver = this.getNode(e);
88 this.onIconOver(e, this.lastEcOver);
90 if(t = this.getNodeTarget(e)){
91 this.onNodeOver(e, this.getNode(e));
95 trackExit : function(e){
96 if(this.lastOverNode){
97 if(this.lastOverNode.ui && !e.within(this.lastOverNode.ui.getEl())){
98 this.onNodeOut(e, this.lastOverNode);
100 delete this.lastOverNode;
101 Ext.getBody().un('mouseover', this.trackExit, this);
102 this.trackingDoc = false;
107 delegateClick : function(e, t){
108 if(this.beforeEvent(e)){
109 if(e.getTarget('input[type=checkbox]', 1)){
110 this.onCheckboxClick(e, this.getNode(e));
111 }else if(e.getTarget('.x-tree-ec-icon', 1)){
112 this.onIconClick(e, this.getNode(e));
113 }else if(this.getNodeTarget(e)){
114 this.onNodeClick(e, this.getNode(e));
117 this.checkContainerEvent(e, 'click');
121 delegateDblClick : function(e, t){
122 if(this.beforeEvent(e)){
123 if(this.getNodeTarget(e)){
124 this.onNodeDblClick(e, this.getNode(e));
127 this.checkContainerEvent(e, 'dblclick');
131 delegateContextMenu : function(e, t){
132 if(this.beforeEvent(e)){
133 if(this.getNodeTarget(e)){
134 this.onNodeContextMenu(e, this.getNode(e));
137 this.checkContainerEvent(e, 'contextmenu');
141 checkContainerEvent: function(e, type){
146 this.onContainerEvent(e, type);
149 onContainerEvent: function(e, type){
150 this.tree.fireEvent('container' + type, this.tree, e);
153 onNodeClick : function(e, node){
157 onNodeOver : function(e, node){
158 this.lastOverNode = node;
162 onNodeOut : function(e, node){
166 onIconOver : function(e, node){
167 node.ui.addClass('x-tree-ec-over');
170 onIconOut : function(e, node){
171 node.ui.removeClass('x-tree-ec-over');
174 onIconClick : function(e, node){
178 onCheckboxClick : function(e, node){
179 node.ui.onCheckChange(e);
182 onNodeDblClick : function(e, node){
183 node.ui.onDblClick(e);
186 onNodeContextMenu : function(e, node){
187 node.ui.onContextMenu(e);
190 beforeEvent : function(e){
191 var node = this.getNode(e);
192 if(this.disabled || !node || !node.ui){
200 this.disabled = true;
204 this.disabled = false;