]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/dnd/Mover.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.Mover"]){
9 dojo
._hasResource
["dojo.dnd.Mover"]=true;
10 dojo
.provide("dojo.dnd.Mover");
11 dojo
.require("dojo.dnd.common");
12 dojo
.require("dojo.dnd.autoscroll");
13 dojo
.declare("dojo.dnd.Mover",null,{constructor:function(_1
,e
,_2
){
14 this.node
=dojo
.byId(_1
);
15 this.marginBox
={l
:e
.pageX
,t
:e
.pageY
};
16 this.mouseButton
=e
.button
;
17 var h
=this.host
=_2
,d
=_1
.ownerDocument
,_3
=dojo
.connect(d
,"onmousemove",this,"onFirstMove");
18 this.events
=[dojo
.connect(d
,"onmousemove",this,"onMouseMove"),dojo
.connect(d
,"onmouseup",this,"onMouseUp"),dojo
.connect(d
,"ondragstart",dojo
.stopEvent
),dojo
.connect(d
.body
,"onselectstart",dojo
.stopEvent
),_3
];
22 },onMouseMove:function(e
){
23 dojo
.dnd
.autoScroll(e
);
25 this.host
.onMove(this,{l
:m
.l
+e
.pageX
,t
:m
.t
+e
.pageY
},e
);
27 },onMouseUp:function(e
){
28 if(dojo
.isWebKit
&&dojo
.isMac
&&this.mouseButton
==2?e
.button
==0:this.mouseButton
==e
.button
){
32 },onFirstMove:function(e
){
33 var s
=this.node
.style
,l
,t
,h
=this.host
;
37 l
=Math
.round(parseFloat(s
.left
))||0;
38 t
=Math
.round(parseFloat(s
.top
))||0;
41 s
.position
="absolute";
42 var m
=dojo
.marginBox(this.node
);
44 var bs
=dojo
.getComputedStyle(b
);
45 var bm
=dojo
._getMarginBox(b
,bs
);
46 var bc
=dojo
._getContentBox(b
,bs
);
51 this.marginBox
.l
=l
-this.marginBox
.l
;
52 this.marginBox
.t
=t
-this.marginBox
.t
;
54 h
.onFirstMove(this,e
);
56 dojo
.disconnect(this.events
.pop());
58 dojo
.forEach(this.events
,dojo
.disconnect
);
63 this.events
=this.node
=this.host
=null;