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
|
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
dojo._xdResourceLoaded(function(dojo, dijit, dojox){
return {depends: [["provide", "dojox.mdnd.LazyManager"],
["require", "dojo.dnd.Manager"],
["require", "dojox.mdnd.PureSource"]],
defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.mdnd.LazyManager"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.mdnd.LazyManager"] = true;
dojo.provide("dojox.mdnd.LazyManager");
dojo.require("dojo.dnd.Manager");
dojo.require("dojox.mdnd.PureSource");
dojo.declare(
"dojox.mdnd.LazyManager",
null,
{
// summary:
// This class allows to launch a drag and drop dojo on the fly.
constructor: function(){
//console.log("dojox.mdnd.LazyManager ::: constructor");
this._registry = {};
// initialization of the _fakeSource to enabled DragAndDrop :
this._fakeSource = new dojox.mdnd.PureSource(dojo.create("div"), {
'copyOnly': false
});
this._fakeSource.startup();
dojo.addOnUnload(dojo.hitch(this, "destroy"));
this.manager = dojo.dnd.manager();
},
getItem: function(/*DOMNode*/draggedNode){
//console.log("dojox.mdnd.LazyManager ::: getItem");
var type = draggedNode.getAttribute("dndType");
return {
'data' : draggedNode.getAttribute("dndData") || draggedNode.innerHTML,
'type' : type ? type.split(/\s*,\s*/) : ["text"]
}
},
startDrag: function(/*Event*/e, /*DOMNode?*/draggedNode){
// summary:
// launch a dojo drag and drop on the fly.
//console.log("dojox.mdnd.LazyManager ::: startDrag");
draggedNode = draggedNode || e.target;
if(draggedNode){
var m = this.manager,
object = this.getItem(draggedNode);
if(draggedNode.id == ""){
dojo.attr(draggedNode, "id", dojo.dnd.getUniqueId());
}
dojo.addClass(draggedNode, "dojoDndItem");
this._fakeSource.setItem(draggedNode.id, object);
m.startDrag(this._fakeSource, [draggedNode], false);
m.onMouseMove(e);
}
},
cancelDrag: function(){
// summary:
// cancel a drag and drop dojo on the fly.
//console.log("dojox.mdnd.LazyManager ::: cancelDrag");
var m = this.manager;
m.target = null;
m.onMouseUp();
},
destroy: function(){
//console.log("dojox.mdnd.LazyManager ::: destroy");
this._fakeSource.destroy();
}
});
}
}};});
|