/* Copyright (c) 2004-2010, 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 */ if(!dojo._hasResource["dojo.dnd.Mover"]){ dojo._hasResource["dojo.dnd.Mover"]=true; dojo.provide("dojo.dnd.Mover"); dojo.require("dojo.dnd.common"); dojo.require("dojo.dnd.autoscroll"); dojo.declare("dojo.dnd.Mover",null,{constructor:function(_1,e,_2){ this.node=dojo.byId(_1); this.marginBox={l:e.pageX,t:e.pageY}; this.mouseButton=e.button; var h=this.host=_2,d=_1.ownerDocument,_3=dojo.connect(d,"onmousemove",this,"onFirstMove"); this.events=[dojo.connect(d,"onmousemove",this,"onMouseMove"),dojo.connect(d,"onmouseup",this,"onMouseUp"),dojo.connect(d,"ondragstart",dojo.stopEvent),dojo.connect(d.body,"onselectstart",dojo.stopEvent),_3]; if(h&&h.onMoveStart){ h.onMoveStart(this); } },onMouseMove:function(e){ dojo.dnd.autoScroll(e); var m=this.marginBox; this.host.onMove(this,{l:m.l+e.pageX,t:m.t+e.pageY},e); dojo.stopEvent(e); },onMouseUp:function(e){ if(dojo.isWebKit&&dojo.isMac&&this.mouseButton==2?e.button==0:this.mouseButton==e.button){ this.destroy(); } dojo.stopEvent(e); },onFirstMove:function(e){ var s=this.node.style,l,t,h=this.host; switch(s.position){ case "relative": case "absolute": l=Math.round(parseFloat(s.left))||0; t=Math.round(parseFloat(s.top))||0; break; default: s.position="absolute"; var m=dojo.marginBox(this.node); var b=dojo.doc.body; var bs=dojo.getComputedStyle(b); var bm=dojo._getMarginBox(b,bs); var bc=dojo._getContentBox(b,bs); l=m.l-(bc.l-bm.l); t=m.t-(bc.t-bm.t); break; } this.marginBox.l=l-this.marginBox.l; this.marginBox.t=t-this.marginBox.t; if(h&&h.onFirstMove){ h.onFirstMove(this,e); } dojo.disconnect(this.events.pop()); },destroy:function(){ dojo.forEach(this.events,dojo.disconnect); var h=this.host; if(h&&h.onMoveStop){ h.onMoveStop(this); } this.events=this.node=this.host=null; }}); }