//>>built
define("dojox/mdnd/adapter/DndFromDojo","dojo/_base/kernel dojo/_base/declare dojo/_base/connect dojo/_base/array dojo/dom-class dojo/_base/window dojox/mdnd/AreaManager dojo/dnd/Manager".split(" "),function(k,h,b,n,e,u,p,q){h=h("dojox.mdnd.adapter.DndFromDojo",null,{dropIndicatorSize:{w:0,h:50},_areaManager:null,_dojoManager:null,_currentArea:null,_oldArea:null,_moveHandler:null,_subscribeHandler:null,constructor:function(){this._areaManager=p.areaManager();this._dojoManager=q.manager();this._moveHandler=
this._currentArea=null;this.subscribeDnd()},subscribeDnd:function(){this._subscribeHandler=[b.subscribe("/dnd/start",this,"onDragStart"),b.subscribe("/dnd/drop/before",this,"onDrop"),b.subscribe("/dnd/cancel",this,"onDropCancel"),b.subscribe("/dnd/source/over",this,"onDndSource")]},unsubscribeDnd:function(){n.forEach(this._subscribeHandler,b.unsubscribe)},_getHoverArea:function(a){var c=a.x;a=a.y;this._oldArea=this._currentArea;this._currentArea=null;for(var d=this._areaManager._areaList,g=0;g<d.length;g++){var f=
d[g],l=f.coords.x,r=l+f.node.offsetWidth,m=f.coords.y,t=m+f.node.offsetHeight;if(l<=c&&c<=r&&m<=a&&a<=t){this._areaManager._oldIndexArea=this._areaManager._currentIndexArea;this._areaManager._currentIndexArea=g;this._currentArea=f.node;break}}if(this._currentArea!=this._oldArea)if(null==this._currentArea)this.onDragExit();else{if(null!=this._oldArea)this.onDragExit();this.onDragEnter()}},onDragStart:function(a,c,d){this._dragNode=c[0];this._copy=d;this._source=a;this._outSourceHandler=b.connect(this._dojoManager,
"outSource",this,function(){null==this._moveHandler&&(this._moveHandler=b.connect(k.doc,"mousemove",this,"onMouseMove"))})},onMouseMove:function(a){a={x:a.pageX,y:a.pageY};this._getHoverArea(a);this._currentArea&&this._areaManager._accept&&("hidden"==this._areaManager._dropIndicator.node.style.visibility&&(this._areaManager._dropIndicator.node.style.visibility="",e.add(this._dojoManager.avatar.node,"dojoDndAvatarCanDrop")),this._areaManager.placeDropIndicator(a,this.dropIndicatorSize))},onDragEnter:function(){var a=
this._dragNode.getAttribute("dndType");a=a?a.split(/\s*,\s*/):["text"];this._areaManager._isAccepted(a,this._areaManager._areaList[this._areaManager._currentIndexArea].accept);this._dojoManager.avatar&&(this._areaManager._accept?e.add(this._dojoManager.avatar.node,"dojoDndAvatarCanDrop"):e.remove(this._dojoManager.avatar.node,"dojoDndAvatarCanDrop"))},onDragExit:function(){this._areaManager._accept=!1;this._dojoManager.avatar&&e.remove(this._dojoManager.avatar.node,"dojoDndAvatarCanDrop");null==this._currentArea?
(this._areaManager._dropMode.refreshItems(this._areaManager._areaList[this._areaManager._oldIndexArea],this._areaManager._oldDropIndex,this.dropIndicatorSize,!1),this._areaManager._resetAfterDrop()):this._areaManager._dropIndicator.remove()},isAccepted:function(a,c){var d=a.getAttribute("dndType")?a.getAttribute("dndType"):"text";return d&&d in c?!0:!1},onDndSource:function(a){if(null!=this._currentArea)if(a){var c=!1;(c=this._dojoManager.target==a?!0:this.isAccepted(this._dragNode,a.accept))?(b.disconnect(this._moveHandler),
this._currentArea=this._moveHandler=null,(a=this._areaManager._dropIndicator.node)&&null!==a.parentNode&&1==a.parentNode.nodeType&&(a.style.visibility="hidden")):this._resetAvatar()}else this._moveHandler||(this._moveHandler=b.connect(k.doc,"mousemove",this,"onMouseMove")),this._resetAvatar()},_resetAvatar:function(){this._dojoManager.avatar&&(this._areaManager._accept?e.add(this._dojoManager.avatar.node,"dojoDndAvatarCanDrop"):e.remove(this._dojoManager.avatar.node,"dojoDndAvatarCanDrop"))},onDropCancel:function(){if(null==
this._currentArea)this._areaManager._resetAfterDrop(),b.disconnect(this._moveHandler),b.disconnect(this._outSourceHandler),this._currentArea=this._moveHandler=this._outSourceHandler=null;else if(this._areaManager._accept)this.onDrop(this._source,[this._dragNode],this._copy,this._currentArea);else this._currentArea=null,b.disconnect(this._outSourceHandler),b.disconnect(this._moveHandler),this._moveHandler=this._outSourceHandler=null},onDrop:function(a,c,d){b.disconnect(this._moveHandler);b.disconnect(this._outSourceHandler);
this._moveHandler=this._outSourceHandler=null;this._currentArea&&(b.publish("/dnd/drop/after",[a,c,d,this._currentArea,this._areaManager._currentDropIndex]),this._currentArea=null);"hidden"==this._areaManager._dropIndicator.node.style.visibility&&(this._areaManager._dropIndicator.node.style.visibility="");this._areaManager._resetAfterDrop()}});dojox.mdnd.adapter._dndFromDojo=null;dojox.mdnd.adapter._dndFromDojo=new dojox.mdnd.adapter.DndFromDojo;return h});