]> git.wh0rd.org - tt-rss.git/blob - lib/dojo/dnd/Moveable.js
add dijit/dojo stuff; initial ui mockup
[tt-rss.git] / lib / dojo / dnd / Moveable.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.Moveable"]){
9 dojo._hasResource["dojo.dnd.Moveable"]=true;
10 dojo.provide("dojo.dnd.Moveable");
11 dojo.require("dojo.dnd.Mover");
12 dojo.declare("dojo.dnd.Moveable",null,{handle:"",delay:0,skip:false,constructor:function(_1,_2){
13 this.node=dojo.byId(_1);
14 if(!_2){
15 _2={};
16 }
17 this.handle=_2.handle?dojo.byId(_2.handle):null;
18 if(!this.handle){
19 this.handle=this.node;
20 }
21 this.delay=_2.delay>0?_2.delay:0;
22 this.skip=_2.skip;
23 this.mover=_2.mover?_2.mover:dojo.dnd.Mover;
24 this.events=[dojo.connect(this.handle,"onmousedown",this,"onMouseDown"),dojo.connect(this.handle,"ondragstart",this,"onSelectStart"),dojo.connect(this.handle,"onselectstart",this,"onSelectStart")];
25 },markupFactory:function(_3,_4){
26 return new dojo.dnd.Moveable(_4,_3);
27 },destroy:function(){
28 dojo.forEach(this.events,dojo.disconnect);
29 this.events=this.node=this.handle=null;
30 },onMouseDown:function(e){
31 if(this.skip&&dojo.dnd.isFormElement(e)){
32 return;
33 }
34 if(this.delay){
35 this.events.push(dojo.connect(this.handle,"onmousemove",this,"onMouseMove"),dojo.connect(this.handle,"onmouseup",this,"onMouseUp"));
36 this._lastX=e.pageX;
37 this._lastY=e.pageY;
38 }else{
39 this.onDragDetected(e);
40 }
41 dojo.stopEvent(e);
42 },onMouseMove:function(e){
43 if(Math.abs(e.pageX-this._lastX)>this.delay||Math.abs(e.pageY-this._lastY)>this.delay){
44 this.onMouseUp(e);
45 this.onDragDetected(e);
46 }
47 dojo.stopEvent(e);
48 },onMouseUp:function(e){
49 for(var i=0;i<2;++i){
50 dojo.disconnect(this.events.pop());
51 }
52 dojo.stopEvent(e);
53 },onSelectStart:function(e){
54 if(!this.skip||!dojo.dnd.isFormElement(e)){
55 dojo.stopEvent(e);
56 }
57 },onDragDetected:function(e){
58 new this.mover(this.node,e,this);
59 },onMoveStart:function(_5){
60 dojo.publish("/dnd/move/start",[_5]);
61 dojo.addClass(dojo.body(),"dojoMove");
62 dojo.addClass(this.node,"dojoMoveItem");
63 },onMoveStop:function(_6){
64 dojo.publish("/dnd/move/stop",[_6]);
65 dojo.removeClass(dojo.body(),"dojoMove");
66 dojo.removeClass(this.node,"dojoMoveItem");
67 },onFirstMove:function(_7,e){
68 },onMove:function(_8,_9,e){
69 this.onMoving(_8,_9);
70 var s=_8.node.style;
71 s.left=_9.l+"px";
72 s.top=_9.t+"px";
73 this.onMoved(_8,_9);
74 },onMoving:function(_a,_b){
75 },onMoved:function(_c,_d){
76 }});
77 }