fineui是帆软报表和BI产品线所使用的前端框架。

47 lines
1.6 KiB

8 years ago
(function () {
8 years ago
var kv = {};
8 years ago
BI.shortcut = function (xtype, cls) {
8 years ago
if (kv[xtype] != null) {
throw ("shortcut:[" + xtype + "] has been registed");
}
kv[xtype] = cls;
};
// 根据配置属性生成widget
var createWidget = function (config) {
if (config['classType']) {
return new (new Function('return ' + config['classType'] + ';')())(config);
}
8 years ago
var cls = kv[config.type];
8 years ago
return new cls(config);
};
BI.createWidget = function (item, options) {
8 years ago
var el, w;
8 years ago
options || (options = {});
if (BI.isEmpty(item) && BI.isEmpty(options)) {
8 years ago
return BI.createWidget({
8 years ago
type: "bi.layout"
8 years ago
});
8 years ago
}
if (BI.isWidget(item)) {
return item;
}
if (item && (item.type || options.type)) {
el = BI.extend({}, options, item);
8 years ago
w = BI.Plugin.getWidget(el.type, el);
return BI.Plugin.getObject(el.type, w.type === el.type ? createWidget(w) : BI.createWidget(BI.extend({}, item, {type: w.type}, options)));
8 years ago
}
if (item && item.el && (item.el.type || options.type)) {
el = BI.extend({}, options, item.el);
8 years ago
w = BI.Plugin.getWidget(el.type, el);
return BI.Plugin.getObject(el.type, w.type === el.type ? createWidget(w) : BI.createWidget(BI.extend({}, item, {type: w.type}, options)));
8 years ago
}
if (item && BI.isWidget(item.el)) {
return item.el;
}
throw new Error('无法根据item创建组件');
}
8 years ago
})();