//>>built define("dojox/mdnd/AreaManager",["dojo/_base/kernel","dojo/_base/declare","dojo/_base/connect","dojo/_base/window","dojo/_base/array","dojo/_base/sniff","dojo/_base/lang","dojo/query","dojo/topic","dojo/dom-class","dojo/dom-geometry","dojo/dom-construct","dijit/registry","dijit/_Widget","./Moveable"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e,_f){ var am=_2("dojox.mdnd.AreaManager",null,{autoRefresh:true,areaClass:"dojoxDndArea",dragHandleClass:"dojoxDragHandle",constructor:function(){ this._areaList=[]; this.resizeHandler=_3.connect(_1.global,"onresize",this,function(){ this._dropMode.updateAreas(this._areaList); }); this._oldIndexArea=this._currentIndexArea=this._oldDropIndex=this._currentDropIndex=this._sourceIndexArea=this._sourceDropIndex=-1; },init:function(){ this.registerByClass(); },registerByNode:function(_10,_11){ var _12=this._getIndexArea(_10); if(_10&&_12==-1){ var _13=_10.getAttribute("accept"); var _14=(_13)?_13.split(/\s*,\s*/):["text"]; var obj={"node":_10,"items":[],"coords":{},"margin":null,"accept":_14,"initItems":false}; _5.forEach(this._getChildren(_10),function(_15){ this._setMarginArea(obj,_15); obj.items.push(this._addMoveableItem(_15)); },this); this._areaList=this._dropMode.addArea(this._areaList,obj); if(!_11){ this._dropMode.updateAreas(this._areaList); } _3.publish("/dojox/mdnd/manager/register",[_10]); } },registerByClass:function(){ _8("."+this.areaClass).forEach(function(_16){ this.registerByNode(_16,true); },this); this._dropMode.updateAreas(this._areaList); },unregister:function(_17){ var _18=this._getIndexArea(_17); if(_18!=-1){ _5.forEach(this._areaList[_18].items,function(_19){ this._deleteMoveableItem(_19); },this); this._areaList.splice(_18,1); this._dropMode.updateAreas(this._areaList); return true; } return false; },_addMoveableItem:function(_1a){ _1a.setAttribute("tabIndex","0"); var _1b=this._searchDragHandle(_1a); var _1c=new _f({"handle":_1b,"skip":true},_1a); _a.add(_1b||_1a,"dragHandle"); var _1d=_1a.getAttribute("dndType"); var _1e={"item":_1c,"type":_1d?_1d.split(/\s*,\s*/):["text"],"handlers":[_3.connect(_1c,"onDragStart",this,"onDragStart")]}; if(_d&&_d.byNode){ var _1f=_d.byNode(_1a); if(_1f){ _1e.type=_1f.dndType?_1f.dndType.split(/\s*,\s*/):["text"]; _1e.handlers.push(_3.connect(_1f,"uninitialize",this,function(){ this.removeDragItem(_1a.parentNode,_1c.node); })); } } return _1e; },_deleteMoveableItem:function(_20){ _5.forEach(_20.handlers,function(_21){ _3.disconnect(_21); }); var _22=_20.item.node,_23=this._searchDragHandle(_22); _a.remove(_23||_22,"dragHandle"); _20.item.destroy(); },_getIndexArea:function(_24){ if(_24){ for(var i=0;i7){ this._eventsIE7=[_3.connect(this._cover,"onmouseover",_1,"stopEvent"),_3.connect(this._cover,"onmouseout",_1,"stopEvent"),_3.connect(this._cover,"onmouseenter",_1,"stopEvent"),_3.connect(this._cover,"onmouseleave",_1,"stopEvent")]; } var s=_40.style; s.left=_41.x+"px"; s.top=_41.y+"px"; if(s.position=="relative"||s.position==""){ s.position="absolute"; } this._cover.appendChild(_40); this._dropIndicator.place(_44.node,_46,_42); _a.add(_40,"dragNode"); this._accept=true; _3.publish("/dojox/mdnd/drag/start",[_40,_44,this._sourceDropIndex]); },onDragEnter:function(_47,_48){ if(this._currentIndexArea===this._sourceIndexArea){ this._accept=true; }else{ this._isAccepted(this._dragItem.type,this._areaList[this._currentIndexArea].accept); } },onDragExit:function(_49,_4a){ this._accept=false; },onDrag:function(_4b,_4c,_4d,_4e){ var _4f=this._dropMode.getDragPoint(_4c,_4d,_4e); this.findCurrentIndexArea(_4f,_4d); if(this._currentIndexArea!==-1&&this._accept){ this.placeDropIndicator(_4f,_4d); } },placeDropIndicator:function(_50,_51){ this._oldDropIndex=this._currentDropIndex; var _52=this._areaList[this._currentIndexArea]; if(!_52.initItems){ this._dropMode.initItems(_52); } this._currentDropIndex=this._dropMode.getDropIndex(_52,_50); if(!(this._currentIndexArea===this._oldIndexArea&&this._oldDropIndex===this._currentDropIndex)){ this._placeDropIndicator(_51); } return this._currentDropIndex; },_placeDropIndicator:function(_53){ var _54=this._areaList[this._lastValidIndexArea]; var _55=this._areaList[this._currentIndexArea]; this._dropMode.refreshItems(_54,this._oldDropIndex,_53,false); var _56=null; if(this._currentDropIndex!=-1){ _56=_55.items[this._currentDropIndex].item.node; } this._dropIndicator.place(_55.node,_56); this._lastValidIndexArea=this._currentIndexArea; this._dropMode.refreshItems(_55,this._currentDropIndex,_53,true); },onDropCancel:function(){ if(!this._accept){ var _57=this._getIndexArea(this._dropIndicator.node.parentNode); if(_57!=-1){ this._currentIndexArea=_57; }else{ this._currentIndexArea=0; } } },onDrop:function(_58){ this.onDropCancel(); var _59=this._areaList[this._currentIndexArea]; _a.remove(_58,"dragNode"); var _5a=_58.style; _5a.position="relative"; _5a.left="0"; _5a.top="0"; _5a.width="auto"; if(_59.node==this._dropIndicator.node.parentNode){ _59.node.insertBefore(_58,this._dropIndicator.node); }else{ _59.node.appendChild(_58); this._currentDropIndex=_59.items.length; } var _5b=this._currentDropIndex; if(_5b==-1){ _5b=_59.items.length; } var _5c=_59.items; var _5d=_5c.slice(0,_5b); var _5e=_5c.slice(_5b,_5c.length); _5d[_5d.length]=this._dragItem; _59.items=_5d.concat(_5e); this._setMarginArea(_59,_58); _5.forEach(this._areaList,function(obj){ obj.initItems=false; }); _3.disconnect(this._dragItem.handlers.pop()); _3.disconnect(this._dragItem.handlers.pop()); this._resetAfterDrop(); if(this._cover){ _1.body().removeChild(this._cover); _1.body().removeChild(this._cover2); } _3.publish("/dojox/mdnd/drop",[_58,_59,_5b]); },_resetAfterDrop:function(){ this._accept=false; this._dragItem=null; this._currentDropIndex=-1; this._currentIndexArea=-1; this._oldDropIndex=-1; this._sourceIndexArea=-1; this._sourceDropIndex=-1; this._dropIndicator.remove(); if(this._dragStartHandler){ _3.disconnect(this._dragStartHandler); } if(_6("ie")>7){ _5.forEach(this._eventsIE7,_3.disconnect); } },destroy:function(){ while(this._areaList.length>0){ if(!this.unregister(this._areaList[0].node)){ throw new Error("Error while destroying AreaManager"); } } _3.disconnect(this.resizeHandler); this._dropIndicator.destroy(); this._dropMode.destroy(); if(dojox.mdnd.autoScroll){ dojox.mdnd.autoScroll.destroy(); } if(this.refreshListener){ _3.unsubscribe(this.refreshListener); } if(this._cover){ _c.destroy(this._cover); _c.destroy(this._cover2); delete this._cover; delete this._cover2; } }}); if(_e){ _7.extend(_e,{dndType:"text"}); } dojox.mdnd._areaManager=null; dojox.mdnd.areaManager=function(){ if(!dojox.mdnd._areaManager){ dojox.mdnd._areaManager=new dojox.mdnd.AreaManager(); } return dojox.mdnd._areaManager; }; return am; });