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