root / trunk / web / dojo / dojox / drawing / ui / dom / Pan.js
History | View | Annotate | Download (3.45 KB)
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["dojox.drawing.ui.dom.Pan"]){ |
9 |
dojo._hasResource["dojox.drawing.ui.dom.Pan"]=true; |
10 |
dojo.provide("dojox.drawing.ui.dom.Pan");
|
11 |
dojo.require("dojox.drawing.plugins._Plugin");
|
12 |
dojo.deprecated("dojox.drawing.ui.dom.Pan","It may not even make it to the 1.4 release.",1.4); |
13 |
dojox.drawing.ui.dom.Pan=dojox.drawing.util.oo.declare(dojox.drawing.plugins._Plugin,function(_1){
|
14 |
this.domNode=_1.node;
|
15 |
var _2;
|
16 |
dojo.connect(this.domNode,"click",this,"onSetPan"); |
17 |
dojo.connect(this.keys,"onKeyUp",this,"onKeyUp"); |
18 |
dojo.connect(this.keys,"onKeyDown",this,"onKeyDown"); |
19 |
dojo.connect(this.anchors,"onAnchorUp",this,"checkBounds"); |
20 |
dojo.connect(this.stencils,"register",this,"checkBounds"); |
21 |
dojo.connect(this.canvas,"resize",this,"checkBounds"); |
22 |
dojo.connect(this.canvas,"setZoom",this,"checkBounds"); |
23 |
dojo.connect(this.canvas,"onScroll",this,function(){ |
24 |
if(this._blockScroll){ |
25 |
this._blockScroll=false; |
26 |
return;
|
27 |
} |
28 |
_2&&clearTimeout(_2); |
29 |
_2=setTimeout(dojo.hitch(this,"checkBounds"),200); |
30 |
}); |
31 |
this._mouseHandle=this.mouse.register(this); |
32 |
},{selected:false,type:"dojox.drawing.ui.dom.Pan",onKeyUp:function(_3){ |
33 |
if(_3.keyCode==32){ |
34 |
this.onSetPan(false); |
35 |
} |
36 |
},onKeyDown:function(_4){ |
37 |
if(_4.keyCode==32){ |
38 |
this.onSetPan(true); |
39 |
} |
40 |
},onSetPan:function(_5){ |
41 |
if(_5===true||_5===false){ |
42 |
this.selected=!_5;
|
43 |
} |
44 |
if(this.selected){ |
45 |
this.selected=false; |
46 |
dojo.removeClass(this.domNode,"selected"); |
47 |
}else{
|
48 |
this.selected=true; |
49 |
dojo.addClass(this.domNode,"selected"); |
50 |
} |
51 |
this.mouse.setEventMode(this.selected?"pan":""); |
52 |
},onPanDrag:function(_6){ |
53 |
var x=_6.x-_6.last.x;
|
54 |
var y=_6.y-_6.last.y;
|
55 |
this.canvas.domNode.parentNode.scrollTop-=_6.move.y;
|
56 |
this.canvas.domNode.parentNode.scrollLeft-=_6.move.x;
|
57 |
this.canvas.onScroll();
|
58 |
},onStencilUp:function(_7){ |
59 |
this.checkBounds();
|
60 |
},onStencilDrag:function(_8){ |
61 |
},checkBounds:function(){ |
62 |
var _9=function(){ |
63 |
}; |
64 |
var _a=function(){ |
65 |
}; |
66 |
var t=Infinity,r=-Infinity,b=-Infinity,l=Infinity,sx=0,sy=0,dy=0,dx=0,mx=this.stencils.group?this.stencils.group.getTransform():{dx:0,dy:0},sc=this.mouse.scrollOffset(),_b=sc.left?10:0,_c=sc.top?10:0,ch=this.canvas.height,cw=this.canvas.width,z=this.canvas.zoom,_d=this.canvas.parentHeight,_e=this.canvas.parentWidth; |
67 |
this.stencils.withSelected(function(m){ |
68 |
var o=m.getBounds();
|
69 |
_a("SEL BOUNDS:",o);
|
70 |
t=Math.min(o.y1+mx.dy,t); |
71 |
r=Math.max(o.x2+mx.dx,r); |
72 |
b=Math.max(o.y2+mx.dy,b); |
73 |
l=Math.min(o.x1+mx.dx,l); |
74 |
}); |
75 |
this.stencils.withUnselected(function(m){ |
76 |
var o=m.getBounds();
|
77 |
_a("UN BOUNDS:",o);
|
78 |
t=Math.min(o.y1,t); |
79 |
r=Math.max(o.x2,r); |
80 |
b=Math.max(o.y2,b); |
81 |
l=Math.min(o.x1,l); |
82 |
}); |
83 |
b*=z; |
84 |
var _f=0,_10=0; |
85 |
_9("Bottom test","b:",b,"z:",z,"ch:",ch,"pch:",_d,"top:",sc.top,"sy:",sy); |
86 |
if(b>_d||sc.top){
|
87 |
_9("*bottom scroll*");
|
88 |
ch=Math.max(b,_d+sc.top); |
89 |
sy=sc.top; |
90 |
_f+=this.canvas.getScrollWidth();
|
91 |
}else{
|
92 |
if(!sy&&ch>_d){
|
93 |
_9("*bottom remove*");
|
94 |
ch=_d; |
95 |
} |
96 |
} |
97 |
r*=z; |
98 |
if(r>_e||sc.left){
|
99 |
cw=Math.max(r,_e+sc.left); |
100 |
sx=sc.left; |
101 |
_10+=this.canvas.getScrollWidth();
|
102 |
}else{
|
103 |
if(!sx&&cw>_e){
|
104 |
cw=_e; |
105 |
} |
106 |
} |
107 |
cw+=_f*2;
|
108 |
ch+=_10*2;
|
109 |
this._blockScroll=true; |
110 |
this.stencils.group&&this.stencils.group.applyTransform({dx:dx,dy:dy}); |
111 |
this.stencils.withUnselected(function(m){ |
112 |
m.transformPoints({dx:dx,dy:dy}); |
113 |
}); |
114 |
this.canvas.setDimensions(cw,ch,sx,sy);
|
115 |
}}); |
116 |
dojox.drawing.ui.dom.Pan.setup={name:"dojox.drawing.ui.dom.Pan",tooltip:"Pan Tool",iconClass:"iconPan"}; |
117 |
dojox.drawing.register(dojox.drawing.ui.dom.Pan.setup,"plugin");
|
118 |
} |