Browse Source

KERNEL-9708 refactor: 提取到system中实现

es6
iapyang 2 years ago
parent
commit
064c68e2a6
  1. 26
      src/base/1.pane.js
  2. 42
      src/core/system.js

26
src/base/1.pane.js

@ -40,30 +40,8 @@ BI.Pane = BI.inherit(BI.Widget, {
loading: function () { loading: function () {
var self = this, o = this.options; var self = this, o = this.options;
var isIE = BI.isIE(); var loadingAnimation = BI.Providers.getProvider("bi.provider.system").getLoading({
var loadingAnimation = BI.createWidget({ loadingSize: o.loadingSize
type: "bi.horizontal",
cls: "bi-loading-widget" + (isIE ? " wave-loading hack" : ""),
height: this._getSize(60),
width: this._getSize(60),
hgap: this._getSize(10),
vgap: 2.5,
items: isIE ? [] : [{
type: "bi.layout",
cls: "animate-rect rect1",
height: this._getSize(50),
width: this._getSize(5)
}, {
type: "bi.layout",
cls: "animate-rect rect2",
height: this._getSize(50),
width: this._getSize(5)
}, {
type: "bi.layout",
cls: "animate-rect rect3",
height: this._getSize(50),
width: this._getSize(5)
}]
}); });
// pane在同步方式下由items决定tipText的显示与否 // pane在同步方式下由items决定tipText的显示与否
// loading的异步情况下由loaded后对面板的populate的时机决定 // loading的异步情况下由loaded后对面板的populate的时机决定

42
src/core/system.js

@ -19,6 +19,40 @@
TOAST_TOP: 10, TOAST_TOP: 10,
H_GAP_SIZE: "M", H_GAP_SIZE: "M",
V_GAP_SIZE: "S" V_GAP_SIZE: "S"
},
loadingCreator: function(config) {
var loadingSize = (config ? config.loadingSize : "small") || "small";
var isIE = BI.isIE();
function getSize(v) {
return Math.ceil(v / (loadingSize === "small" ? 2 : 1));
}
return {
type: "bi.horizontal",
cls: "bi-loading-widget" + (isIE ? " wave-loading hack" : ""),
height: getSize(60),
width: getSize(60),
hgap: getSize(10),
vgap: 2.5,
items: isIE ? [] : [{
type: "bi.layout",
cls: "animate-rect rect1",
height: getSize(50),
width: getSize(5)
}, {
type: "bi.layout",
cls: "animate-rect rect2",
height: getSize(50),
width: getSize(5)
}, {
type: "bi.layout",
cls: "animate-rect rect3",
height: getSize(50),
width: getSize(5)
}]
};
} }
}; };
@ -59,6 +93,10 @@
BI.extend(system.dependencies, moduleConfig); BI.extend(system.dependencies, moduleConfig);
}; };
this.setLoadingCreator = function(creator) {
system.loadingCreator = creator;
};
this.$get = function () { this.$get = function () {
return BI.inherit(BI.OB, { return BI.inherit(BI.OB, {
@ -87,6 +125,10 @@
getDependencies: function () { getDependencies: function () {
return system.dependencies; return system.dependencies;
},
getLoading: function(config) {
return system.loadingCreator(config);
} }
}); });
}; };

Loading…
Cancel
Save