/*
Copyright 2012, KISSY UI Library v1.30rc
MIT Licensed
build time: Jul 11 21:21
*/
KISSY.add("base/attribute",function(e,j){function k(a,b,c,d,g,f,i){i=i||c;return a.fire(b+e.ucfirst(c)+"Change",{attrName:i,subAttrName:f,prevVal:d,newVal:g})}function h(a,b,c){var d=a[b]||{};c&&(a[b]=d);return d}function i(a){return h(a,"__attrs",!0)}function l(a){return h(a,"__attrVals",!0)}function n(a,b){for(var c=0,d=b.length;a!=j&&c<d;c++)a=a[b[c]];return a}function m(a,b){var c;!a.hasAttr(b)&&-1!==b.indexOf(".")&&(c=b.split("."),b=c.shift());return{path:c,name:b}}function p(a,b,c){var d=c;
if(b){var a=d=a===j?{}:e.clone(a),g=b.length-1;if(0<=g){for(var f=0;f<g;f++)a=a[b[f]];a!=j&&(a[b[f]]=c)}}return d}function q(a,b,c,d,g){var d=d||{},f,i,e;e=m(a,b);var h=b,b=e.name;f=e.path;e=a.get(b);f&&(i=n(e,f));if(!f&&e===c||f&&i===c)return j;c=p(e,f,c);if(!d.silent&&!1===k(a,"before",b,e,c,h))return!1;c=a.__set(b,c,d);if(!1===c)return c;d.silent||(c=l(a)[b],k(a,"after",b,e,c,h),g?g.push({prevVal:e,newVal:c,attrName:b,subAttrName:h}):k(a,"","*",[e],[c],[h],[b]));return a}function o(){}function r(a,
b,c,d){var g,f;g=m(a,b);b=g.name;if(g=g.path)f=a.get(b),c=p(f,g,c);if((g=h(i(a),b,!0).validator)&&(g=e.isString(g)?a[g]:g))if(a=g.call(a,c,b,d),a!==j&&!0!==a)return a;return j}o.INVALID={};var s=o.INVALID;e.augment(o,{getAttrs:function(){return i(this)},getAttrVals:function(){var a={},b,c=i(this);for(b in c)a[b]=this.get(b);return a},addAttr:function(a,b,c){var d=i(this),b=e.clone(b);d[a]?e.mix(d[a],b,c):d[a]=b;return this},addAttrs:function(a,b){var c=this;e.each(a,function(a,b){c.addAttr(b,a)});
b&&c.set(b);return c},hasAttr:function(a){return a&&i(this).hasOwnProperty(a)},removeAttr:function(a){this.hasAttr(a)&&(delete i(this)[a],delete l(this)[a]);return this},set:function(a,b,c){if(e.isPlainObject(a)){var c=b,b=Object(a),d=[],g,f=[];for(a in b)(g=r(this,a,b[a],b))!==j&&f.push(g);if(f.length)return c&&c.error&&c.error(f),!1;for(a in b)q(this,a,b[a],c,d);var i=[],h=[],l=[],n=[];e.each(d,function(a){h.push(a.prevVal);l.push(a.newVal);i.push(a.attrName);n.push(a.subAttrName)});i.length&&k(this,
"","*",h,l,n,i);return this}return q(this,a,b,c)},__set:function(a,b,c){var d,g,f=h(i(this),a,!0).setter;g=r(this,a,b);if(g!==j)return c.error&&c.error(g),!1;if(f&&(f=e.isString(f)?this[f]:f))d=f.call(this,b,a);if(d===s)return!1;d!==j&&(b=d);l(this)[a]=b},get:function(a){var b,c=this.hasAttr(a),d=l(this);!c&&-1!==a.indexOf(".")&&(b=a.split("."),a=b.shift());c=h(i(this),a).getter;d=a in d?d[a]:this.__getDefAttrVal(a);if(c&&(c=e.isString(c)?this[c]:c))d=c.call(this,d,a);b&&(d=n(d,b));return d},__getDefAttrVal:function(a){var b=
i(this),c=h(b,a),d=c.valueFn;if(d&&(d=e.isString(d)?this[d]:d))d=d.call(this),d!==j&&(c.value=d),delete c.valueFn,b[a]=c;return c.value},reset:function(a,b){if(e.isString(a))return this.hasAttr(a)?this.set(a,this.__getDefAttrVal(a),b):this;var b=a,c=i(this),d={};for(a in c)d[a]=this.__getDefAttrVal(a);this.set(d,b);return this}});return o});
KISSY.add("base",function(e,j,k){function h(e){for(var h=this.constructor;h;){var j=h.ATTRS;if(j){var m=void 0;for(m in j)j.hasOwnProperty(m)&&this.addAttr(m,j[m],!1)}h=h.superclass?h.superclass.constructor:null}if(e)for(var k in e)e.hasOwnProperty(k)&&this.__set(k,e[k])}e.augment(h,k.Target,j);h.Attribute=j;return e.Base=h},{requires:["base/attribute","event"]});
