Browse Source

Merge pull request #1184 in VISUAL/fineui from ~KIRA/fineui:master to master

* commit 'eaaca33db2647474bcd93cbd1a4fdab7fc8e25bb':
  KERNEL-1646 refactor: 去掉config中传的options
  KERNEL-1646 refactor: 修改命名
  KERNEL-1646 refactor: config可配置参数屏蔽掉之前注册的插件,inject放到第一次createWidget时做
es6
guy 5 years ago
parent
commit
6d8a1ff346
  1. 1
      src/core/base.js
  2. 46
      src/core/inject.js
  3. 11
      src/core/plugin.js
  4. 4
      src/core/shortcut.js

1
src/core/base.js

@ -456,6 +456,7 @@ if (!_global.BI) {
while (BI.prepares && BI.prepares.length > 0) {
BI.prepares.shift()();
}
BI.initialized = true;
},
has: function (obj, keys) {

46
src/core/inject.js

@ -47,17 +47,42 @@
providerInjection[xtype] = cls;
};
var configFunctions = {};
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]();
if (BI.initialized) {
if (constantInjection[type]) {
return (constantInjection[type] = configFn(constantInjection[type]));
}
return configFn(providers[type]);
if (providerInjection[type]) {
if (!providers[type]) {
providers[type] = new providerInjection[type]();
}
return configFn(providers[type]);
}
return BI.Plugin.configWidget(type, configFn);
}
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]();
}
queue[i](providers[type]);
continue;
}
BI.Plugin.configWidget(type, queue[i]);
}
configFunctions[type] = null;
});
}
BI.Plugin.configWidget(type, configFn);
configFunctions[type].push(configFn);
};
var actions = {};
@ -189,7 +214,8 @@
}
};
var providers = {}, providerInstance = {};
var providers = {},
providerInstance = {};
BI.Providers = {
getProvider: function (type, config) {
@ -242,4 +268,4 @@
return BI.Providers.getProvider(type, config);
}
};
})();
})();

11
src/core/plugin.js

@ -10,13 +10,16 @@ BI.Plugin = BI.Plugin || {};
if (_GlobalWidgetConfigFn) {
_GlobalWidgetConfigFn(type, options);
}
var res;
if (_ConfigPlugin[type]) {
for (var i = _ConfigPlugin[type].length - 1; i >= 0; i--) {
_ConfigPlugin[type][i](options);
if (res = _ConfigPlugin[type][i](options)) {
options = res;
}
}
}
// Deprecated
if (_WidgetsPlugin[type]) {
var res;
for (var i = _WidgetsPlugin[type].length - 1; i >= 0; i--) {
if (res = _WidgetsPlugin[type][i](options)) {
return res;
@ -59,7 +62,9 @@ BI.Plugin = BI.Plugin || {};
if (_ObjectPlugin[type]) {
var res;
for (var i = 0, len = _ObjectPlugin[type].length; i < len; i++) {
res = _ObjectPlugin[type][i](object);
if (res = _ObjectPlugin[type][i](object)) {
object = res;
};
}
}
return res || object;

4
src/core/shortcut.js

@ -22,9 +22,7 @@
BI.createWidget = function (item, options, context) {
// 先把准备环境准备好
while (BI.prepares && BI.prepares.length > 0) {
BI.prepares.shift()();
}
BI.init();
var el, w;
item || (item = {});
if (BI.isWidget(options)) {

Loading…
Cancel
Save