widget-min.js revision 8ab6c5a43c971d3f5b9f12ea6e5794a394a9a19c
YUI.add("widget",function(F){var T=F.Lang;function k(L){this._plugins={};this.after("init",function(Y,O){this._initPlugins(O);});this.after("destroy",this._destroyPlugins);}k.prototype={plug:function(Y){if(Y){if(T.isArray(Y)){var O=Y.length;for(var L=0;L<O;L++){this.plug(Y[L]);}}else{if(T.isFunction(Y)){this._plug(Y);}else{this._plug(Y.fn,Y.cfg);}}}return this;},unplug:function(L){if(L){this._unplug(L);}else{for(L in this._plugins){if(F.Object.owns(this._plugins,L)){this._unplug(L);}}}return this;},hasPlugin:function(L){return(this._plugins[L]&&this[L]);},_initPlugins:function(L){var Y=this._getClasses(),m;for(var O=Y.length-1;O>=0;O--){m=Y[O];if(m.PLUGINS){this.plug(m.PLUGINS);}}if(L&&L.plugins){this.plug(L.plugins);}},_destroyPlugins:function(){this._unplug();},_plug:function(Y,L){if(Y&&Y.NS){var O=Y.NS;L=L||{};L.owner=this;if(this.hasPlugin(O)){this[O].setAttrs(L);}else{this[O]=new Y(L);this._plugins[O]=Y;}}},_unplug:function(L){if(L){if(this[L]){this[L].destroy();delete this[L];}if(this._plugins[L]){delete this._plugins[L];}}}};F.PluginHost=k;var c="widget",P="content",e="visible",g="hidden",h="disabled",H="focus",D="blur",A="hasFocus",J="width",a="height",l="",b="-",j="boundingBox",W="contentBox",S="parentNode",C="firstChild",d="ownerDocument",f="body",E="tabIndex",I="locale",K="initValue",U="id",V="render",B="rendered",Z="destroyed",N="contentUpdate",M=F.Object,i=F.Node,Q=F.ClassNameManager;var X={};function G(L){this._yuid=F.guid(c);this._strings={};G.superclass.constructor.apply(this,arguments);}G._buildCfg={aggregates:["PLUGINS","HTML_PARSER"]};G.NAME=c;G.UI_SRC="ui";var R=G.UI_SRC;G.ATTRS={rendered:{value:false,readOnly:true},boundingBox:{value:null,set:function(L){return this._setBoundingBox(L);},writeOnce:true},contentBox:{value:null,set:function(L){return this._setContentBox(L);},writeOnce:true},tabIndex:{value:0},hasFocus:{value:false},disabled:{value:false},visible:{value:true},height:{value:l},width:{value:l},moveStyles:{value:false},locale:{value:"en"},strings:{set:function(L){return this._setStrings(L,this.get(I));},get:function(){return this.getStrings(this.get(I));}}};G._NAME_LOWERCASE=G.NAME.toLowerCase();G.getClassName=function(){var L=F.Array(arguments,0,true);L.splice(0,0,this._NAME_LOWERCASE);return Q.getClassName.apply(Q,L);};G.getByNode=function(L){var O,Y=G.getClassName();L=i.get(L);if(L){L=(L.hasClass(Y))?L:L.ancestor("."+Y);if(L){O=X[L.get(U)];}}return O||null;};G.HTML_PARSER={};F.extend(G,F.Base,{getClassName:function(){var L=F.Array(arguments,0,true);L.splice(0,0,this._name);return Q.getClassName.apply(Q,L);},initializer:function(L){this.publish(N,{preventable:false});this._name=this.constructor.NAME.toLowerCase();var Y=this.get(j).get(U);if(Y){X[Y]=this;}var O=this._parseHTML(this.get(W));if(O){F.aggregate(L,O,false);}F.PluginHost.call(this,L);},destructor:function(){var L=this.get(j);F.Event.purgeElement(L,true);var O=L.get(U);if(O&&O in X){delete X[O];}},render:function(L){if(this.get(Z)){return;}if(!this.get(B)){this.publish(V,{queuable:false,defaultFn:this._defRenderFn});L=(L)?i.get(L):null;if(L&&!L.inDoc()){L=null;}this.fire(V,null,L);}return this;},_defRenderFn:function(O,L){this._renderUI(L);this._bindUI();this._syncUI();this.renderer();this._set(B,true);},renderer:function(){this.renderUI();this.bindUI();this.syncUI();},bindUI:function(){},renderUI:function(){},syncUI:function(){},hide:function(){return this.set(e,false);},show:function(){return this.set(e,true);},focus:function(){return this.set(A,true);},blur:function(){return this.set(A,false);},enable:function(){return this.set(h,false);},disable:function(){return this.set(h,true);},_parseHTML:function(O){var L=this._getHtmlParser(),Y,m;if(L&&O&&O.hasChildNodes()){M.each(L,function(p,n,q){m=null;if(T.isFunction(p)){m=p.call(this,O);}else{if(T.isArray(p)){m=O.queryAll(p[0]);}else{m=O.query(p);}}if(m!==null&&m!==undefined){Y=Y||{};Y[n]=m;}},this);}return Y;},_moveStyles:function(n,p){var m=this.WRAP_STYLES,q=n.getStyle("position"),O=this.get(W),o=[0,0],Y,L;if(!this.get("height")){Y=O.get("offsetHeight");}if(!this.get("width")){L=O.get("offsetWidth");}if(q==="absolute"){o=n.getXY();p.setStyles({right:"auto",bottom:"auto"});n.setStyles({right:"auto",bottom:"auto"});}F.each(m,function(t,r){var u=n.getStyle(r);p.setStyle(r,u);if(t===false){n.setStyle(r,"");}else{n.setStyle(r,t);}});if(q==="absolute"){p.setXY(o);}if(Y){this.set("height",Y);}if(L){this.set("width",L);}},_renderBox:function(O){var Y=this.get(W),m=this.get(j),n=m.get(d)||Y.get(d),L;if(!m.compareTo(Y.get(S))){if(this.get("moveStyles")){this._moveStyles(Y,m);}if(Y.inDoc(n)){Y.get(S).replaceChild(m,Y);}m.appendChild(Y);}if(!m.inDoc(n)&&!O){L=i.get(f);if(L.get(C)){L.insertBefore(m,L.get(C));}else{L.appendChild(m);}}else{if(O&&!O.compareTo(m.get(S))){O.appendChild(m);}}},_setBoundingBox:function(L){return this._setBox(L,this.BOUNDING_TEMPLATE);},_setContentBox:function(L){return this._setBox(L,this.CONTENT_TEMPLATE);},_setBox:function(Y,O){Y=i.get(Y)||i.create(O);var L=F.stamp(Y);if(!Y.get(U)){Y.set(U,L);}return Y;},_renderUI:function(L){this._renderBoxClassNames();this._renderBox(L);},_renderBoxClassNames:function(){var n=this._getClasses(),Y=this.get(j),L=this.get(W),O,m;Y.addClass(G.getClassName());for(m=n.length-3;m>=0;m--){O=n[m].NAME;if(O){Y.addClass(Q.getClassName(O.toLowerCase()));}}L.addClass(this.getClassName(P));},_bindUI:function(){this.after("visibleChange",this._afterVisibleChange);this.after("disabledChange",this._afterDisabledChange);this.after("heightChange",this._afterHeightChange);this.after("widthChange",this._afterWidthChange);this.after("hasFocusChange",this._afterHasFocusChange);this._bindDOMListeners();},_bindDOMListeners:function(){this.get(j).on(H,F.bind(this._onFocus,this));this.get(j).on(D,F.bind(this._onBlur,this));},_syncUI:function(){this._uiSetVisible(this.get(e));this._uiSetDisabled(this.get(h));this._uiSetHeight(this.get(a));this._uiSetWidth(this.get(J));this._uiSetHasFocus(this.get(A));this._uiSetTabIndex(this.get(E));
},_uiSetHeight:function(L){if(T.isNumber(L)){L=L+this.DEF_UNIT;}this.get(j).setStyle(a,L);},_uiSetWidth:function(L){if(T.isNumber(L)){L=L+this.DEF_UNIT;}this.get(j).setStyle(J,L);},_uiSetVisible:function(Y){var O=this.get(j),L=this.getClassName(g);if(Y===true){O.removeClass(L);}else{O.addClass(L);}},_uiSetDisabled:function(Y){var O=this.get(j),L=this.getClassName(h);if(Y===true){O.addClass(L);}else{O.removeClass(L);}},_uiSetHasFocus:function(m,Y){var O=this.get(j),L=this.getClassName(H);if(m===true){O.addClass(L);if(Y!==R){O.focus();}}else{O.removeClass(L);if(Y!==R){O.blur();}}},_uiSetTabIndex:function(L){this.get(j).set(E,L);},_afterVisibleChange:function(L){this._uiSetVisible(L.newVal);},_afterDisabledChange:function(L){this._uiSetDisabled(L.newVal);},_afterHeightChange:function(L){this._uiSetHeight(L.newVal);},_afterWidthChange:function(L){this._uiSetWidth(L.newVal);},_afterHasFocusChange:function(L){this._uiSetHasFocus(L.newVal,L.src);},_onFocus:function(L){this.set(A,true,{src:R});},_onBlur:function(L){this.set(A,false,{src:R});},toString:function(){return this.constructor.NAME+"["+this._yuid+"]";},DEF_UNIT:"px",CONTENT_TEMPLATE:"<div></div>",BOUNDING_TEMPLATE:"<div></div>",WRAP_STYLES:{height:"100%",width:"100%",zIndex:false,position:"static",top:"0",left:"0",bottom:"",right:"",padding:"",margin:""},_setStrings:function(O,L){var Y=this._strings;L=L.toLowerCase();if(!Y[L]){Y[L]={};}F.aggregate(Y[L],O,true);return Y[L];},_getStrings:function(L){return this._strings[L.toLowerCase()];},getStrings:function(r){r=(r||this.get(I)).toLowerCase();var p=this.getDefaultLocale().toLowerCase(),O=this._getStrings(p),q=(O)?F.merge(O):{},o=r.split(b);if(r!==p||o.length>1){var L="";for(var m=0,Y=o.length;m<Y;++m){L+=o[m];var n=this._getStrings(L);if(n){F.aggregate(q,n,true);}L+=b;}}return q;},getString:function(Y,O){O=(O||this.get(I)).toLowerCase();var m=(this.getDefaultLocale()).toLowerCase(),n=this._getStrings(m)||{},o=n[Y],L=O.lastIndexOf(b);if(O!==m||L!=-1){do{n=this._getStrings(O);if(n&&Y in n){o=n[Y];break;}L=O.lastIndexOf(b);if(L!=-1){O=O.substring(0,L);}}while(L!=-1);}return o;},getDefaultLocale:function(){return this._conf.get(I,K);},_strings:null,_getHtmlParser:function(){if(!this._HTML_PARSER){var O=this._getClasses(),m={},L,Y;for(L=O.length-1;L>=0;L--){Y=O[L].HTML_PARSER;if(Y){F.mix(m,Y,true);}}this._HTML_PARSER=m;}return this._HTML_PARSER;}});G.PLUGINS=[];F.mix(G,F.PluginHost,false,null,1);F.Widget=G;},"@VERSION@",{requires:["base","node","classnamemanager"]});