DragAndDrop_wev8.js
3.15 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
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
/*
Copyright (c) 2004-2005, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
http://dojotoolkit.org/community/licensing.shtml
*/
dojo.require("dojo.lang");
dojo.provide("dojo.dnd.DragSource");
dojo.provide("dojo.dnd.DropTarget");
dojo.provide("dojo.dnd.DragObject");
dojo.provide("dojo.dnd.DragManager");
dojo.provide("dojo.dnd.DragAndDrop");
dojo.dnd.DragSource = function(){
dojo.dnd.dragManager.registerDragSource(this);
}
dojo.lang.extend(dojo.dnd.DragSource, {
type: "",
onDragEnd: function(){
},
onDragStart: function(){
},
unregister: function(){
dojo.dnd.dragManager.unregisterDragSource(this);
},
reregister: function(){
dojo.dnd.dragManager.registerDragSource(this);
}
});
dojo.dnd.DragObject = function(){
dojo.dnd.dragManager.registerDragObject(this);
}
dojo.lang.extend(dojo.dnd.DragObject, {
type: "",
onDragStart: function(){
// gets called directly after being created by the DragSource
// default action is to clone self as icon
},
onDragMove: function(){
// this changes the UI for the drag icon
// "it moves itself"
},
onDragOver: function(){
},
onDragOut: function(){
},
onDragEnd: function(){
},
// normal aliases
onDragLeave: this.onDragOut,
onDragEnter: this.onDragOver,
// non-camel aliases
ondragout: this.onDragOut,
ondragover: this.onDragOver
});
dojo.dnd.DropTarget = function(){
if (this.constructor == dojo.dnd.DropTarget) { return; } // need to be subclassed
dojo.dnd.dragManager.registerDropTarget(this);
}
dojo.lang.extend(dojo.dnd.DropTarget, {
acceptedTypes: [],
onDragOver: function(){
},
onDragOut: function(){
},
onDragMove: function(){
},
onDrop: function(){
}
});
// NOTE: this interface is defined here for the convenience of the DragManager
// implementor. It is expected that in most cases it will be satisfied by
// extending a native event (DOM event in HTML and SVG).
dojo.dnd.DragEvent = function(){
this.dragSource = null;
this.dragObject = null;
this.target = null;
this.eventStatus = "success";
//
// can be one of:
// [ "dropSuccess", "dropFailure", "dragMove",
// "dragStart", "dragEnter", "dragLeave"]
//
}
dojo.dnd.DragManager = function(){
/*
* The DragManager handles listening for low-level events and dispatching
* them to higher-level primitives like drag sources and drop targets. In
* order to do this, it must keep a list of the items.
*/
}
dojo.lang.extend(dojo.dnd.DragManager, {
selectedSources: [],
dragObjects: [],
dragSources: [],
registerDragSource: function(){},
dropTargets: [],
registerDropTarget: function(){},
lastDragTarget: null,
currentDragTarget: null,
onKeyDown: function(){},
onMouseOut: function(){},
onMouseMove: function(){},
onMouseUp: function(){}
});
// NOTE: despite the existance of the DragManager class, there will be a
// singleton drag manager provided by the renderer-specific D&D support code.
// It is therefore sane for us to assign instance variables to the DragManager
// prototype
// The renderer-specific file will define the following object:
dojo.dnd.dragManager = null;