attribute-min.js revision a1eb4ab883f94a7346666b9784db277dd3418a23
YUI.add("attribute",function(B){B.State=function(){this.data={};};B.State.prototype={add:function(O,U,W){var V=this.data;V[U]=V[U]||{};V[U][O]=W;},addAll:function(O,V){var U;for(U in V){if(V.hasOwnProperty(U)){this.add(O,U,V[U]);}}},remove:function(O,U){var V=this.data;if(V[U]&&(O in V[U])){delete V[U][O];}},removeAll:function(O,V){var U=this.data;B.each(V||U,function(X,W){if(B.Lang.isString(W)){this.remove(O,W);}else{this.remove(O,X);}},this);},get:function(O,U){var V=this.data;return(V[U]&&O in V[U])?V[U][O]:undefined;},getAll:function(O){var V=this.data,U;B.each(V,function(X,W){if(O in V[W]){U=U||{};U[W]=X[O];}},this);return U;}};var H=B.Object,Q=".",N="Change",K="getter",J="setter",F="value",S="added",A="initializing",G="initValue",L="readOnly",R="writeOnce",T="validator",P="published",D="broadcast",M="defaultValue",E,I=B.EventTarget;function C(){this._ATTR_E_FACADE={};I.call(this,{emitFacade:true});this._conf=new B.State();}C.INVALID_VALUE={};E=C.INVALID_VALUE;C.prototype={addAttr:function(V,U){if(!this.attrAdded(V)){U=U||{};var X,W=(F in U),O=this._conf;if(W){X=U.value;delete U.value;}U[S]=true;U[A]=true;O.addAll(V,U);if(W){this.set(V,X);}O.remove(V,A);}else{}return this;},attrAdded:function(O){return !!(this._conf.get(O,S));},removeAttr:function(O){this._conf.removeAll(O);},get:function(V){var Y=V,U=this._conf,W,O,X;if(V.indexOf(Q)!==-1){W=V.split(Q);V=W.shift();}X=U.get(V,F);O=U.get(V,K);X=(O)?O.call(this,X,Y):X;X=(W)?H.getValue(X,W):X;return X;},set:function(O,V,U){return this._setAttr(O,V,U);},reset:function(U){if(U){this.set(U,this._conf.get(U,G));}else{var O=this._conf.data.initValue;B.each(O,function(V,W){this.set(W,V);},this);}return this;},_set:function(O,V,U){return this._setAttr(O,V,U,true);},_setAttr:function(U,X,O,V){var Z=true,c=this._conf,a=c.data,Y,b,d,W;if(U.indexOf(Q)!==-1){b=U;d=U.split(Q);U=d.shift();}Y=(!a.value||!(U in a.value));if(!this.attrAdded(U)){}else{if(!Y&&!V){if(c.get(U,R)){Z=false;}if(c.get(U,L)){Z=false;}}if(Z){W=this.get(U);if(d){X=H.setValue(B.clone(W),d,X);if(X===undefined){Z=false;}}if(Z){if(c.get(U,A)){this._setAttrVal(U,b,W,X);}else{this._fireAttrChange(U,b,W,X,O);}}}}return this;},_fireAttrChange:function(a,Z,W,V,O){var X=a+N,Y=this._conf,b;if(!Y.get(a,P)){var U={queuable:false,defaultFn:this._defAttrChangeFn,silent:true};U.broadcast=Y.get(a,D);this.publish(X,U);Y.add(a,P,true);}b=(O)?B.merge(O):this._ATTR_E_FACADE;b.type=X;b.attrName=a;b.subAttrName=Z;b.prevVal=W;b.newVal=V;this.fire(b);},_defAttrChangeFn:function(O){if(!this._setAttrVal(O.attrName,O.subAttrName,O.prevVal,O.newVal)){O.stopImmediatePropagation();}else{O.newVal=this._conf.get(O.attrName,F);}},_setAttrVal:function(e,d,Y,X){var a=true,c=this._conf,V=c.get(e,T),Z=c.get(e,J),b=c.get(e,A),U=d||e,W;if(V){var O=V.call(this,X,U);if(!O&&b){X=c.get(e,M);O=true;}}if(!V||O){if(Z){W=Z.call(this,X,U);if(W===E){a=false;}else{if(W!==undefined){X=W;}}}if(a){if(!d&&X===Y){a=false;}else{if(c.get(e,G)===undefined){c.add(e,G,X);}c.add(e,F,X);}}}else{a=false;}return a;},setAttrs:function(U){for(var O in U){if(U.hasOwnProperty(O)){this.set(O,U[O]);}}return this;},getAttrs:function(W){var Z={},X,U,O,Y,V=(W===true);W=(W&&!V)?W:H.keys(this._conf.data[F]);for(X=0,U=W.length;X<U;X++){O=W[X];Y=this.get(O);if(!V||this._conf.get(O,F)!=this._conf.get(O,G)){Z[O]=this.get(O);}}return Z;},addAttrs:function(U,V){if(U){var O,W,X;V=this._splitAttrVals(V);for(O in U){if(U.hasOwnProperty(O)){W=U[O];W.defaultValue=W.value;X=this._getAttrInitVal(O,W,V);if(X!==undefined){W.value=X;}this.addAttr(O,W);}}}return this;},_splitAttrVals:function(W){var Y={},X={},Z,O,V,U;for(U in W){if(W.hasOwnProperty(U)){if(U.indexOf(Q)!==-1){Z=U.split(Q);O=Z.shift();V=X[O]=X[O]||[];V[V.length]={path:Z,value:W[U]};}else{Y[U]=W[U];}}}return{simple:Y,complex:X};},_getAttrInitVal:function(a,Y,c){var U=(Y.valueFn)?Y.valueFn.call(this):Y.value,O,V,X,W,d,b,Z;if(!Y[L]&&c){O=c.simple;if(O&&O.hasOwnProperty(a)){U=O[a];}V=c.complex;if(V&&V.hasOwnProperty(a)){Z=V[a];for(X=0,W=Z.length;X<W;++X){d=Z[X].path;b=Z[X].value;H.setValue(U,d,b);}}}return U;}};B.mix(C,I,false,null,1);B.Attribute=C;},"@VERSION@",{requires:["event-custom"]});