1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
|
<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.4.0
* Copyright(c) 2006-2011 Sencha Inc.
* licensing@sencha.com
* http://www.sencha.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>
|