|
|
@ -49,7 +49,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
var configFunctions = {}; |
|
|
|
var configFunctions = {}; |
|
|
|
BI.config = BI.config || function (type, configFn, opt) { |
|
|
|
BI.config = BI.config || function (type, configFn, opt) { |
|
|
|
if (opt && opt.immediate) { |
|
|
|
if (BI.initialized) { |
|
|
|
if (constantInjection[type]) { |
|
|
|
if (constantInjection[type]) { |
|
|
|
return (constantInjection[type] = configFn(constantInjection[type])); |
|
|
|
return (constantInjection[type] = configFn(constantInjection[type])); |
|
|
|
} |
|
|
|
} |
|
|
@ -67,49 +67,29 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
if (!configFunctions[type]) { |
|
|
|
if (!configFunctions[type]) { |
|
|
|
configFunctions[type] = []; |
|
|
|
configFunctions[type] = []; |
|
|
|
|
|
|
|
BI.prepares.push(function () { |
|
|
|
|
|
|
|
var queue = configFunctions[type]; |
|
|
|
|
|
|
|
for (var i = 0; i < queue.length; i++) { |
|
|
|
|
|
|
|
if (constantInjection[type]) { |
|
|
|
|
|
|
|
constantInjection[type] = queue[i](constantInjection[type]); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (providerInjection[type]) { |
|
|
|
|
|
|
|
if (!providers[type]) { |
|
|
|
|
|
|
|
providers[type] = new providerInjection[type](); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (providerInstance[type]) { |
|
|
|
|
|
|
|
delete providerInstance[type]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
queue[i](providers[type]); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
BI.Plugin.configWidget(type, queue[i]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
configFunctions[type] = null; |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
configFunctions[type].push({fn: configFn, args: opt}); |
|
|
|
configFunctions[type].push({fn: configFn, args: opt}); |
|
|
|
// if (BI.initialized) {
|
|
|
|
|
|
|
|
// if (constantInjection[type]) {
|
|
|
|
|
|
|
|
// return (constantInjection[type] = configFn(constantInjection[type]));
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (providerInjection[type]) {
|
|
|
|
|
|
|
|
// if (!providers[type]) {
|
|
|
|
|
|
|
|
// providers[type] = new providerInjection[type]();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// // 如果config被重新配置的话,需要删除掉之前的实例
|
|
|
|
|
|
|
|
// if (providerInstance[type]) {
|
|
|
|
|
|
|
|
// delete providerInstance[type];
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return configFn(providers[type]);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return BI.Plugin.configWidget(type, configFn, opt);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (!configFunctions[type]) {
|
|
|
|
|
|
|
|
// configFunctions[type] = [];
|
|
|
|
|
|
|
|
// BI.prepares.push(function () {
|
|
|
|
|
|
|
|
// var queue = configFunctions[type];
|
|
|
|
|
|
|
|
// for (var i = 0; i < queue.length; i++) {
|
|
|
|
|
|
|
|
// if (constantInjection[type]) {
|
|
|
|
|
|
|
|
// constantInjection[type] = queue[i](constantInjection[type]);
|
|
|
|
|
|
|
|
// continue;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (providerInjection[type]) {
|
|
|
|
|
|
|
|
// if (!providers[type]) {
|
|
|
|
|
|
|
|
// providers[type] = new providerInjection[type]();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (providerInstance[type]) {
|
|
|
|
|
|
|
|
// delete providerInstance[type];
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// queue[i](providers[type]);
|
|
|
|
|
|
|
|
// continue;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// BI.Plugin.configWidget(type, queue[i]);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// configFunctions[type] = null;
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// configFunctions[type].push(configFn);
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
BI.Configs = BI.Configs || { |
|
|
|
BI.Configs = BI.Configs || { |
|
|
@ -175,16 +155,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
BI.Constants = BI.Constants || { |
|
|
|
BI.Constants = BI.Constants || { |
|
|
|
getConstant: function (type) { |
|
|
|
getConstant: function (type) { |
|
|
|
var instance = constantInjection[type]; |
|
|
|
return constantInjection[type]; |
|
|
|
BI.each(configFunctions[type], function (i, cf) { |
|
|
|
|
|
|
|
var res = cf.fn(instance); |
|
|
|
|
|
|
|
if (res) { |
|
|
|
|
|
|
|
instance = res; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
constantInjection[type] = instance; |
|
|
|
|
|
|
|
configFunctions[type] && (configFunctions[type] = null); |
|
|
|
|
|
|
|
return instance; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -273,17 +244,9 @@ |
|
|
|
if (!providers[type]) { |
|
|
|
if (!providers[type]) { |
|
|
|
providers[type] = new providerInjection[type](); |
|
|
|
providers[type] = new providerInjection[type](); |
|
|
|
} |
|
|
|
} |
|
|
|
var instance = providers[type]; |
|
|
|
|
|
|
|
BI.each(configFunctions[type], function (i, cf) { |
|
|
|
|
|
|
|
if (providerInstance[type]) { |
|
|
|
|
|
|
|
delete providerInstance[type]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
cf.fn(instance); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
if (!providerInstance[type]) { |
|
|
|
if (!providerInstance[type]) { |
|
|
|
providerInstance[type] = new (providers[type].$get())(config); |
|
|
|
providerInstance[type] = new (providers[type].$get())(config); |
|
|
|
} |
|
|
|
} |
|
|
|
configFunctions[type] && (configFunctions[type] = null); |
|
|
|
|
|
|
|
return providerInstance[type]; |
|
|
|
return providerInstance[type]; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|