sync
[roojs1] / roojs-core.js
index 7f12b84..a07d60e 100644 (file)
@@ -132,7 +132,7 @@ this.anim({opacity:{to:(AY?1:0)}},this.preanim(arguments,1),null,.35,'easeIn',fu
 Roo.get(dom).setOpacity(1);}});}return this;},isDisplayed:function(){return this.getStyle("display")!="none";},toggle:function(Aa){this.setVisible(!this.isVisible(),this.preanim(arguments,0));return this;},setDisplayed:function(Ab){if(typeof Ab=="boolean"){Ab=Ab?this.originalDisplay:"none";}
 this.setStyle("display",Ab);return this;},focus:function(){try{this.dom.focus();}catch(e){}return this;},blur:function(){try{this.dom.blur();}catch(e){}return this;},addClass:function(Ac){if(Ac instanceof Array){for(var i=0,len=Ac.length;i<len;i++){this.addClass(Ac[i]);}}else {if(Ac&&!this.hasClass(Ac)){this.dom.className=this.dom.className+" "+Ac;}}return this;},radioClass:function(Ad){var Ae=this.dom.parentNode.childNodes;for(var i=0;i<Ae.length;i++){var s=Ae[i];if(s.nodeType==1){Roo.get(s).removeClass(Ad);}}
 this.addClass(Ad);return this;},removeClass:function(Af){if(!Af||!this.dom.className){return this;}if(Af instanceof Array){for(var i=0,len=Af.length;i<len;i++){this.removeClass(Af[i]);}}else {if(this.hasClass(Af)){var re=this.classReCache[Af];if(!re){re=new RegExp('(?:^|\\s+)'+Af+'(?:\\s+|$)',"g");this.classReCache[Af]=re;}
-this.dom.className=this.dom.className.replace(re," ");}}return this;},classReCache:{},toggleClass:function(Ag){if(this.hasClass(Ag)){this.removeClass(Ag);}else {this.addClass(Ag);}return this;},hasClass:function(Ah){return Ah&&(' '+this.dom.className+' ').indexOf(' '+Ah+' ')!=-1;},replaceClass:function(Ai,Aj){this.removeClass(Ai);this.addClass(Aj);return this;},getStyles:function(){var a=arguments,Ak=a.length,r={};for(var i=0;i<Ak;i++){r[a[i]]=this.getStyle(a[i]);}return r;},getStyle:function(){return G&&G.getComputedStyle?function(Al){var el=this.dom,v,cs,Am;if(Al=='float'){Al="cssFloat";}if(el.style&&(v=el.style[Al])){return v;}if(cs=G.getComputedStyle(el,"")){if(!(Am=B[Al])){Am=B[Al]=Al.replace(C,F);}return cs[Am];}return null;}:function(Al){var el=this.dom,v,cs,Am;if(Al=='opacity'){if(typeof el.style.filter=='string'){var m=el.style.filter.match(/alpha\(opacity=(.*)\)/i);if(m){var fv=parseFloat(m[1]);if(!isNaN(fv)){return fv?fv/100:0;}}}return 1;}else if(Al=='float'){Al="styleFloat";}if(!(Am=B[Al])){Am=B[Al]=Al.replace(C,F);}if(v=el.style[Am]){return v;}if(cs=el.currentStyle){return cs[Am];}return null;};}(),setStyle:function(Al,Am){if(typeof Al=="string"){var camel;if(!(camel=B[Al])){camel=B[Al]=Al.replace(C,F);}if(camel=='opacity'){this.setOpacity(Am);}else {this.dom.style[camel]=Am;}}else {for(var style in Al){if(typeof Al[style]!="function"){this.setStyle(style,Al[style]);}}}return this;},applyStyles:function(An){Roo.DomHelper.applyStyles(this.dom,An);return this;},getX:function(){return D.getX(this.dom);},getY:function(){return D.getY(this.dom);},getXY:function(){return D.getXY(this.dom);},setX:function(x,Ao){if(!Ao||!A){D.setX(this.dom,x);}else {this.setXY([x,this.getY()],this.preanim(arguments,1));}return this;},setY:function(y,Ap){if(!Ap||!A){D.setY(this.dom,y);}else {this.setXY([this.getX(),y],this.preanim(arguments,1));}return this;},setLeft:function(Aq){this.setStyle("left",this.addUnits(Aq));return this;},setTop:function(Ar){this.setStyle("top",this.addUnits(Ar));return this;},setRight:function(As){this.setStyle("right",this.addUnits(As));return this;},setBottom:function(At){this.setStyle("bottom",this.addUnits(At));return this;},setXY:function(Au,Av){if(!Av||!A){D.setXY(this.dom,Au);}else {this.anim({points:{to:Au}},this.preanim(arguments,1),'motion');}return this;},setLocation:function(x,y,Aw){this.setXY([x,y],this.preanim(arguments,2));return this;},moveTo:function(x,y,Ax){this.setXY([x,y],this.preanim(arguments,2));return this;},getRegion:function(){return D.getRegion(this.dom);},getHeight:function(Ay){var h=this.dom.offsetHeight||0;return Ay!==true?h:h-this.getBorderWidth("tb")-this.getPadding("tb");},getWidth:function(Az){var w=this.dom.offsetWidth||0;return Az!==true?w:w-this.getBorderWidth("lr")-this.getPadding("lr");},getComputedHeight:function(){var h=Math.max(this.dom.offsetHeight,this.dom.clientHeight);if(!h){h=parseInt(this.getStyle('height'),10)||0;if(!this.isBorderBox()){h+=this.getFrameWidth('tb');}}return h;},getComputedWidth:function(){var w=Math.max(this.dom.offsetWidth,this.dom.clientWidth);if(!w){w=parseInt(this.getStyle('width'),10)||0;if(!this.isBorderBox()){w+=this.getFrameWidth('lr');}}return w;},getSize:function(A0){return {width:this.getWidth(A0),height:this.getHeight(A0)};},getViewSize:function(){var d=this.dom,A1=document,aw=0,ah=0;if(d==A1||d==A1.body){return {width:D.getViewWidth(),height:D.getViewHeight()};}else {return {width:d.clientWidth,height:d.clientHeight};}},getValue:function(A2){return A2?parseInt(this.dom.value,10):this.dom.value;},adjustWidth:function(A3){if(typeof A3=="number"){if(this.autoBoxAdjust&&!this.isBorderBox()){A3-=(this.getBorderWidth("lr")+this.getPadding("lr"));}if(A3<0){A3=0;}}return A3;},adjustHeight:function(A4){if(typeof A4=="number"){if(this.autoBoxAdjust&&!this.isBorderBox()){A4-=(this.getBorderWidth("tb")+this.getPadding("tb"));}if(A4<0){A4=0;}}return A4;},setWidth:function(A5,A6){A5=this.adjustWidth(A5);if(!A6||!A){this.dom.style.width=this.addUnits(A5);}else {this.anim({width:{to:A5}},this.preanim(arguments,1));}return this;},setHeight:function(A7,A8){A7=this.adjustHeight(A7);if(!A8||!A){this.dom.style.height=this.addUnits(A7);}else {this.anim({height:{to:A7}},this.preanim(arguments,1));}return this;},setSize:function(A9,BA,BB){if(typeof A9=="object"){BA=A9.height;A9=A9.width;}
+this.dom.className=this.dom.className.replace(re," ");}}return this;},classReCache:{},toggleClass:function(Ag){if(this.hasClass(Ag)){this.removeClass(Ag);}else {this.addClass(Ag);}return this;},hasClass:function(Ah){return Ah&&(' '+this.dom.className+' ').indexOf(' '+Ah+' ')!=-1;},replaceClass:function(Ai,Aj){this.removeClass(Ai);this.addClass(Aj);return this;},getStyles:function(){var a=arguments,Ak=a.length,r={};for(var i=0;i<Ak;i++){r[a[i]]=this.getStyle(a[i]);}return r;},getStyle:function(){return G&&G.getComputedStyle?function(Al){var el=this.dom,v,cs,Am;if(Al=='float'){Al="cssFloat";}if(el.style&&(v=el.style[Al])){return v;}if(cs=G.getComputedStyle(el,"")){if(!(Am=B[Al])){Am=B[Al]=Al.replace(C,F);}return cs[Am];}return null;}:function(Al){var el=this.dom,v,cs,Am;if(Al=='opacity'){if(typeof el.style.filter=='string'){var m=el.style.filter.match(/alpha\(opacity=(.*)\)/i);if(m){var fv=parseFloat(m[1]);if(!isNaN(fv)){return fv?fv/100:0;}}}return 1;}else if(Al=='float'){Al="styleFloat";}if(!(Am=B[Al])){Am=B[Al]=Al.replace(C,F);}if(v=el.style[Am]){return v;}if(cs=el.currentStyle){return cs[Am];}return null;};}(),setStyle:function(Al,Am){if(typeof Al=="string"){if(Al=='float'){this.setStyle(Roo.isIE?'styleFloat':'cssFloat',Am);return this;}var camel;if(!(camel=B[Al])){camel=B[Al]=Al.replace(C,F);}if(camel=='opacity'){this.setOpacity(Am);}else {this.dom.style[camel]=Am;}}else {for(var style in Al){if(typeof Al[style]!="function"){this.setStyle(style,Al[style]);}}}return this;},applyStyles:function(An){Roo.DomHelper.applyStyles(this.dom,An);return this;},getX:function(){return D.getX(this.dom);},getY:function(){return D.getY(this.dom);},getXY:function(){return D.getXY(this.dom);},setX:function(x,Ao){if(!Ao||!A){D.setX(this.dom,x);}else {this.setXY([x,this.getY()],this.preanim(arguments,1));}return this;},setY:function(y,Ap){if(!Ap||!A){D.setY(this.dom,y);}else {this.setXY([this.getX(),y],this.preanim(arguments,1));}return this;},setLeft:function(Aq){this.setStyle("left",this.addUnits(Aq));return this;},setTop:function(Ar){this.setStyle("top",this.addUnits(Ar));return this;},setRight:function(As){this.setStyle("right",this.addUnits(As));return this;},setBottom:function(At){this.setStyle("bottom",this.addUnits(At));return this;},setXY:function(Au,Av){if(!Av||!A){D.setXY(this.dom,Au);}else {this.anim({points:{to:Au}},this.preanim(arguments,1),'motion');}return this;},setLocation:function(x,y,Aw){this.setXY([x,y],this.preanim(arguments,2));return this;},moveTo:function(x,y,Ax){this.setXY([x,y],this.preanim(arguments,2));return this;},getRegion:function(){return D.getRegion(this.dom);},getHeight:function(Ay){var h=this.dom.offsetHeight||0;return Ay!==true?h:h-this.getBorderWidth("tb")-this.getPadding("tb");},getWidth:function(Az){var w=this.dom.offsetWidth||0;return Az!==true?w:w-this.getBorderWidth("lr")-this.getPadding("lr");},getComputedHeight:function(){var h=Math.max(this.dom.offsetHeight,this.dom.clientHeight);if(!h){h=parseInt(this.getStyle('height'),10)||0;if(!this.isBorderBox()){h+=this.getFrameWidth('tb');}}return h;},getComputedWidth:function(){var w=Math.max(this.dom.offsetWidth,this.dom.clientWidth);if(!w){w=parseInt(this.getStyle('width'),10)||0;if(!this.isBorderBox()){w+=this.getFrameWidth('lr');}}return w;},getSize:function(A0){return {width:this.getWidth(A0),height:this.getHeight(A0)};},getViewSize:function(){var d=this.dom,A1=document,aw=0,ah=0;if(d==A1||d==A1.body){return {width:D.getViewWidth(),height:D.getViewHeight()};}else {return {width:d.clientWidth,height:d.clientHeight};}},getValue:function(A2){return A2?parseInt(this.dom.value,10):this.dom.value;},adjustWidth:function(A3){if(typeof A3=="number"){if(this.autoBoxAdjust&&!this.isBorderBox()){A3-=(this.getBorderWidth("lr")+this.getPadding("lr"));}if(A3<0){A3=0;}}return A3;},adjustHeight:function(A4){if(typeof A4=="number"){if(this.autoBoxAdjust&&!this.isBorderBox()){A4-=(this.getBorderWidth("tb")+this.getPadding("tb"));}if(A4<0){A4=0;}}return A4;},setWidth:function(A5,A6){A5=this.adjustWidth(A5);if(!A6||!A){this.dom.style.width=this.addUnits(A5);}else {this.anim({width:{to:A5}},this.preanim(arguments,1));}return this;},setHeight:function(A7,A8){A7=this.adjustHeight(A7);if(!A8||!A){this.dom.style.height=this.addUnits(A7);}else {this.anim({height:{to:A7}},this.preanim(arguments,1));}return this;},setSize:function(A9,BA,BB){if(typeof A9=="object"){BA=A9.height;A9=A9.width;}
 A9=this.adjustWidth(A9);BA=this.adjustHeight(BA);if(!BB||!A){this.dom.style.width=this.addUnits(A9);this.dom.style.height=this.addUnits(BA);}else {this.anim({width:{to:A9},height:{to:BA}},this.preanim(arguments,2));}return this;},setBounds:function(x,y,BC,BD,BE){if(!BE||!A){this.setSize(BC,BD);this.setLocation(x,y);}else {BC=this.adjustWidth(BC);BD=this.adjustHeight(BD);this.anim({points:{to:[x,y]},width:{to:BC},height:{to:BD}},this.preanim(arguments,4),'motion');}return this;},setRegion:function(BF,BG){this.setBounds(BF.left,BF.top,BF.right-BF.left,BF.bottom-BF.top,this.preanim(arguments,1));return this;},addListener:function(BH,fn,BI,BJ){Roo.EventManager.on(this.dom,BH,fn,BI||this,BJ);},removeListener:function(BK,fn){Roo.EventManager.removeListener(this.dom,BK,fn);return this;},removeAllListeners:function(){E.purgeElement(this.dom);return this;},relayEvent:function(BL,BM){this.on(BL,function(e){BM.fireEvent(BL,e);});},setOpacity:function(BN,BO){if(!BO||!A){var s=this.dom.style;if(Roo.isIE){s.zoom=1;s.filter=(s.filter||'').replace(/alpha\([^\)]*\)/gi,"")+(BN==1?"":"alpha(opacity="+BN*100+")");}else {s.opacity=BN;}}else {this.anim({opacity:{to:BN}},this.preanim(arguments,1),null,.35,'easeIn');}return this;},getLeft:function(BP){if(!BP){return this.getX();}else {return parseInt(this.getStyle("left"),10)||0;}},getRight:function(BQ){if(!BQ){return this.getX()+this.getWidth();}else {return (this.getLeft(true)+this.getWidth())||0;}},getTop:function(BR){if(!BR){return this.getY();}else {return parseInt(this.getStyle("top"),10)||0;}},getBottom:function(BS){if(!BS){return this.getY()+this.getHeight();}else {return (this.getTop(true)+this.getHeight())||0;}},position:function(BT,BU,x,y){if(!BT){if(this.getStyle('position')=='static'){this.setStyle('position','relative');}}else {this.setStyle("position",BT);}if(BU){this.setStyle("z-index",BU);}if(x!==undefined&&y!==undefined){this.setXY([x,y]);}else if(x!==undefined){this.setX(x);}else if(y!==undefined){this.setY(y);}},clearPositioning:function(BV){BV=BV||'';this.setStyle({"left":BV,"right":BV,"top":BV,"bottom":BV,"z-index":"","position":"static"});return this;},getPositioning:function(){var l=this.getStyle("left");var t=this.getStyle("top");return {"position":this.getStyle("position"),"left":l,"right":l?"":this.getStyle("right"),"top":t,"bottom":t?"":this.getStyle("bottom"),"z-index":this.getStyle("z-index")};},getBorderWidth:function(BW){return this.addStyles(BW,El.borders);},getPadding:function(BX){return this.addStyles(BX,El.paddings);},setPositioning:function(pc){this.applyStyles(pc);if(pc.right=="auto"){this.dom.style.right="";}if(pc.bottom=="auto"){this.dom.style.bottom="";}return this;},fixDisplay:function(){if(this.getStyle("display")=="none"){this.setStyle("visibility","hidden");this.setStyle("display",this.originalDisplay);if(this.getStyle("display")=="none"){this.setStyle("display","block");}}},setLeftTop:function(BY,BZ){this.dom.style.left=this.addUnits(BY);this.dom.style.top=this.addUnits(BZ);return this;},move:function(Ba,Bb,Bc){var xy=this.getXY();Ba=Ba.toLowerCase();switch(Ba){case "l":case "left":this.moveTo(xy[0]-Bb,xy[1],this.preanim(arguments,2));break;case "r":case "right":this.moveTo(xy[0]+Bb,xy[1],this.preanim(arguments,2));break;case "t":case "top":case "up":this.moveTo(xy[0],xy[1]-Bb,this.preanim(arguments,2));break;case "b":case "bottom":case "down":this.moveTo(xy[0],xy[1]+Bb,this.preanim(arguments,2));break;}return this;},clip:function(){if(!this.isClipped){this.isClipped=true;this.originalClip={"o":this.getStyle("overflow"),"x":this.getStyle("overflow-x"),"y":this.getStyle("overflow-y")};this.setStyle("overflow","hidden");this.setStyle("overflow-x","hidden");this.setStyle("overflow-y","hidden");}return this;},unclip:function(){if(this.isClipped){this.isClipped=false;var o=this.originalClip;if(o.o){this.setStyle("overflow",o.o);}if(o.x){this.setStyle("overflow-x",o.x);}if(o.y){this.setStyle("overflow-y",o.y);}}return this;},getAnchorXY:function(Bd,Be,s){var w,h,vp=false;if(!s){var d=this.dom;if(d==document.body||d==document){vp=true;w=D.getViewWidth();h=D.getViewHeight();}else {w=this.getWidth();h=this.getHeight();}}else {w=s.width;h=s.height;}var x=0,y=0,r=Math.round;switch((Bd||"tl").toLowerCase()){case "c":x=r(w*.5);y=r(h*.5);break;case "t":x=r(w*.5);y=0;break;case "l":x=0;y=r(h*.5);break;case "r":x=w;y=r(h*.5);break;case "b":x=r(w*.5);y=h;break;case "tl":x=0;y=0;break;case "bl":x=0;y=h;break;case "br":x=w;y=h;break;case "tr":x=w;y=0;break;}if(Be===true){return [x,y];}if(vp){var sc=this.getScroll();return [x+sc.left,y+sc.top];}var o=this.getXY();return [x+o[0],y+o[1]];},getAlignToXY:function(el,p,o){el=Roo.get(el);var d=this.dom;if(!el.dom){throw "Element.alignTo with an element that doesn't exist";}var c=false;var p1="",p2="";o=o||[0,0];if(!p){p="tl-bl";}else if(p=="?"){p="tl-bl?";}else if(p.indexOf("-")==-1){p="tl-"+p;}
 p=p.toLowerCase();var m=p.match(/^([a-z]+)-([a-z]+)(\?)?$/);if(!m){throw "Element.alignTo with an invalid alignment "+p;}
 p1=m[1];p2=m[2];c=!!m[3];var a1=this.getAnchorXY(p1,true);var a2=el.getAnchorXY(p2,false);var x=a2[0]-a1[0]+o[0];var y=a2[1]-a1[1]+o[1];if(c){var w=this.getWidth(),h=this.getHeight(),r=el.getRegion();var dw=D.getViewWidth()-5,dh=D.getViewHeight()-5;var p1y=p1.charAt(0),p1x=p1.charAt(p1.length-1);var p2y=p2.charAt(0),p2x=p2.charAt(p2.length-1);var swapY=((p1y=="t"&&p2y=="b")||(p1y=="b"&&p2y=="t"));var swapX=((p1x=="r"&&p2x=="l")||(p1x=="l"&&p2x=="r"));var A1=document;var scrollX=(A1.documentElement.scrollLeft||A1.body.scrollLeft||0)+5;var scrollY=(A1.documentElement.scrollTop||A1.body.scrollTop||0)+5;if((x+w)>dw+scrollX){x=swapX?r.left-w:dw+scrollX-w;}if(x<scrollX){x=swapX?r.right:scrollX;}if((y+h)>dh+scrollY){y=swapY?r.top-h:dh+scrollY-h;}if(y<scrollY){y=swapY?r.bottom:scrollY;}}return [x,y];},getConstrainToXY:function(){var os={top:0,left:0,bottom:0,right:0};return function(el,Bf,Bg,Bh){el=Roo.get(el);Bg=Bg?Roo.applyIf(Bg,os):os;var vw,vh,vx=0,vy=0;if(el.dom==document.body||el.dom==document){vw=Roo.lib.Dom.getViewWidth();vh=Roo.lib.Dom.getViewHeight();}else {vw=el.dom.clientWidth;vh=el.dom.clientHeight;if(!Bf){var vxy=el.getXY();vx=vxy[0];vy=vxy[1];}}var s=el.getScroll();vx+=Bg.left+s.left;vy+=Bg.top+s.top;vw-=Bg.right;vh-=Bg.bottom;var vr=vx+vw;var vb=vy+vh;var xy=Bh||(!Bf?this.getXY():[this.getLeft(true),this.getTop(true)]);var x=xy[0],y=xy[1];var w=this.dom.offsetWidth,h=this.dom.offsetHeight;var Bi=false;if((x+w)>vr){x=vr-w;Bi=true;}if((y+h)>vb){y=vb-h;Bi=true;}if(x<vx){x=vx;Bi=true;}if(y<vy){y=vy;Bi=true;}return Bi?[x,y]:false;};}(),adjustForConstraints:function(xy,Bf,Bg){return this.getConstrainToXY(Bf||document,false,Bg,xy)||xy;},alignTo:function(Bh,Bi,Bj,Bk){var xy=this.getAlignToXY(Bh,Bi,Bj);this.setXY(xy,this.preanim(arguments,3));return this;},anchorTo:function(el,Bl,Bm,Bn,Bo,Bp){var Bq=function(){this.alignTo(el,Bl,Bm,Bn);Roo.callback(Bp,this);};Roo.EventManager.onWindowResize(Bq,this);var tm=typeof Bo;if(tm!='undefined'){Roo.EventManager.on(window,'scroll',Bq,this,{buffer:tm=='number'?Bo:50});}