/*
	Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


window[esri._dojoScopeName||"dojo"]._xdResourceLoaded(function(_1,_2,_3){return {depends:[["provide","dojox.drawing.ui.dom.Pan"],["require","dojox.drawing.plugins._Plugin"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["dojox.drawing.ui.dom.Pan"]){_4._hasResource["dojox.drawing.ui.dom.Pan"]=true;_4.provide("dojox.drawing.ui.dom.Pan");_4.require("dojox.drawing.plugins._Plugin");_4.deprecated("dojox.drawing.ui.dom.Pan","It may not even make it to the 1.4 release.",1.4);_6.drawing.ui.dom.Pan=_6.drawing.util.oo.declare(_6.drawing.plugins._Plugin,function(_7){this.domNode=_7.node;var _8;_4.connect(this.domNode,"click",this,"onSetPan");_4.connect(this.keys,"onKeyUp",this,"onKeyUp");_4.connect(this.keys,"onKeyDown",this,"onKeyDown");_4.connect(this.anchors,"onAnchorUp",this,"checkBounds");_4.connect(this.stencils,"register",this,"checkBounds");_4.connect(this.canvas,"resize",this,"checkBounds");_4.connect(this.canvas,"setZoom",this,"checkBounds");_4.connect(this.canvas,"onScroll",this,function(){if(this._blockScroll){this._blockScroll=false;return;}_8&&clearTimeout(_8);_8=setTimeout(_4.hitch(this,"checkBounds"),200);});this._mouseHandle=this.mouse.register(this);},{selected:false,type:"dojox.drawing.ui.dom.Pan",onKeyUp:function(_9){if(_9.keyCode==32){this.onSetPan(false);}},onKeyDown:function(_a){if(_a.keyCode==32){this.onSetPan(true);}},onSetPan:function(_b){if(_b===true||_b===false){this.selected=!_b;}if(this.selected){this.selected=false;_4.removeClass(this.domNode,"selected");}else{this.selected=true;_4.addClass(this.domNode,"selected");}this.mouse.setEventMode(this.selected?"pan":"");},onPanDrag:function(_c){var x=_c.x-_c.last.x;var y=_c.y-_c.last.y;this.canvas.domNode.parentNode.scrollTop-=_c.move.y;this.canvas.domNode.parentNode.scrollLeft-=_c.move.x;this.canvas.onScroll();},onStencilUp:function(_d){this.checkBounds();},onStencilDrag:function(_e){},checkBounds:function(){var _f=function(){};var _10=function(){};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(),scY=sc.left?10:0,scX=sc.top?10:0,ch=this.canvas.height,cw=this.canvas.width,z=this.canvas.zoom,pch=this.canvas.parentHeight,pcw=this.canvas.parentWidth;this.stencils.withSelected(function(m){var o=m.getBounds();_10("SEL BOUNDS:",o);t=Math.min(o.y1+mx.dy,t);r=Math.max(o.x2+mx.dx,r);b=Math.max(o.y2+mx.dy,b);l=Math.min(o.x1+mx.dx,l);});this.stencils.withUnselected(function(m){var o=m.getBounds();_10("UN BOUNDS:",o);t=Math.min(o.y1,t);r=Math.max(o.x2,r);b=Math.max(o.y2,b);l=Math.min(o.x1,l);});b*=z;var _11=0,_12=0;_f("Bottom test","b:",b,"z:",z,"ch:",ch,"pch:",pch,"top:",sc.top,"sy:",sy);if(b>pch||sc.top){_f("*bottom scroll*");ch=Math.max(b,pch+sc.top);sy=sc.top;_11+=this.canvas.getScrollWidth();}else{if(!sy&&ch>pch){_f("*bottom remove*");ch=pch;}}r*=z;if(r>pcw||sc.left){cw=Math.max(r,pcw+sc.left);sx=sc.left;_12+=this.canvas.getScrollWidth();}else{if(!sx&&cw>pcw){cw=pcw;}}cw+=_11*2;ch+=_12*2;this._blockScroll=true;this.stencils.group&&this.stencils.group.applyTransform({dx:dx,dy:dy});this.stencils.withUnselected(function(m){m.transformPoints({dx:dx,dy:dy});});this.canvas.setDimensions(cw,ch,sx,sy);}});_6.drawing.ui.dom.Pan.setup={name:"dojox.drawing.ui.dom.Pan",tooltip:"Pan Tool",iconClass:"iconPan"};_6.drawing.register(_6.drawing.ui.dom.Pan.setup,"plugin");}}};});