Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
if(!dojo._hasResource["dijit._tree.dndContainer"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2
dojo._hasResource["dijit._tree.dndContainer"] = true;
3
dojo.provide("dijit._tree.dndContainer");
4
dojo.require("dojo.dnd.common");
5
dojo.require("dojo.dnd.Container");
6
 
7
dojo.declare("dijit._tree.dndContainer",
8
	null,
9
	{
10
		constructor: function(tree, params){
11
			// summary: a constructor of the Container
12
			// tree: Node: node or node's id to build the container on
13
			// params: Object: a dict of parameters, which gets mixed into the object
14
			this.tree = tree;
15
			this.node = tree.domNode;
16
			dojo.mixin(this, params);
17
 
18
			// class-specific variables
19
			this.map = {};
20
			this.current = null;
21
 
22
			// states
23
			this.ContainerState = "";
24
			dojo.addClass(this.node, "dojoDndContainer");
25
 
26
			// mark up children
27
			if(!(params && params._skipStartup)){
28
				this.startup();
29
			}
30
 
31
			// set up events
32
			this.events = [
33
				dojo.connect(this.node, "onmouseover", this, "onMouseOver"),
34
				dojo.connect(this.node, "onmouseout",  this, "onMouseOut"),
35
 
36
				// cancel text selection and text dragging
37
				dojo.connect(this.node, "ondragstart",   dojo, "stopEvent"),
38
				dojo.connect(this.node, "onselectstart", dojo, "stopEvent")
39
			];
40
		},
41
 
42
 
43
		// abstract access to the map
44
		getItem: function(/*String*/ key){
45
			// summary: returns a data item by its key (id)
46
			//console.log("Container getItem()", arguments,this.map, this.map[key], this.selection[key]);
47
			return this.selection[key];
48
			//return this.map[key];	// Object
49
		},
50
 
51
		// mouse events
52
		onMouseOver: function(e){
53
			// summary: event processor for onmouseover
54
			// e: Event: mouse event
55
			var n = e.relatedTarget;
56
			while(n){
57
				if(n == this.node){ break; }
58
				try{
59
					n = n.parentNode;
60
				}catch(x){
61
					n = null;
62
				}
63
			}
64
			if(!n){
65
				this._changeState("Container", "Over");
66
				this.onOverEvent();
67
			}
68
			n = this._getChildByEvent(e);
69
			if(this.current == n){ return; }
70
			if(this.current){ this._removeItemClass(this.current, "Over"); }
71
			if(n){ this._addItemClass(n, "Over"); }
72
			this.current = n;
73
		},
74
 
75
		onMouseOut: function(e){
76
			// summary: event processor for onmouseout
77
			// e: Event: mouse event
78
			for(var n = e.relatedTarget; n;){
79
				if(n == this.node){ return; }
80
				try{
81
					n = n.parentNode;
82
				}catch(x){
83
					n = null;
84
				}
85
			}
86
			if(this.current){
87
				this._removeItemClass(this.current, "Over");
88
				this.current = null;
89
			}
90
			this._changeState("Container", "");
91
			this.onOutEvent();
92
		},
93
 
94
		_changeState: function(type, newState){
95
			// summary: changes a named state to new state value
96
			// type: String: a name of the state to change
97
			// newState: String: new state
98
			var prefix = "dojoDnd" + type;
99
			var state  = type.toLowerCase() + "State";
100
			//dojo.replaceClass(this.node, prefix + newState, prefix + this[state]);
101
			dojo.removeClass(this.node, prefix + this[state]);
102
			dojo.addClass(this.node, prefix + newState);
103
			this[state] = newState;
104
		},
105
 
106
                _getChildByEvent: function(e){
107
                        // summary: gets a child, which is under the mouse at the moment, or null
108
                        // e: Event: a mouse event
109
                        var node = e.target;
110
 
111
                        if (node && dojo.hasClass(node,"dijitTreeLabel")){
112
                                return node;
113
                        }
114
                        return null;
115
                },
116
 
117
		markupFactory: function(tree, params){
118
			params._skipStartup = true;
119
			return new dijit._tree.dndContainer(tree, params);
120
		},
121
 
122
		_addItemClass: function(node, type){
123
			// summary: adds a class with prefix "dojoDndItem"
124
			// node: Node: a node
125
			// type: String: a variable suffix for a class name
126
			dojo.addClass(node, "dojoDndItem" + type);
127
		},
128
 
129
		_removeItemClass: function(node, type){
130
			// summary: removes a class with prefix "dojoDndItem"
131
			// node: Node: a node
132
			// type: String: a variable suffix for a class name
133
			dojo.removeClass(node, "dojoDndItem" + type);
134
		},
135
 
136
		onOverEvent: function(){
137
			// summary: this function is called once, when mouse is over our container
138
			console.log("onOverEvent parent");
139
		},
140
 
141
		onOutEvent: function(){
142
			// summary: this function is called once, when mouse is out of our container
143
		}
144
});
145
 
146
}