source: trunk/web/addons/job_monarch/lib/extjs/source/widgets/tree/TreeEventModel.js @ 619

Last change on this file since 619 was 619, checked in by ramonb, 15 years ago

lib/:

  • added new AJAX dependancies: ExtJS, pChart, Lightbox2
File size: 4.0 KB
Line 
1/*
2 * Ext JS Library 2.2.1
3 * Copyright(c) 2006-2009, Ext JS, LLC.
4 * licensing@extjs.com
5 *
6 * http://extjs.com/license
7 */
8
9Ext.tree.TreeEventModel = function(tree){
10    this.tree = tree;
11    this.tree.on('render', this.initEvents, this);
12}
13
14Ext.tree.TreeEventModel.prototype = {
15    initEvents : function(){
16        var el = this.tree.getTreeEl();
17        el.on('click', this.delegateClick, this);
18        if(this.tree.trackMouseOver !== false){
19            el.on('mouseover', this.delegateOver, this);
20            el.on('mouseout', this.delegateOut, this);
21        }
22        el.on('dblclick', this.delegateDblClick, this);
23        el.on('contextmenu', this.delegateContextMenu, this);
24    },
25
26    getNode : function(e){
27        var t;
28        if(t = e.getTarget('.x-tree-node-el', 10)){
29            var id = Ext.fly(t, '_treeEvents').getAttributeNS('ext', 'tree-node-id');
30            if(id){
31                return this.tree.getNodeById(id);
32            }
33        }
34        return null;
35    },
36
37    getNodeTarget : function(e){
38        var t = e.getTarget('.x-tree-node-icon', 1);
39        if(!t){
40            t = e.getTarget('.x-tree-node-el', 6);
41        }
42        return t;
43    },
44
45    delegateOut : function(e, t){
46        if(!this.beforeEvent(e)){
47            return;
48        }
49        if(e.getTarget('.x-tree-ec-icon', 1)){
50            var n = this.getNode(e);
51            this.onIconOut(e, n);
52            if(n == this.lastEcOver){
53                delete this.lastEcOver;
54            }
55        }
56        if((t = this.getNodeTarget(e)) && !e.within(t, true)){
57            this.onNodeOut(e, this.getNode(e));
58        }
59    },
60
61    delegateOver : function(e, t){
62        if(!this.beforeEvent(e)){
63            return;
64        }
65        if(this.lastEcOver){ // prevent hung highlight
66            this.onIconOut(e, this.lastEcOver);
67            delete this.lastEcOver;
68        }
69        if(e.getTarget('.x-tree-ec-icon', 1)){
70            this.lastEcOver = this.getNode(e);
71            this.onIconOver(e, this.lastEcOver);
72        }
73        if(t = this.getNodeTarget(e)){
74            this.onNodeOver(e, this.getNode(e));
75        }
76    },
77
78    delegateClick : function(e, t){
79        if(!this.beforeEvent(e)){
80            return;
81        }
82
83        if(e.getTarget('input[type=checkbox]', 1)){
84            this.onCheckboxClick(e, this.getNode(e));
85        }
86        else if(e.getTarget('.x-tree-ec-icon', 1)){
87            this.onIconClick(e, this.getNode(e));
88        }
89        else if(this.getNodeTarget(e)){
90            this.onNodeClick(e, this.getNode(e));
91        }
92    },
93
94    delegateDblClick : function(e, t){
95        if(this.beforeEvent(e) && this.getNodeTarget(e)){
96            this.onNodeDblClick(e, this.getNode(e));
97        }
98    },
99
100    delegateContextMenu : function(e, t){
101        if(this.beforeEvent(e) && this.getNodeTarget(e)){
102            this.onNodeContextMenu(e, this.getNode(e));
103        }
104    },
105
106    onNodeClick : function(e, node){
107        node.ui.onClick(e);
108    },
109
110    onNodeOver : function(e, node){
111        node.ui.onOver(e);
112    },
113
114    onNodeOut : function(e, node){
115        node.ui.onOut(e);
116    },
117
118    onIconOver : function(e, node){
119        node.ui.addClass('x-tree-ec-over');
120    },
121
122    onIconOut : function(e, node){
123        node.ui.removeClass('x-tree-ec-over');
124    },
125
126    onIconClick : function(e, node){
127        node.ui.ecClick(e);
128    },
129
130    onCheckboxClick : function(e, node){
131        node.ui.onCheckChange(e);
132    },
133
134    onNodeDblClick : function(e, node){
135        node.ui.onDblClick(e);
136    },
137
138    onNodeContextMenu : function(e, node){
139        node.ui.onContextMenu(e);
140    },
141
142    beforeEvent : function(e){
143        if(this.disabled){
144            e.stopEvent();
145            return false;
146        }
147        return true;
148    },
149
150    disable: function(){
151        this.disabled = true;
152    },
153
154    enable: function(){
155        this.disabled = false;
156    }
157};
Note: See TracBrowser for help on using the repository browser.