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.

82 lines
2.5 KiB

8 years ago
BI.Plugin = BI.Plugin || {};
7 years ago
!(function () {
8 years ago
var _WidgetsPlugin = {};
var _ObjectPlugin = {};
7 years ago
var _ConfigPlugin = {};
7 years ago
var _GlobalWidgetConfigFn, _GlobalObjectConfigFn;
8 years ago
BI.extend(BI.Plugin, {
getWidget: function (type, options) {
7 years ago
if (_GlobalWidgetConfigFn) {
_GlobalWidgetConfigFn(type, options);
}
7 years ago
if (_ConfigPlugin[type]) {
for (var i = _ConfigPlugin[type].length - 1; i >= 0; i--) {
_ConfigPlugin[type][i](options);
}
}
8 years ago
if (_WidgetsPlugin[type]) {
var res;
7 years ago
for (var i = _WidgetsPlugin[type].length - 1; i >= 0; i--) {
8 years ago
if (res = _WidgetsPlugin[type][i](options)) {
return res;
}
}
}
return options;
},
7 years ago
config: function (widgetConfigFn, objectConfigFn) {
_GlobalWidgetConfigFn = widgetConfigFn;
_GlobalObjectConfigFn = objectConfigFn;
},
7 years ago
configWidget: function (type, fn) {
if (!_ConfigPlugin[type]) {
_ConfigPlugin[type] = [];
}
_ConfigPlugin[type].push(fn);
},
8 years ago
registerWidget: function (type, fn) {
if (!_WidgetsPlugin[type]) {
_WidgetsPlugin[type] = [];
}
if (_WidgetsPlugin[type].length > 0) {
console.log("组件已经注册过了!");
}
_WidgetsPlugin[type].push(fn);
},
relieveWidget: function (type) {
delete _WidgetsPlugin[type];
},
getObject: function (type, object) {
7 years ago
if (_GlobalObjectConfigFn) {
_GlobalObjectConfigFn(type, object);
}
8 years ago
if (_ObjectPlugin[type]) {
var res;
for (var i = 0, len = _ObjectPlugin[type].length; i < len; i++) {
res = _ObjectPlugin[type][i](object);
}
}
return res || object;
},
registerObject: function (type, fn) {
if (!_ObjectPlugin[type]) {
_ObjectPlugin[type] = [];
}
if (_ObjectPlugin[type].length > 0) {
console.log("对象已经注册过了!");
}
_ObjectPlugin[type].push(fn);
},
relieveObject: function (type) {
delete _ObjectPlugin[type];
}
});
})();