resize-base-min.js revision b59e7b3ed206081207046ca576d89a258c2de995
YUI.add("resize-base",function(d){var ay=d.Lang,H=ay.isArray,Q=ay.isBoolean,s=ay.isString,a=ay.trim,z=d.Array.indexOf,F=".",y=",",b=" ",D="active",ag="activeHandle",o="activeHandleNode",am="all",I="autoHide",N="bottom",e="className",Z="cursor",aq="dragCursor",aw="handle",f="handles",al="hidden",P="inner",G="left",ae="margin",au="node",ai="nodeName",X="none",ac="offsetHeight",af="offsetWidth",u="parentNode",ab="position",ax="proxy",aj="proxyNode",t="relative",av="resize",ad="resizing",ap="right",v="static",U="top",l="wrap",at="wrapper",r="wrapTypes",K="resize:mouseUp",x="resize:resize",A="resize:align",W="resize:end",c="resize:start",g="t",aa="tr",i="r",O="br",w="b",V="bl",p="l",ah="tl",n=function(B){return(B instanceof d.Node);},E=function(B){return aw+B.toUpperCase();},J=function(){return Array.prototype.slice.call(arguments).join(b);},ao=d.cached(function(B){return B.substring(0,1).toUpperCase()+B.substring(1);}),j=d.ClassNameManager.getClassName,ar=j(av),S=j(av,aw),k=j(av,aw,D),q=j(av,aw,P),M=j(av,aw,P,"{handle}"),m=j(av,aw,"{handle}"),C=j(av,al,f),h=j(av,ax),an=j(av,at);function ak(){ak.superclass.constructor.apply(this,arguments);}d.mix(ak,{NAME:av,ATTRS:{activeHandle:{value:null,validator:s},activeHandleNode:{value:null,validator:n},autoHide:{value:false,validator:Q},handles:{setter:"_setHandles",value:am},node:{setter:d.one},proxy:{value:false,validator:Q},proxyNode:{setter:d.one,valueFn:function(){return d.Node.create(this.PROXY_TEMPLATE);}},resizing:{value:false,validator:Q},wrap:{setter:"_setWrap",value:false,validator:Q},wrapTypes:{readOnly:true,value:/^canvas|textarea|input|select|button|img|iframe|table|embed$/i},wrapper:{setter:"_setWrapper",value:null,writeOnce:true}}});d.Resize=d.extend(ak,d.Base,{ALL_HANDLES:[g,aa,i,O,w,V,p,ah],REGEX_CHANGE_HEIGHT:/^(t|tr|b|bl|br|tl)$/i,REGEX_CHANGE_LEFT:/^(tl|l|bl)$/i,REGEX_CHANGE_TOP:/^(tl|t|tr)$/i,REGEX_CHANGE_WIDTH:/^(bl|br|l|r|tl|tr)$/i,WRAP_TEMPLATE:'<div class="'+an+'"></div>',PROXY_TEMPLATE:'<div class="'+h+'"></div>',HANDLE_TEMPLATE:'<div class="'+J(S,m)+'">'+'<div class="'+J(q,M)+'"> </div>'+"</div>",changeHeightHandles:false,changeLeftHandles:false,changeTopHandles:false,changeWidthHandles:false,delegate:null,info:null,lastInfo:null,originalInfo:null,initializer:function(){var B=this;B.info={};B.originalInfo={};B.get(au).addClass(ar);B.renderer();},renderUI:function(){var B=this;B._renderHandles();},bindUI:function(){var B=this;B._createEvents();B._bindDD();B._bindHandle();},syncUI:function(){var B=this;B._setHideHandlesUI(B.get(I));},destructor:function(){var B=this,R=B.get(au),T=B.get(at),L=T.get(u);d.Event.purgeElement(T,true);B.eachHandle(function(Y){B.delegate.dd.destroy();Y.remove(true);});if(B.get(l)){B._copyStyles(T,R);if(L){L.insertBefore(R,T);}T.remove(true);}R.removeClass(ar);R.removeClass(C);},renderer:function(){this.renderUI();this.bindUI();this.syncUI();},eachHandle:function(L){var B=this;d.each(B.get(f),function(Y,R){var T=B.get(E(Y));L.apply(B,[T,Y,R]);});},_bindDD:function(){var B=this;B.delegate=new d.DD.Delegate({bubbleTargets:B,container:B.get(at),dragConfig:{clickPixelThresh:0,clickTimeThresh:0,useShim:true,move:false},nodes:F+S,target:false});B.on("drag:drag",B._handleResizeEvent);B.on("drag:dropmiss",B._handleMouseUpEvent);B.on("drag:end",B._handleResizeEndEvent);B.on("drag:start",B._handleResizeStartEvent);},_bindHandle:function(){var B=this,L=B.get(at);L.on("mouseenter",d.bind(B._onWrapperMouseEnter,B));L.on("mouseleave",d.bind(B._onWrapperMouseLeave,B));L.delegate("mouseenter",d.bind(B._onHandleMouseEnter,B),F+S);L.delegate("mouseleave",d.bind(B._onHandleMouseLeave,B),F+S);},_createEvents:function(){var B=this,L=function(R,T){B.publish(R,{defaultFn:T,queuable:false,emitFacade:true,bubbles:true,prefix:av});};L(c,this._defResizeStartFn);L(x,this._defResizeFn);L(A,this._defResizeAlignFn);L(W,this._defResizeEndFn);L(K,this._defMouseUpFn);},_renderHandles:function(){var B=this,L=B.get(at);B.eachHandle(function(R){L.append(R);});},_renderProxy:function(){var B=this,L=B.get(aj);if(!L.inDoc()){B.get(at).get(u).append(L.hide());}},_buildHandle:function(L){var B=this;return d.Node.create(d.substitute(B.HANDLE_TEMPLATE,{handle:L}));},_checkSize:function(az,L){var B=this,Y=B.info,T=B.originalInfo,R=(az==ac)?U:G;Y[az]=L;if(((R==G)&&B.changeLeftHandles)||((R==U)&&B.changeTopHandles)){Y[R]=T[R]+T[az]-L;}},_copyStyles:function(T,Y){var B=T.getStyle(ab).toLowerCase(),L={},R;if(B==v){B=t;}R={position:B};d.each([U,G],function(az){L[az]=Y.getStyle(az);R[az]=T.getStyle(az);});d.each([U,ap,N,G],function(aA){var az=ae+ao(aA);L[az]=Y.getStyle(az);R[az]=T.getStyle(az);});Y.setStyles(R);T.setStyles(L);T.setStyles({margin:0});Y.set(ac,T.get(ac));Y.set(af,T.get(af));},_extractHandleName:d.cached(function(R){var L=R.get(e),B=L.match(new RegExp(j(av,aw,"(\\w{1,2})\\b")));return B?B[1]:null;}),_getInfo:function(Y,B){var az,aB=B.dragEvent.target,aA=Y.getXY(),T=aA[0],R=aA[1],L=Y.get(ac),aC=Y.get(af);if(B){az=(aB.actXY.length?aB.actXY:aB.lastXY);}return{actXY:az,bottom:(R+L),left:T,offsetHeight:L,offsetWidth:aC,right:(T+aC),top:R};},_resize:function(){var B=this,T=B.get(ag),az=B.info,Y=B.originalInfo,R=az.actXY[0]-Y.actXY[0],L=az.actXY[1]-Y.actXY[1],aA={t:function(){az.top=Y.top+L;az.offsetHeight=Y.offsetHeight-L;},r:function(){az.offsetWidth=Y.offsetWidth+R;},l:function(){az.left=Y.left+R;az.offsetWidth=Y.offsetWidth-R;},b:function(){az.offsetHeight=Y.offsetHeight+L;},tr:function(){this.t();this.r();},br:function(){this.b();this.r();},tl:function(){this.t();this.l();},bl:function(){this.b();this.l();}};aA[T](R,L);},_setOffset:function(R,L,B){R.set(af,L);R.set(ac,B);},_syncUI:function(){var B=this,R=B.info,T=B.get(at),L=B.get(au);B._setOffset(T,R.offsetWidth,R.offsetHeight);if(B.changeLeftHandles||B.changeTopHandles){T.setXY([R.left,R.top]);}if(!T.compareTo(L)){B._setOffset(L,R.offsetWidth,R.offsetHeight);}if(d.UA.webkit){L.setStyle(av,X);}},_syncProxyUI:function(){var B=this,T=B.info,R=B.get(o),L=B.get(aj),Y=R.getStyle(Z);L.show().setStyle(Z,Y);
B.delegate.dd.set(aq,Y);B._setOffset(L,T.offsetWidth,T.offsetHeight);L.setXY([T.left,T.top]);},_updateChangeHandleInfo:function(L){var B=this;B.changeHeightHandles=B.REGEX_CHANGE_HEIGHT.test(L);B.changeLeftHandles=B.REGEX_CHANGE_LEFT.test(L);B.changeTopHandles=B.REGEX_CHANGE_TOP.test(L);B.changeWidthHandles=B.REGEX_CHANGE_WIDTH.test(L);},_updateInfo:function(L){var B=this;B.info=B._getInfo(B.get(at),L);},_setActiveHandlesUI:function(R){var B=this,L=B.get(o);if(L){if(R){B.eachHandle(function(T){T.removeClass(k);});L.addClass(k);}else{L.removeClass(k);}}},_setHandles:function(R){var B=this,L=[];if(H(R)){L=R;}else{if(s(R)){if(R.toLowerCase()==am){L=B.ALL_HANDLES;}else{d.each(R.split(y),function(Y,T){var az=a(Y);if(z(B.ALL_HANDLES,az)>-1){L.push(az);}});}}}return L;},_setHideHandlesUI:function(L){var B=this,R=B.get(at);if(!B.get(ad)){if(L){R.addClass(C);}else{R.removeClass(C);}}},_setWrap:function(T){var B=this,R=B.get(au),Y=R.get(ai),L=B.get(r);if(L.test(Y)){T=true;}return T;},_setWrapper:function(){var B=this,R=B.get(au),L=R.get(u),T=R;if(B.get(l)){T=d.Node.create(B.WRAP_TEMPLATE);if(L){L.insertBefore(T,R);}T.append(R);B._copyStyles(R,T);R.setStyles({position:v,left:0,top:0});}return T;},_defMouseUpFn:function(L){var B=this;B.set(ad,false);},_defResizeFn:function(L){var B=this;B._handleResizeAlignEvent(L.dragEvent);if(B.get(ax)){B._syncProxyUI();}else{B._syncUI();}},_defResizeAlignFn:function(L){var B=this,R;B.lastInfo=B.info;B._updateInfo(L);R=B.info;B._resize();if(!B.con){if(R.offsetHeight<=15){B._checkSize(ac,15);}if(R.offsetWidth<=15){B._checkSize(af,15);}}},_defResizeEndFn:function(R){var B=this,L=R.dragEvent.target;L.actXY=[];if(B.get(ax)){B._syncProxyUI();B.get(aj).hide();}B._syncUI();B.set(ag,null);B.set(o,null);B._setActiveHandlesUI(false);},_defResizeStartFn:function(L){var B=this;B.set(ad,true);B.originalInfo=B._getInfo(B.get(at),L);B._updateInfo(L);if(B.get(ax)){B._renderProxy();}},_handleMouseUpEvent:function(B){this.fire(K,{dragEvent:B,info:this.info});},_handleResizeEvent:function(B){this.fire(x,{dragEvent:B,info:this.info});},_handleResizeAlignEvent:function(B){this.fire(A,{dragEvent:B,info:this.info});},_handleResizeEndEvent:function(B){this.fire(W,{dragEvent:B,info:this.info});},_handleResizeStartEvent:function(B){this.fire(c,{dragEvent:B,info:this.info});},_onWrapperMouseEnter:function(L){var B=this;if(B.get(I)){B._setHideHandlesUI(false);}},_onWrapperMouseLeave:function(L){var B=this;if(B.get(I)){B._setHideHandlesUI(true);}},_onHandleMouseEnter:function(R){var B=this,L=R.currentTarget,T=B._extractHandleName(L);if(!B.get(ad)){B.set(ag,T);B.set(o,L);B._setActiveHandlesUI(true);B._updateChangeHandleInfo(T);}},_onHandleMouseLeave:function(L){var B=this;if(!B.get(ad)){B._setActiveHandlesUI(false);}}});d.each(d.Resize.prototype.ALL_HANDLES,function(L,B){d.Resize.ATTRS[E(L)]={setter:function(){return this._buildHandle(L);},value:null,writeOnce:true};});},"@VERSION@",{skinnable:true,requires:["base","widget","substitute","event","oop","dd-drag","dd-delegate","dd-drop"]});