3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">Ext.tree.TreeEventModel = function(tree){
\r
10 this.tree.on('render', this.initEvents, this);
\r
13 Ext.tree.TreeEventModel.prototype = {
\r
14 initEvents : function(){
\r
15 var el = this.tree.getTreeEl();
\r
16 el.on('click', this.delegateClick, this);
\r
17 if(this.tree.trackMouseOver !== false){
\r
18 this.tree.innerCt.on('mouseover', this.delegateOver, this);
\r
19 this.tree.innerCt.on('mouseout', this.delegateOut, this);
\r
21 el.on('dblclick', this.delegateDblClick, this);
\r
22 el.on('contextmenu', this.delegateContextMenu, this);
\r
25 getNode : function(e){
\r
27 if(t = e.getTarget('.x-tree-node-el', 10)){
\r
28 var id = Ext.fly(t, '_treeEvents').getAttribute('tree-node-id', 'ext');
\r
30 return this.tree.getNodeById(id);
\r
36 getNodeTarget : function(e){
\r
37 var t = e.getTarget('.x-tree-node-icon', 1);
\r
39 t = e.getTarget('.x-tree-node-el', 6);
\r
44 delegateOut : function(e, t){
\r
45 if(!this.beforeEvent(e)){
\r
48 if(e.getTarget('.x-tree-ec-icon', 1)){
\r
49 var n = this.getNode(e);
\r
50 this.onIconOut(e, n);
\r
51 if(n == this.lastEcOver){
\r
52 delete this.lastEcOver;
\r
55 if((t = this.getNodeTarget(e)) && !e.within(t, true)){
\r
56 this.onNodeOut(e, this.getNode(e));
\r
60 delegateOver : function(e, t){
\r
61 if(!this.beforeEvent(e)){
\r
64 if(Ext.isGecko && !this.trackingDoc){ // prevent hanging in FF
\r
65 Ext.getBody().on('mouseover', this.trackExit, this);
\r
66 this.trackingDoc = true;
\r
68 if(this.lastEcOver){ // prevent hung highlight
\r
69 this.onIconOut(e, this.lastEcOver);
\r
70 delete this.lastEcOver;
\r
72 if(e.getTarget('.x-tree-ec-icon', 1)){
\r
73 this.lastEcOver = this.getNode(e);
\r
74 this.onIconOver(e, this.lastEcOver);
\r
76 if(t = this.getNodeTarget(e)){
\r
77 this.onNodeOver(e, this.getNode(e));
\r
81 trackExit : function(e){
\r
82 if(this.lastOverNode && !e.within(this.lastOverNode.ui.getEl())){
\r
83 this.onNodeOut(e, this.lastOverNode);
\r
84 delete this.lastOverNode;
\r
85 Ext.getBody().un('mouseover', this.trackExit, this);
\r
86 this.trackingDoc = false;
\r
90 delegateClick : function(e, t){
\r
91 if(!this.beforeEvent(e)){
\r
95 if(e.getTarget('input[type=checkbox]', 1)){
\r
96 this.onCheckboxClick(e, this.getNode(e));
\r
98 else if(e.getTarget('.x-tree-ec-icon', 1)){
\r
99 this.onIconClick(e, this.getNode(e));
\r
101 else if(this.getNodeTarget(e)){
\r
102 this.onNodeClick(e, this.getNode(e));
\r
106 delegateDblClick : function(e, t){
\r
107 if(this.beforeEvent(e) && this.getNodeTarget(e)){
\r
108 this.onNodeDblClick(e, this.getNode(e));
\r
112 delegateContextMenu : function(e, t){
\r
113 if(this.beforeEvent(e) && this.getNodeTarget(e)){
\r
114 this.onNodeContextMenu(e, this.getNode(e));
\r
118 onNodeClick : function(e, node){
\r
119 node.ui.onClick(e);
\r
122 onNodeOver : function(e, node){
\r
123 this.lastOverNode = node;
\r
127 onNodeOut : function(e, node){
\r
131 onIconOver : function(e, node){
\r
132 node.ui.addClass('x-tree-ec-over');
\r
135 onIconOut : function(e, node){
\r
136 node.ui.removeClass('x-tree-ec-over');
\r
139 onIconClick : function(e, node){
\r
140 node.ui.ecClick(e);
\r
143 onCheckboxClick : function(e, node){
\r
144 node.ui.onCheckChange(e);
\r
147 onNodeDblClick : function(e, node){
\r
148 node.ui.onDblClick(e);
\r
151 onNodeContextMenu : function(e, node){
\r
152 node.ui.onContextMenu(e);
\r
155 beforeEvent : function(e){
\r
163 disable: function(){
\r
164 this.disabled = true;
\r
167 enable: function(){
\r
168 this.disabled = false;
\r