Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / gfx / Moveable.js @ 11

History | View | Annotate | Download (1.67 KB)

1 9 andrej.cim
/*
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["dojox.gfx.Moveable"]){
9
dojo._hasResource["dojox.gfx.Moveable"]=true;
10
dojo.provide("dojox.gfx.Moveable");
11
dojo.require("dojox.gfx.Mover");
12
dojo.declare("dojox.gfx.Moveable",null,{constructor:function(_1,_2){
13
this.shape=_1;
14
this.delay=(_2&&_2.delay>0)?_2.delay:0;
15
this.mover=(_2&&_2.mover)?_2.mover:dojox.gfx.Mover;
16
this.events=[this.shape.connect("onmousedown",this,"onMouseDown")];
17
},destroy:function(){
18
dojo.forEach(this.events,this.shape.disconnect,this.shape);
19
this.events=this.shape=null;
20
},onMouseDown:function(e){
21
if(this.delay){
22
this.events.push(this.shape.connect("onmousemove",this,"onMouseMove"));
23
this.events.push(this.shape.connect("onmouseup",this,"onMouseUp"));
24
this._lastX=e.clientX;
25
this._lastY=e.clientY;
26
}else{
27
new this.mover(this.shape,e,this);
28
}
29
dojo.stopEvent(e);
30
},onMouseMove:function(e){
31
if(Math.abs(e.clientX-this._lastX)>this.delay||Math.abs(e.clientY-this._lastY)>this.delay){
32
this.onMouseUp(e);
33
new this.mover(this.shape,e,this);
34
}
35
dojo.stopEvent(e);
36
},onMouseUp:function(e){
37
this.shape.disconnect(this.events.pop());
38
this.shape.disconnect(this.events.pop());
39
},onMoveStart:function(_3){
40
dojo.publish("/gfx/move/start",[_3]);
41
dojo.addClass(dojo.body(),"dojoMove");
42
},onMoveStop:function(_4){
43
dojo.publish("/gfx/move/stop",[_4]);
44
dojo.removeClass(dojo.body(),"dojoMove");
45
},onFirstMove:function(_5){
46
},onMove:function(_6,_7){
47
this.onMoving(_6,_7);
48
this.shape.applyLeftTransform(_7);
49
this.onMoved(_6,_7);
50
},onMoving:function(_8,_9){
51
},onMoved:function(_a,_b){
52
}});
53
}