1 /** 2 * Setup component namespace. 3 * @author yiminghe@gmail.com 4 */ 5 KISSY.add("component/base", function (S, UIBase, Manager) { 6 /** 7 * @name Component 8 * @namespace 9 * Component infrastructure. 10 */ 11 var Component = { 12 Manager:Manager, 13 UIBase:UIBase 14 }; 15 16 /** 17 * Create a component instance using json with xclass. 18 * @param {Object} component Component's json notation with xclass attribute. 19 * @param {String} component.xclass Component to be newed 's xclass. 20 * @param {Controller} self Component From which new component generated will inherit prefixCls 21 * if component 's prefixCls is undefined. 22 * @memberOf Component 23 * @example 24 * <code> 25 * create({ 26 * xclass:'menu', 27 * children:[{ 28 * xclass:'menuitem', 29 * content:"1" 30 * }] 31 * }) 32 * </code> 33 */ 34 function create(component, self) { 35 var childConstructor, xclass; 36 if (component && (xclass = component.xclass)) { 37 if (self && !component.prefixCls) { 38 component.prefixCls = self.get("prefixCls"); 39 } 40 childConstructor = Manager.getConstructorByXClass(xclass); 41 component = new childConstructor(component); 42 } 43 return component; 44 } 45 46 Component.create = create; 47 48 return Component; 49 }, { 50 requires:['./uibase', './manager'] 51 });