]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/dnd/Manager.js
2 Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3 Available via Academic Free License >= 2.1 OR the modified BSD license.
4 see: http://dojotoolkit.org/license for details
8 if(!dojo
._hasResource
["dojo.dnd.Manager"]){
9 dojo
._hasResource
["dojo.dnd.Manager"]=true;
10 dojo
.provide("dojo.dnd.Manager");
11 dojo
.require("dojo.dnd.common");
12 dojo
.require("dojo.dnd.autoscroll");
13 dojo
.require("dojo.dnd.Avatar");
14 dojo
.declare("dojo.dnd.Manager",null,{constructor:function(){
20 this.canDropFlag
=false;
22 },OFFSET_X
:16,OFFSET_Y
:16,overSource:function(_1
){
24 this.target
=(_1
&&_1
.targetState
!="Disabled")?_1
:null;
25 this.canDropFlag
=Boolean(this.target
);
28 dojo
.publish("/dnd/source/over",[_1
]);
29 },outSource:function(_2
){
33 this.canDropFlag
=false;
35 dojo
.publish("/dnd/source/over",[null]);
38 dojo
.publish("/dnd/source/over",[null]);
40 },startDrag:function(_3
,_4
,_5
){
43 this.copy
=Boolean(_5
);
44 this.avatar
=this.makeAvatar();
45 dojo
.body().appendChild(this.avatar
.node
);
46 dojo
.publish("/dnd/start",[_3
,_4
,this.copy
]);
47 this.events
=[dojo
.connect(dojo
.doc
,"onmousemove",this,"onMouseMove"),dojo
.connect(dojo
.doc
,"onmouseup",this,"onMouseUp"),dojo
.connect(dojo
.doc
,"onkeydown",this,"onKeyDown"),dojo
.connect(dojo
.doc
,"onkeyup",this,"onKeyUp"),dojo
.connect(dojo
.doc
,"ondragstart",dojo
.stopEvent
),dojo
.connect(dojo
.body(),"onselectstart",dojo
.stopEvent
)];
48 var c
="dojoDnd"+(_5
?"Copy":"Move");
49 dojo
.addClass(dojo
.body(),c
);
50 },canDrop:function(_6
){
51 var _7
=Boolean(this.target
&&_6
);
52 if(this.canDropFlag
!=_7
){
56 },stopDrag:function(){
57 dojo
.removeClass(dojo
.body(),"dojoDndCopy");
58 dojo
.removeClass(dojo
.body(),"dojoDndMove");
59 dojo
.forEach(this.events
,dojo
.disconnect
);
61 this.avatar
.destroy();
63 this.source
=this.target
=null;
65 },makeAvatar:function(){
66 return new dojo
.dnd
.Avatar(this);
67 },updateAvatar:function(){
69 },onMouseMove:function(e
){
72 dojo
.dnd
.autoScrollNodes(e
);
74 s
.left
=(e
.pageX
+this.OFFSET_X
)+"px";
75 s
.top
=(e
.pageY
+this.OFFSET_Y
)+"px";
76 var _8
=Boolean(this.source
.copyState(dojo
.isCopyKey(e
)));
78 this._setCopyStatus(_8
);
81 },onMouseUp:function(e
){
83 if(this.target
&&this.canDropFlag
){
84 var _9
=Boolean(this.source
.copyState(dojo
.isCopyKey(e
))),_a
=[this.source
,this.nodes
,_9
,this.target
,e
];
85 dojo
.publish("/dnd/drop/before",_a
);
86 dojo
.publish("/dnd/drop",_a
);
88 dojo
.publish("/dnd/cancel");
92 },onKeyDown:function(e
){
96 var _b
=Boolean(this.source
.copyState(true));
98 this._setCopyStatus(_b
);
101 case dojo
.keys
.ESCAPE
:
102 dojo
.publish("/dnd/cancel");
107 },onKeyUp:function(e
){
108 if(this.avatar
&&e
.keyCode
==dojo
.keys
.CTRL
){
109 var _c
=Boolean(this.source
.copyState(false));
111 this._setCopyStatus(_c
);
114 },_setCopyStatus:function(_d
){
116 this.source
._markDndStatus(this.copy
);
118 dojo
.removeClass(dojo
.body(),"dojoDnd"+(this.copy
?"Move":"Copy"));
119 dojo
.addClass(dojo
.body(),"dojoDnd"+(this.copy
?"Copy":"Move"));
121 dojo
.dnd
._manager
=null;
122 dojo
.dnd
.manager=function(){
123 if(!dojo
.dnd
._manager
){
124 dojo
.dnd
._manager
=new dojo
.dnd
.Manager();
126 return dojo
.dnd
._manager
;