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){
\r
91 if(this.lastOverNode.ui && !e.within(this.lastOverNode.ui.getEl())){
\r
92 this.onNodeOut(e, this.lastOverNode);
\r
94 delete this.lastOverNode;
\r
95 Ext.getBody().un('mouseover', this.trackExit, this);
\r
96 this.trackingDoc = false;
\r
101 delegateClick : function(e, t){
\r
102 if(this.beforeEvent(e)){
\r
103 if(e.getTarget('input[type=checkbox]', 1)){
\r
104 this.onCheckboxClick(e, this.getNode(e));
\r
105 }else if(e.getTarget('.x-tree-ec-icon', 1)){
\r
106 this.onIconClick(e, this.getNode(e));
\r
107 }else if(this.getNodeTarget(e)){
\r
108 this.onNodeClick(e, this.getNode(e));
\r
110 this.onContainerEvent(e, 'click');
\r
115 delegateDblClick : function(e, t){
\r
116 if(this.beforeEvent(e)){
\r
117 if(this.getNodeTarget(e)){
\r
118 this.onNodeDblClick(e, this.getNode(e));
\r
120 this.onContainerEvent(e, 'dblclick');
\r
125 delegateContextMenu : function(e, t){
\r
126 if(this.beforeEvent(e)){
\r
127 if(this.getNodeTarget(e)){
\r
128 this.onNodeContextMenu(e, this.getNode(e));
\r
130 this.onContainerEvent(e, 'contextmenu');
\r
135 onContainerEvent: function(e, type){
\r
136 this.tree.fireEvent('container' + type, this.tree, e);
\r
139 onNodeClick : function(e, node){
\r
140 node.ui.onClick(e);
\r
143 onNodeOver : function(e, node){
\r
144 this.lastOverNode = node;
\r
148 onNodeOut : function(e, node){
\r
152 onIconOver : function(e, node){
\r
153 node.ui.addClass('x-tree-ec-over');
\r
156 onIconOut : function(e, node){
\r
157 node.ui.removeClass('x-tree-ec-over');
\r
160 onIconClick : function(e, node){
\r
161 node.ui.ecClick(e);
\r
164 onCheckboxClick : function(e, node){
\r
165 node.ui.onCheckChange(e);
\r
168 onNodeDblClick : function(e, node){
\r
169 node.ui.onDblClick(e);
\r
172 onNodeContextMenu : function(e, node){
\r
173 node.ui.onContextMenu(e);
\r
176 beforeEvent : function(e){
\r
177 var node = this.getNode(e);
\r
178 if(this.disabled || !node || !node.ui){
\r
185 disable: function(){
\r
186 this.disabled = true;
\r
189 enable: function(){
\r
190 this.disabled = false;
\r