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