//>>built
define("dojox/mdnd/adapter/DndToDojo","dojo/_base/kernel dojo/_base/declare dojo/_base/connect dojo/_base/array dojo/dom-class dojo/dom-style dojo/dom-geometry dojo/topic dojo/_base/window dojox/mdnd/PureSource dojox/mdnd/LazyManager dojox/mdnd/AreaManager".split(" "),function(l,k,c,g,n,p,q,t,f,u,v,r){k=k("dojox.mdnd.adapter.DndToDojo",null,{_dojoList:null,_currentDojoArea:null,_dojoxManager:null,_dragStartHandler:null,_dropHandler:null,_moveHandler:null,_moveUpHandler:null,_draggedNode:null,constructor:function(){this._dojoList=
[];this._currentDojoArea=null;this._dojoxManager=r.areaManager();this._dragStartHandler=c.subscribe("/dojox/mdnd/drag/start",this,function(a,b,d){this._draggedNode=a;this._moveHandler=c.connect(l.doc,"onmousemove",this,"onMouseMove")});this._dropHandler=c.subscribe("/dojox/mdnd/drop",this,function(a,b,d){this._currentDojoArea&&c.publish("/dojox/mdnd/adapter/dndToDojo/cancel",[this._currentDojoArea.node,this._currentDojoArea.type,this._draggedNode,this.accept]);this._currentDojoArea=this._draggedNode=
null;c.disconnect(this._moveHandler)})},_getIndexDojoArea:function(a){if(a)for(var b=0,d=this._dojoList.length;b<d;b++)if(this._dojoList[b].node===a)return b;return-1},_initCoordinates:function(a){if(a){a=q.position(a,!0);var b={};b.x=a.x;b.y=a.y;b.x1=a.x+a.w;b.y1=a.y+a.h;return b}return null},register:function(a,b,d){if(-1==this._getIndexDojoArea(a)){var e=this._initCoordinates(a);this._dojoList.push({node:a,type:b,dojo:d?d:!1,coords:e});d&&!this._lazyManager&&(this._lazyManager=new dojox.mdnd.LazyManager)}},
unregisterByNode:function(a){a=this._getIndexDojoArea(a);-1!=a&&this._dojoList.splice(a,1)},unregisterByType:function(a){if(a){var b=[];g.forEach(this._dojoList,function(d,e){d.type!=a&&b.push(d)});this._dojoList=b}},unregister:function(){this._dojoList=[]},refresh:function(){var a=this._dojoList;this.unregister();g.forEach(a,function(b){b.coords=this._initCoordinates(b.node)},this);this._dojoList=a},refreshByType:function(a){var b=this._dojoList;this.unregister();g.forEach(b,function(d){d.type==
a&&(d.coords=this._initCoordinates(d.node))},this);this._dojoList=b},_getHoverDojoArea:function(a){this._oldDojoArea=this._currentDojoArea;this._currentDojoArea=null;var b=a.x;a=a.y;for(var d=this._dojoList.length,e=0;e<d;e++){var m=this._dojoList[e],h=m.coords;if(h.x<=b&&b<=h.x1&&h.y<=a&&a<=h.y1){this._currentDojoArea=m;break}}},onMouseMove:function(a){this._getHoverDojoArea({x:a.pageX,y:a.pageY});if(this._currentDojoArea!=this._oldDojoArea)if(null==this._currentDojoArea)this.onDragExit(a);else{if(null!=
this._oldDojoArea)this.onDragExit(a);this.onDragEnter(a)}},isAccepted:function(a,b){return!0},onDragEnter:function(a){if(this._currentDojoArea.dojo){c.disconnect(this._dojoxManager._dragItem.handlers.pop());c.disconnect(this._dojoxManager._dragItem.handlers.pop());c.disconnect(this._dojoxManager._dragItem.item.events.pop());f.body().removeChild(this._dojoxManager._cover);f.body().removeChild(this._dojoxManager._cover2);var b=this._dojoxManager._dragItem.item.node;dojox.mdnd.adapter._dndFromDojo&&
dojox.mdnd.adapter._dndFromDojo.unsubscribeDnd();p.set(b,{position:"relative",top:"0",left:"0"});this._lazyManager.startDrag(a,b);var d=c.connect(this._lazyManager.manager,"overSource",this,function(){c.disconnect(d);this._lazyManager.manager.canDropFlag&&(this._dojoxManager._dropIndicator.node.style.display="none")});this.cancelHandler=c.subscribe("/dnd/cancel",this,function(){var e=this._dojoxManager._dragItem.item;e.events=[c.connect(e.handle,"onmousedown",e,"onMouseDown")];f.body().appendChild(this._dojoxManager._cover);
f.body().appendChild(this._dojoxManager._cover2);this._dojoxManager._cover.appendChild(e.node);"none"==this._dojoxManager._dropIndicator.node.style.display&&""==this._dojoxManager._dropIndicator.node.style.display;this._dojoxManager._dragItem.handlers.push(c.connect(this._dojoxManager._dragItem.item,"onDrag",this._dojoxManager,"onDrag"));this._dojoxManager._dragItem.handlers.push(c.connect(this._dojoxManager._dragItem.item,"onDragEnd",this._dojoxManager,"onDrop"));this._draggedNode.style.display=
"";this._dojoxManager.onDrop(this._draggedNode);c.unsubscribe(this.cancelHandler);c.unsubscribe(this.dropHandler);dojox.mdnd.adapter._dndFromDojo&&dojox.mdnd.adapter._dndFromDojo.subscribeDnd()});this.dropHandler=c.subscribe("/dnd/drop/before",this,function(e){c.unsubscribe(this.cancelHandler);c.unsubscribe(this.dropHandler);this.onDrop()})}else if(this.accept=this.isAccepted(this._dojoxManager._dragItem.item.node,this._currentDojoArea))c.disconnect(this._dojoxManager._dragItem.handlers.pop()),c.disconnect(this._dojoxManager._dragItem.handlers.pop()),
this._dojoxManager._dropIndicator.node.style.display="none",this._moveUpHandler||(this._moveUpHandler=c.connect(l.doc,"onmouseup",this,"onDrop"));c.publish("/dojox/mdnd/adapter/dndToDojo/over",[this._currentDojoArea.node,this._currentDojoArea.type,this._draggedNode,this.accept])},onDragExit:function(a){if(this._oldDojoArea.dojo){c.unsubscribe(this.cancelHandler);c.unsubscribe(this.dropHandler);var b=this._dojoxManager._dragItem.item;this._dojoxManager._dragItem.item.events.push(c.connect(b.node.ownerDocument,
"onmousemove",b,"onMove"));f.body().appendChild(this._dojoxManager._cover);f.body().appendChild(this._dojoxManager._cover2);this._dojoxManager._cover.appendChild(b.node);var d=b.node.style;d.position="absolute";d.left=b.offsetDrag.l+a.pageX+"px";d.top=b.offsetDrag.t+a.pageX+"px";d.display="";this._lazyManager.cancelDrag();dojox.mdnd.adapter._dndFromDojo&&dojox.mdnd.adapter._dndFromDojo.subscribeDnd();"none"==this._dojoxManager._dropIndicator.node.style.display&&(this._dojoxManager._dropIndicator.node.style.display=
"");this._dojoxManager._dragItem.handlers.push(c.connect(this._dojoxManager._dragItem.item,"onDrag",this._dojoxManager,"onDrag"));this._dojoxManager._dragItem.handlers.push(c.connect(this._dojoxManager._dragItem.item,"onDragEnd",this._dojoxManager,"onDrop"));this._dojoxManager._dragItem.item.onMove(a)}else this.accept&&(this._moveUpHandler&&(c.disconnect(this._moveUpHandler),this._moveUpHandler=null),"none"==this._dojoxManager._dropIndicator.node.style.display&&(this._dojoxManager._dropIndicator.node.style.display=
""),this._dojoxManager._dragItem.handlers.push(c.connect(this._dojoxManager._dragItem.item,"onDrag",this._dojoxManager,"onDrag")),this._dojoxManager._dragItem.handlers.push(c.connect(this._dojoxManager._dragItem.item,"onDragEnd",this._dojoxManager,"onDrop")),this._dojoxManager._dragItem.item.onMove(a));c.publish("/dojox/mdnd/adapter/dndToDojo/out",[this._oldDojoArea.node,this._oldDojoArea.type,this._draggedNode,this.accept])},onDrop:function(a){this._currentDojoArea.dojo&&dojox.mdnd.adapter._dndFromDojo&&
dojox.mdnd.adapter._dndFromDojo.subscribeDnd();"none"==this._dojoxManager._dropIndicator.node.style.display&&(this._dojoxManager._dropIndicator.node.style.display="");this._dojoxManager._cover.parentNode&&1==this._dojoxManager._cover.parentNode.nodeType&&(f.body().removeChild(this._dojoxManager._cover),f.body().removeChild(this._dojoxManager._cover2));this._draggedNode.parentNode==this._dojoxManager._cover&&this._dojoxManager._cover.removeChild(this._draggedNode);c.disconnect(this._moveHandler);c.disconnect(this._moveUpHandler);
this._moveHandler=this._moveUpHandler=null;c.publish("/dojox/mdnd/adapter/dndToDojo/drop",[this._draggedNode,this._currentDojoArea.node,this._currentDojoArea.type]);n.remove(this._draggedNode,"dragNode");a=this._draggedNode.style;a.position="relative";a.left="0";a.top="0";a.width="auto";g.forEach(this._dojoxManager._dragItem.handlers,c.disconnect);this._dojoxManager._deleteMoveableItem(this._dojoxManager._dragItem);this._currentDojoArea=this._draggedNode=null;this._dojoxManager._resetAfterDrop()}});
dojox.mdnd.adapter._dndToDojo=null;dojox.mdnd.adapter.dndToDojo=function(){dojox.mdnd.adapter._dndToDojo||(dojox.mdnd.adapter._dndToDojo=new dojox.mdnd.adapter.DndToDojo);return dojox.mdnd.adapter._dndToDojo};return k});