widget-base-min.js revision fbe8205228375d3a502c60cdf5b080b32d85b227
YUI.add("widget-base",function(B){var G=B.Lang,T=B.Node,E=B.ClassNameManager,a=E.getClassName,q,U=B.cached(function(L){return L.substring(0,1).toUpperCase()+L.substring(1);}),j="content",u="visible",p="hidden",c="disabled",f="focused",D="width",e="height",r="boundingBox",Z="contentBox",K="parentNode",O="ownerDocument",k="offsetHeight",b="auto",J="srcNode",n="body",m="tabIndex",S="id",I="render",o="rendered",P="destroyed",A="strings",Q="<div></div>",d="Change",i="_uiSet",h="",l=function(){},M=/(\w+):(\w+)/,X="$2",W=true,s=false,V,N={},F=[u,c,e,D,f],g=B.UA.webkit,R=B.UA.ie,t="contentUpdate",H={};function C(Y){this._strs={};C.superclass.constructor.apply(this,arguments);var v=this.get(I),L;if(v){if(v!==W){L=v;}this.render(L);}}C.NAME="widget";V=C.UI_SRC="ui";C.ATTRS=N;N[S]={valueFn:"_guid",writeOnce:W};N[o]={value:s,readOnly:W};N[r]={value:null,setter:"_setBB",writeOnce:W};N[Z]={value:null,setter:"_setCB",writeOnce:W};N[m]={value:0,validator:"_validTabIndex"};N[f]={value:s,readOnly:W};N[c]={value:s};N[u]={value:W};N[e]={value:h};N[D]={value:h};N[A]={value:{},setter:"_strSetter",getter:"_strGetter"};N[I]={value:s,writeOnce:W};C._NAME=C.NAME.toLowerCase();C.getClassName=function(){return a.apply(E,[C._NAME].concat(B.Array(arguments)));};q=C.getClassName;C.getByNode=function(L){var v,Y=q();L=T.one(L);if(L){L=(L.hasClass(Y))?L:L.ancestor("."+Y);if(L){v=H[B.stamp(L,W)];}}return v||null;};B.extend(C,B.Base,{getClassName:function(){return a.apply(E,[this._name].concat(B.Array(arguments)));},initializer:function(L){this._name=this.constructor.NAME.toLowerCase();H[B.stamp(this.get(r))]=this;this.publish(t,{preventable:s});if(this._applyParser){this._applyParser(L);}},destructor:function(){var Y=this.get(r),L=B.stamp(Y,W);if(L in H){delete H[L];}this._unbindUI(Y);Y.remove(W);},render:function(L){if(!this.get(P)&&!this.get(o)){this.publish(I,{queuable:s,fireOnce:W,defaultFn:this._defRenderFn});this.fire(I,{parentNode:(L)?T.one(L):null});}return this;},_defRenderFn:function(L){if(L.target===this){this._renderUI(L.parentNode);this._bindUI();this._syncUI();this.renderer();this._set(o,W);}},renderer:function(){this.renderUI();this.bindUI();this.syncUI();},bindUI:l,renderUI:l,syncUI:l,hide:function(){return this.set(u,s);},show:function(){return this.set(u,W);},focus:function(){return this._set(f,W);},blur:function(){return this._set(f,s);},enable:function(){return this.set(c,s);},disable:function(){return this.set(c,W);},_uiSizeCB:function(v){var x=this.get(r),Y=this.get(Z),L=q("tmp","forcesize"),w=this._bbs,y=R&&R<7;if(w){Y.toggleClass(q(j,"expanded"),v);}else{if(v){if(y){x.addClass(L);}Y.set(k,x.get(k));if(y){x.removeClass(L);}}else{Y.setStyle(e,h);}}},_renderBox:function(L){var Y=this.get(Z),v=this.get(r),x=this.get(J),w=(x&&x.get(O))||v.get(O)||Y.get(O);if(x&&!x.compareTo(Y)&&!Y.inDoc(w)){x.replace(Y);}if(!v.compareTo(Y.get(K))&&!v.compareTo(Y)){if(Y.inDoc(w)){Y.replace(v);}v.appendChild(Y);}if(L){L.appendChild(v);}else{if(!v.inDoc(w)){T.one(n).insert(v,0);}}this._bbs=!(R&&R<8&&w.compatMode!="BackCompat");},_setBB:function(L){return this._setBox(this.get(S),L,this.BOUNDING_TEMPLATE);},_setCB:function(L){return(this.CONTENT_TEMPLATE===null)?this.get(r):this._setBox(null,L,this.CONTENT_TEMPLATE);},_setBox:function(v,Y,L){Y=T.one(Y)||T.create(L);if(!Y.get(S)){Y.set(S,v||B.guid());}return Y;},_renderUI:function(L){this._renderBoxClassNames();this._renderBox(L);},_renderBoxClassNames:function(){var v=this._getClasses(),L=this.get(r),Y;L.addClass(q());for(Y=v.length-3;Y>=0;Y--){L.addClass(E.getClassName(v[Y].NAME.toLowerCase()));}this.get(Z).addClass(this.getClassName(j));},_bindUI:function(){this._bindAttrUI(this._BIND_UI_ATTRS);this._bindDOM();},_unbindUI:function(L){this._unbindAttrUI(this._BIND_UI_ATTRS);this._unbindDOM(L);},_bindDOM:function(){var L=this.get(r).get(O);this._hDocFocus=L.on("focus",this._onDocFocus,this);if(g){this._hDocMouseDown=L.on("mousedown",this._onDocMouseDown,this);}},_unbindDOM:function(L){this._hDocFocus.detach();if(g){this._hDocMouseDown.detach();}},_syncUI:function(){this._syncAttrUI(this._SYNC_UI_ATTRS);},_uiSetHeight:function(L){this._uiSetDim(e,L);this._uiSizeCB((L!==h&&L!==b));},_uiSetWidth:function(L){this._uiSetDim(D,L);},_uiSetDim:function(L,Y){this.get(r).setStyle(L,G.isNumber(Y)?Y+this.DEF_UNIT:Y);},_uiSetVisible:function(L){this.get(r).toggleClass(this.getClassName(p),!L);},_uiSetDisabled:function(L){this.get(r).toggleClass(this.getClassName(c),L);},_uiSetFocused:function(v,Y){var L=this.get(r);L.toggleClass(this.getClassName(f),v);if(Y!==V){if(v){L.focus();}else{L.blur();}}},_uiSetTabIndex:function(Y){var L=this.get(r);if(G.isNumber(Y)){L.set(m,Y);}else{L.removeAttribute(m);}},_onDocMouseDown:function(L){if(this._hasDOMFocus){this._onDocFocus(L);}},_onDocFocus:function(Y){var L=this.get(r).contains(Y.target);this._hasDOMFocus=L;this._set(f,L,{src:V});},toString:function(){return this.constructor.NAME+"["+this.get(S)+"]";},DEF_UNIT:"px",CONTENT_TEMPLATE:Q,BOUNDING_TEMPLATE:Q,_guid:function(){return B.guid();},_validTabIndex:function(L){return(G.isNumber(L)||G.isNull(L));},_bindAttrUI:function(L){this._doBindAttrUI(L,W);},_unbindAttrUI:function(L){this._doBindAttrUI(L,s);},_syncAttrUI:function(v){var w,Y=v.length,L;for(w=0;w<Y;w++){L=v[w];this[i+U(L)](this.get(L));}},_doBindAttrUI:function(v,x){var w,L=v.length,Y=(x)?"after":"detach";for(w=0;w<L;w++){this[Y](v[w]+d,this._setAttrUI);}},_setAttrUI:function(L){this[i+U(L.attrName)](L.newVal,L.src);},_strSetter:function(L){return B.merge(this.get(A),L);},getString:function(L){return this.get(A)[L];},getStrings:function(){return this.get(A);},_BIND_UI_ATTRS:F,_SYNC_UI_ATTRS:F.concat(m),UI_EVENTS:{click:W,contextmenu:W,dblclick:W,keydown:W,keypress:W,keyup:W,mousedown:W,mousemove:W,mouseout:W,mouseover:W,mouseup:W,mouseenter:W,mouseleave:W},_getUIEventNode:function(){return this.get(r);},_createUIEvent:function(L){var v=this._getUIEventNode(),Y=this._uiEvts||{};if(!Y[L]){Y[L]=v.get(K).delegate(L,function(w){var x=C.getByNode(this);
x.fire(w.type,{domEvent:w});},"."+q());this._uiEvts=Y;}},on:function(L){if(G.isString(L)){var Y=L.replace(M,X);if(this.UI_EVENTS[Y]){this.after(I,function(){this._createUIEvent(Y);});}}return C.superclass.on.apply(this,arguments);}});B.Widget=C;},"@VERSION@",{requires:["attribute","event-focus","base","node","classnamemanager"]});