fineui是帆软报表和BI产品线所使用的前端框架。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.3 KiB

8 years ago
(function () {
7 years ago
var kv = {};
6 years ago
BI.shortcut = BI.component = function (xtype, cls) {
8 years ago
if (kv[xtype] != null) {
6 years ago
_global.console && console.error("shortcut:[" + xtype + "] has been registed");
8 years ago
}
kv[xtype] = cls;
};
8 years ago
// 根据配置属性生成widget
var createWidget = function (config) {
7 years ago
var cls = kv[config.type];
var widget = new cls();
widget._initProps(config);
widget._init();
widget._initRef();
return widget;
8 years ago
};
7 years ago
BI.createWidget = function (item, options, context) {
6 years ago
// 先把准备环境准备好
BI.init();
7 years ago
var el, w;
7 years ago
item || (item = {});
7 years ago
if (BI.isWidget(options)) {
context = options;
options = {};
} else {
options || (options = {});
}
8 years ago
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;
}
7 years ago
if (item.type || options.type) {
8 years ago
el = BI.extend({}, options, item);
7 years ago
w = BI.Plugin.getWidget(el.type, el);
6 years ago
w.listeners = (w.listeners || []).concat([{
eventName: BI.Events.MOUNT,
action: function () {
BI.Plugin.getObject(el.type, this);
}
}]);
return w.type === el.type ? createWidget(w) : BI.createWidget(BI.extend({}, item, {type: w.type}, options));
8 years ago
}
7 years ago
if (item.el && (item.el.type || options.type)) {
8 years ago
el = BI.extend({}, options, item.el);
7 years ago
w = BI.Plugin.getWidget(el.type, el);
6 years ago
w.listeners = (w.listeners || []).concat([{
eventName: BI.Events.MOUNT,
action: function () {
BI.Plugin.getObject(el.type, this);
}
}]);
return w.type === el.type ? createWidget(w) : BI.createWidget(BI.extend({}, item, {type: w.type}, options));
8 years ago
}
7 years ago
if (BI.isWidget(item.el)) {
8 years ago
return item.el;
}
7 years ago
throw new Error("无法根据item创建组件");
};
8 years ago
5 years ago
BI.createElement = function () {
var widget = BI.createWidget.apply(this, arguments);
return widget.element;
};
8 years ago
})();