/*
Copyright 2011, KISSY UI Library v1.20dev
MIT Licensed
build time: ${build.time}
*/
KISSY.add("component/modelcontrol",function(d,e){function g(a){return function(b){this.get("view").set(a,b)}}function i(){for(var a=this.constructor,b;a&&!b;){b=a.DefaultRender;a=a.superclass&&a.superclass.constructor}if(b){a=this.__attrs;var c={},f;for(f in a)if(a.hasOwnProperty(f))if(a[f].view&&this.__attrVals[f]!==undefined)c[f]=this.__attrVals[f];return new b(c)}}function h(a){a+="";return a.charAt(0).toUpperCase()+a.substring(1)}return e.create([e.Box],{renderUI:function(){var a=this.__attrs,
b;for(b in a)if(a.hasOwnProperty(b))if(a[b].view&&!this["_uiSet"+h(b)])this["_uiSet"+h(b)]=g(b);a=this.get("view")||i.call(this);if(!a){d.error("no view for");d.error(this.constructor)}this.set("view",a);if(this.get("parent")){b=this.get("parent").get("view");a.set("render",b.get("contentEl")||b.get("el"))}a.render();a=this.get("children");d.each(a,function(c){c.render()})},addChild:function(a,b){var c=this.get("children");b?c.splice(b,0,a):c.push(a);a.set("parent",this)},removeChild:function(a){var b=
this.get("children"),c=d.indexOf(a,b);c!=-1&&b.splice(c,1);a.destroy()},bindUI:function(){var a=this.get("view").get("el");a.on("mouseenter",this._handleMouseEnter,this);a.on("mouseleave",this._handleMouseLeave,this);a.on("mousedown",this._handleMouseDown,this);a.on("mouseup",this._handleMouseUp,this);a.on("focus",this._handleFocus,this);a.on("blur",this._handleBlur,this);a.on("keydown",this._handleKeydown,this);a.on("click",this._handleClick,this)},_forwordToView:function(a,b){var c=this.get("view");
c[a]&&c[a](b)},_handleMouseEnter:function(a){if(this.get("disabled"))return false;this._forwordToView("_handleMouseEnter",a)},_handleMouseLeave:function(a){if(this.get("disabled"))return false;this._forwordToView("_handleMouseLeave",a)},_handleMouseDown:function(a){if(this.get("disabled"))return false;this._forwordToView("_handleMouseDown",a)},_handleMouseUp:function(a){if(this.get("disabled"))return false;this._forwordToView("_handleMouseUp",a)},_handleFocus:function(a){if(this.get("disabled"))return false;
this._forwordToView("_handleFocus",a)},_handleBlur:function(a){if(this.get("disabled"))return false;this._forwordToView("_handleBlur",a)},_handleKeydown:function(a){if(this.get("disabled"))return false;var b=this.get("view");if(b._handleKeydown)if(a.keyCode==13||a.keyCode==32){this._handleClick();a.preventDefault()}else return b._handleKeydown(a)},_handleClick:function(){if(this.get("disabled"))return false;this._forwordToView("_handleClick");this.fire("click")},_uiSetDisabled:function(a){this.get("view").set("disabled",
a)},destructor:function(){var a=this.get("children");d.each(a,function(b){b.destroy()});a=this.get("view");a.get("el").detach();a.destroy()}},{ATTRS:{children:{value:[],setter:function(a){var b=this;d.each(a,function(c){c.set("parent",b)})}},srcNode:{view:true},render:{view:true},parent:{},view:{},disabled:{value:false,view:true}}})},{requires:["uibase"]});
KISSY.add("component/render",function(d,e){return e.create([e.Box.Render],{},{ATTRS:{srcNode:{},prefixCls:{value:""},disabled:{value:false}}})},{requires:["uibase"]});KISSY.add("component",function(d,e,g){return{ModelControl:e,Render:g}},{requires:["component/modelcontrol","component/render"]});
