3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js">Ext.tree.TreeEventModel = function(tree){
\r
11 this.tree.on('render', this.initEvents, this);
\r
14 Ext.tree.TreeEventModel.prototype = {
\r
15 initEvents : function(){
\r
18 if(t.trackMouseOver !== false){
\r
21 mouseover: this.delegateOver,
\r
22 mouseout: this.delegateOut
\r
25 t.mon(t.getTreeEl(), {
\r
27 click: this.delegateClick,
\r
28 dblclick: this.delegateDblClick,
\r
29 contextmenu: this.delegateContextMenu
\r
33 getNode : function(e){
\r
35 if(t = e.getTarget('.x-tree-node-el', 10)){
\r
36 var id = Ext.fly(t, '_treeEvents').getAttribute('tree-node-id', 'ext');
\r
38 return this.tree.getNodeById(id);
\r
44 getNodeTarget : function(e){
\r
45 var t = e.getTarget('.x-tree-node-icon', 1);
\r
47 t = e.getTarget('.x-tree-node-el', 6);
\r
52 delegateOut : function(e, t){
\r
53 if(!this.beforeEvent(e)){
\r
56 if(e.getTarget('.x-tree-ec-icon', 1)){
\r
57 var n = this.getNode(e);
\r
58 this.onIconOut(e, n);
\r
59 if(n == this.lastEcOver){
\r
60 delete this.lastEcOver;
\r
63 if((t = this.getNodeTarget(e)) && !e.within(t, true)){
\r
64 this.onNodeOut(e, this.getNode(e));
\r
68 delegateOver : function(e, t){
\r
69 if(!this.beforeEvent(e)){
\r
72 if(Ext.isGecko && !this.trackingDoc){ // prevent hanging in FF
\r
73 Ext.getBody().on('mouseover', this.trackExit, this);
\r
74 this.trackingDoc = true;
\r
76 if(this.lastEcOver){ // prevent hung highlight
\r
77 this.onIconOut(e, this.lastEcOver);
\r
78 delete this.lastEcOver;
\r
80 if(e.getTarget('.x-tree-ec-icon', 1)){
\r
81 this.lastEcOver = this.getNode(e);
\r
82 this.onIconOver(e, this.lastEcOver);
\r
84 if(t = this.getNodeTarget(e)){
\r
85 this.onNodeOver(e, this.getNode(e));
\r
89 trackExit : function(e){
\r
90 if(this.lastOverNode && !e.within(this.lastOverNode.ui.getEl())){
\r
91 this.onNodeOut(e, this.lastOverNode);
\r
92 delete this.lastOverNode;
\r
93 Ext.getBody().un('mouseover', this.trackExit, this);
\r
94 this.trackingDoc = false;
\r
98 delegateClick : function(e, t){
\r
99 if(this.beforeEvent(e)){
\r
100 if(e.getTarget('input[type=checkbox]', 1)){
\r
101 this.onCheckboxClick(e, this.getNode(e));
\r
102 }else if(e.getTarget('.x-tree-ec-icon', 1)){
\r
103 this.onIconClick(e, this.getNode(e));
\r
104 }else if(this.getNodeTarget(e)){
\r
105 this.onNodeClick(e, this.getNode(e));
\r
107 this.onContainerEvent(e, 'click');
\r
112 delegateDblClick : function(e, t){
\r
113 if(this.beforeEvent(e)){
\r
114 if(this.getNodeTarget(e)){
\r
115 this.onNodeDblClick(e, this.getNode(e));
\r
117 this.onContainerEvent(e, 'dblclick');
\r
122 delegateContextMenu : function(e, t){
\r
123 if(this.beforeEvent(e)){
\r
124 if(this.getNodeTarget(e)){
\r
125 this.onNodeContextMenu(e, this.getNode(e));
\r
127 this.onContainerEvent(e, 'contextmenu');
\r
132 onContainerEvent: function(e, type){
\r
133 this.tree.fireEvent('container' + type, this.tree, e);
\r
136 onNodeClick : function(e, node){
\r
137 node.ui.onClick(e);
\r
140 onNodeOver : function(e, node){
\r
141 this.lastOverNode = node;
\r
145 onNodeOut : function(e, node){
\r
149 onIconOver : function(e, node){
\r
150 node.ui.addClass('x-tree-ec-over');
\r
153 onIconOut : function(e, node){
\r
154 node.ui.removeClass('x-tree-ec-over');
\r
157 onIconClick : function(e, node){
\r
158 node.ui.ecClick(e);
\r
161 onCheckboxClick : function(e, node){
\r
162 node.ui.onCheckChange(e);
\r
165 onNodeDblClick : function(e, node){
\r
166 node.ui.onDblClick(e);
\r
169 onNodeContextMenu : function(e, node){
\r
170 node.ui.onContextMenu(e);
\r
173 beforeEvent : function(e){
\r
181 disable: function(){
\r
182 this.disabled = true;
\r
185 enable: function(){
\r
186 this.disabled = false;
\r