-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDropIndicator.js
More file actions
98 lines (87 loc) · 2.36 KB
/
Copy pathDropIndicator.js
File metadata and controls
98 lines (87 loc) · 2.36 KB
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
define(["dojo/_base/kernel",
"dojo/_base/declare",
"dojo/dom-class",
"dojo/dom-construct",
"./AreaManager"
], function(dojo, declare, domClass, domConstruct){
var di = declare(
"smdnd.DropIndicator",
null,
{
// summary:
// DropIndicator managment for DnD.
// node: DOMNode
// the drop indicator node
node : null,
constructor: function(){
//console.log("smdnd.DropIndicator ::: constructor");
var dropIndicator = document.createElement("div");
var subDropIndicator = document.createElement("div");
dropIndicator.appendChild(subDropIndicator);
domClass.add(dropIndicator, "dropIndicator");
this.node = dropIndicator;
},
place: function(/*Node*/area, /*Node*/nodeRef, /*Object*/size){
// summary:
// Place the DropIndicator in the right place
// area:
// the dnd targer area node
// nodeRef:
// node where the dropIndicator have to be placed into the area
// dragNode:
// the node which is dragged
// returns:
// the node inserted or null if it crashes
//console.log("smdnd.DropIndicator ::: place");
if(size){
this.node.style.height = size.h + "px";
}
try{
//bedits --
var currentDropArea = this.node.parentNode;
currentDropArea && domClass.remove(currentDropArea,"drop-target-area");
// -- bedits
if(nodeRef){
area.insertBefore(this.node, nodeRef);
}
else{
// empty target area or last node => appendChild
area.appendChild(this.node);
}
// bedits --
domClass.add(area,"drop-target-area");
// -- bedits
return this.node; // DOMNode
}catch(e){
return null;
}
},
remove: function(){
// summary:
// remove the DropIndicator (not destroy)
//console.log("smdnd.DropIndicator ::: remove");
if(this.node){
//FIX : IE6 problem
this.node.style.height = "";
if(this.node.parentNode){
domClass.remove(this.node.parentNode,"drop-target-area");
this.node.parentNode.removeChild(this.node);
}
}
},
destroy: function(){
// summary:
// destroy the dropIndicator
//console.log("smdnd.DropIndicator ::: destroy");
if(this.node){
if(this.node.parentNode){
this.node.parentNode.removeChild(this.node);
}
domConstruct.destroy(this.node);
delete this.node;
}
}
});
smdnd.areaManager()._dropIndicator = new smdnd.DropIndicator();
return di;
});