]> git.wh0rd.org - tt-rss.git/blob - lib/dojo/dnd/Mover.js
add dijit/dojo stuff; initial ui mockup
[tt-rss.git] / lib / dojo / dnd / Mover.js
1 /*
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
5 */
6
7
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];
19 if(h&&h.onMoveStart){
20 h.onMoveStart(this);
21 }
22 },onMouseMove:function(e){
23 dojo.dnd.autoScroll(e);
24 var m=this.marginBox;
25 this.host.onMove(this,{l:m.l+e.pageX,t:m.t+e.pageY},e);
26 dojo.stopEvent(e);
27 },onMouseUp:function(e){
28 if(dojo.isWebKit&&dojo.isMac&&this.mouseButton==2?e.button==0:this.mouseButton==e.button){
29 this.destroy();
30 }
31 dojo.stopEvent(e);
32 },onFirstMove:function(e){
33 var s=this.node.style,l,t,h=this.host;
34 switch(s.position){
35 case "relative":
36 case "absolute":
37 l=Math.round(parseFloat(s.left))||0;
38 t=Math.round(parseFloat(s.top))||0;
39 break;
40 default:
41 s.position="absolute";
42 var m=dojo.marginBox(this.node);
43 var b=dojo.doc.body;
44 var bs=dojo.getComputedStyle(b);
45 var bm=dojo._getMarginBox(b,bs);
46 var bc=dojo._getContentBox(b,bs);
47 l=m.l-(bc.l-bm.l);
48 t=m.t-(bc.t-bm.t);
49 break;
50 }
51 this.marginBox.l=l-this.marginBox.l;
52 this.marginBox.t=t-this.marginBox.t;
53 if(h&&h.onFirstMove){
54 h.onFirstMove(this,e);
55 }
56 dojo.disconnect(this.events.pop());
57 },destroy:function(){
58 dojo.forEach(this.events,dojo.disconnect);
59 var h=this.host;
60 if(h&&h.onMoveStop){
61 h.onMoveStop(this);
62 }
63 this.events=this.node=this.host=null;
64 }});
65 }