Wtf.ux.Portal=Wtf.extend(Wtf.Panel,{layout:"column",autoScroll:true,initComponent:function(){Wtf.ux.Portal.superclass.initComponent.call(this);this.addEvents({validatedrop:true,beforedragover:true,dragover:true,beforedrop:true,drop:true})},initEvents:function(){Wtf.ux.Portal.superclass.initEvents.call(this);this.dd=new Wtf.ux.Portal.DropZone(this,this.dropConfig)}});Wtf.reg("portal",Wtf.ux.Portal);Wtf.ux.Portal.DropZone=function(B,A){this.portal=B;Wtf.dd.ScrollManager.register(B.body);Wtf.ux.Portal.DropZone.superclass.constructor.call(this,B.bwrap.dom,A);B.body.ddScrollConfig=this.ddScrollConfig};Wtf.extend(Wtf.ux.Portal.DropZone,Wtf.dd.DropTarget,{ddScrollConfig:{vthresh:50,hthresh:-1,animate:true,increment:200},createEvent:function(A,D,C,B,F,E){return{portal:this.portal,panel:C.panel,columnIndex:B,column:F,position:E,data:C,source:A,rawEvent:D,status:this.dropAllowed}},notifyOver:function(Q,O,R){var E=O.getXY(),I=this.portal,J=Q.proxy;if(!this.grid){this.grid=this.getGrid()}var B=I.body.dom.clientWidth;if(!this.lastCW){this.lastCW=B}else{if(this.lastCW!=B){this.lastCW=B;I.doLayout();this.grid=this.getGrid()}}var D=0,H=this.grid.columnX,A=false;for(var N=H.length;D<N;D++){if(E[0]<(H[D].x+H[D].w)){A=true;break}}if(!A){D--}var L,G=false,F=0,P=I.items.itemAt(D),K=P.items.items;for(var N=K.length;F<N;F++){L=K[F];var M=L.el.getHeight();if(M!==0&&(L.el.getY()+(M/2))>E[1]){G=true;break}}var C=this.createEvent(Q,O,R,D,P,G&&L?F:P.items.getCount());if(I.fireEvent("validatedrop",C)!==false&&I.fireEvent("beforedragover",C)!==false){J.getProxy().setWidth("auto");if(L){J.moveProxy(L.el.dom.parentNode,G?L.el.dom:null)}else{J.moveProxy(P.body.dom,null)}this.lastPos={c:P,col:D,p:G&&L?F:false};this.scrollPos=I.body.getScroll();I.fireEvent("dragover",C);return C.status}else{return C.status}},notifyOut:function(){delete this.grid},notifyDrop:function(H,D,B){delete this.grid;var F=this.lastPos.c,A=this.lastPos.col,G=this.lastPos.p;var C=this.createEvent(H,D,B,A,F,G!==false?G:F.items.getCount());if(this.portal.fireEvent("validatedrop",C)!==false&&this.portal.fireEvent("beforedrop",C)!==false){H.proxy.getProxy().remove();if(H.panel.ownerCt==this.lastPos.c){H.panel.el.dom.parentNode.removeChild(H.panel.el.dom)}if(this.lastPos.p!==false){this.lastPos.c.insert(this.lastPos.p,H.panel)}else{this.lastPos.c.add(H.panel)}this.portal.doLayout();this.portal.fireEvent("drop",C);var I=this.scrollPos.top;if(I){var E=this.portal.body.dom;setTimeout(function(){E.scrollTop=I},10)}}},getGrid:function(){var A=this.portal.bwrap.getBox();A.columnX=[];this.portal.items.each(function(B){A.columnX.push({x:B.el.getX(),w:B.el.getWidth()})});return A}})