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.

134 lines
3.6 KiB

7 years ago
;(function () {
var constantInjection = {};
BI.constant = function (xtype, cls) {
if (constantInjection[xtype] != null) {
throw ("constant:[" + xtype + "] has been registed");
}
constantInjection[xtype] = cls;
};
var modelInjection = {};
BI.model = function (xtype, cls) {
if (modelInjection[xtype] != null) {
throw ("model:[" + xtype + "] has been registed");
}
modelInjection[xtype] = cls;
};
var storeInjection = {};
7 years ago
BI.store = function (xtype, cls) {
7 years ago
if (storeInjection[xtype] != null) {
throw ("store:[" + xtype + "] has been registed");
}
storeInjection[xtype] = cls;
};
7 years ago
var serviceInjection = {};
BI.service = function (xtype, cls) {
if (serviceInjection[xtype] != null) {
throw ("service:[" + xtype + "] has been registed");
}
serviceInjection[xtype] = cls;
};
7 years ago
var providerInjection = {};
BI.provider = function (xtype, cls) {
if (providerInjection[xtype] != null) {
throw ("provider:[" + xtype + "] has been registed");
}
providerInjection[xtype] = cls;
};
BI.config = function (type, configFn) {
if (constantInjection[type]) {
return constantInjection[type] = configFn(constantInjection[type]);
}
if (providerInjection[type]) {
if (!providers[type]) {
providers[type] = new providerInjection[type]();
}
return configFn(providers[type])
}
}
7 years ago
var actions = {}
BI.action = function (type, actionFn) {
if (!actions[type]) {
actions[type] = [];
}
actions[type].push(actionFn)
return function () {
actions[type].remove(actionFn);
if (actions[type].length === 0) {
delete actions[type];
}
}
}
7 years ago
BI.Constants = {
getConstant: function (type) {
return constantInjection[type];
}
}
BI.Models = {
getModel: function (type, config) {
return new modelInjection[type](config);
}
}
var stores = {};
BI.Stores = {
getStore: function (type, config) {
if (stores[type]) {
return stores[type];
}
return stores[type] = new storeInjection[type](config);
7 years ago
},
releaseStore: function (type) {
delete stores[type];
7 years ago
}
}
7 years ago
var services = {};
BI.Services = {
getService: function (type, config) {
if (services[type]) {
return services[type];
}
return services[type] = new serviceInjection[type](config);
},
releaseService: function (type) {
delete services[type];
}
}
7 years ago
var providers = {}, providerInstance = {}
BI.Providers = {
getProvider: function (type, config) {
if (!providers[type]) {
providers[type] = new providerInjection[type]();
}
if (!providerInstance[type]) {
providerInstance[type] = new providers[type].$get()(config);
}
return providerInstance[type];
7 years ago
},
releaseProvider: function (type) {
delete providers[type];
delete providerInstance[type];
7 years ago
}
}
7 years ago
BI.Actions = {
runAction: function (type, config) {
BI.each(actions[type], function (i, act) {
act(config);
})
}
}
7 years ago
})();