/*
	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","dojo.dnd.Manager"],["require","dojo.dnd.common"],["require","dojo.dnd.autoscroll"],["require","dojo.dnd.Avatar"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["dojo.dnd.Manager"]){_4._hasResource["dojo.dnd.Manager"]=true;_4.provide("dojo.dnd.Manager");_4.require("dojo.dnd.common");_4.require("dojo.dnd.autoscroll");_4.require("dojo.dnd.Avatar");_4.declare("dojo.dnd.Manager",null,{constructor:function(){this.avatar=null;this.source=null;this.nodes=[];this.copy=true;this.target=null;this.canDropFlag=false;this.events=[];},OFFSET_X:16,OFFSET_Y:16,overSource:function(_7){if(this.avatar){this.target=(_7&&_7.targetState!="Disabled")?_7:null;this.canDropFlag=Boolean(this.target);this.avatar.update();}_4.publish("/dnd/source/over",[_7]);},outSource:function(_8){if(this.avatar){if(this.target==_8){this.target=null;this.canDropFlag=false;this.avatar.update();_4.publish("/dnd/source/over",[null]);}}else{_4.publish("/dnd/source/over",[null]);}},startDrag:function(_9,_a,_b){this.source=_9;this.nodes=_a;this.copy=Boolean(_b);this.avatar=this.makeAvatar();_4.body().appendChild(this.avatar.node);_4.publish("/dnd/start",[_9,_a,this.copy]);this.events=[_4.connect(_4.doc,"onmousemove",this,"onMouseMove"),_4.connect(_4.doc,"onmouseup",this,"onMouseUp"),_4.connect(_4.doc,"onkeydown",this,"onKeyDown"),_4.connect(_4.doc,"onkeyup",this,"onKeyUp"),_4.connect(_4.doc,"ondragstart",_4.stopEvent),_4.connect(_4.body(),"onselectstart",_4.stopEvent)];var c="dojoDnd"+(_b?"Copy":"Move");_4.addClass(_4.body(),c);},canDrop:function(_c){var _d=Boolean(this.target&&_c);if(this.canDropFlag!=_d){this.canDropFlag=_d;this.avatar.update();}},stopDrag:function(){_4.removeClass(_4.body(),["dojoDndCopy","dojoDndMove"]);_4.forEach(this.events,_4.disconnect);this.events=[];this.avatar.destroy();this.avatar=null;this.source=this.target=null;this.nodes=[];},makeAvatar:function(){return new _4.dnd.Avatar(this);},updateAvatar:function(){this.avatar.update();},onMouseMove:function(e){var a=this.avatar;if(a){_4.dnd.autoScrollNodes(e);var s=a.node.style;s.left=(e.pageX+this.OFFSET_X)+"px";s.top=(e.pageY+this.OFFSET_Y)+"px";var _e=Boolean(this.source.copyState(_4.isCopyKey(e)));if(this.copy!=_e){this._setCopyStatus(_e);}}},onMouseUp:function(e){if(this.avatar){if(this.target&&this.canDropFlag){var _f=Boolean(this.source.copyState(_4.isCopyKey(e))),_10=[this.source,this.nodes,_f,this.target,e];_4.publish("/dnd/drop/before",_10);_4.publish("/dnd/drop",_10);}else{_4.publish("/dnd/cancel");}this.stopDrag();}},onKeyDown:function(e){if(this.avatar){switch(e.keyCode){case _4.keys.CTRL:var _11=Boolean(this.source.copyState(true));if(this.copy!=_11){this._setCopyStatus(_11);}break;case _4.keys.ESCAPE:_4.publish("/dnd/cancel");this.stopDrag();break;}}},onKeyUp:function(e){if(this.avatar&&e.keyCode==_4.keys.CTRL){var _12=Boolean(this.source.copyState(false));if(this.copy!=_12){this._setCopyStatus(_12);}}},_setCopyStatus:function(_13){this.copy=_13;this.source._markDndStatus(this.copy);this.updateAvatar();_4.replaceClass(_4.body(),"dojoDnd"+(this.copy?"Copy":"Move"),"dojoDnd"+(this.copy?"Move":"Copy"));}});_4.dnd._manager=null;_4.dnd.manager=function(){if(!_4.dnd._manager){_4.dnd._manager=new _4.dnd.Manager();}return _4.dnd._manager;};}}};});