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.

155 lines
4.7 KiB

8 years ago
/**
* 当没有元素时有提示信息的view
*
* Created by GUY on 2015/9/8.
* @class BI.Pane
* @extends BI.Widget
* @abstract
*/
BI.Pane = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.Pane.superclass._defaultConfig.apply(this, arguments), {
6 years ago
_baseCls: "bi-pane",
8 years ago
tipText: BI.i18nText("BI-No_Selected_Item"),
loadingText: "",
loadingSize: "small",
8 years ago
overlap: true,
onLoaded: BI.emptyFn
7 years ago
});
8 years ago
},
_assertTip: function () {
3 years ago
var self = this, o = this.options;
8 years ago
if (!this._tipText) {
BI.createWidget({
6 years ago
type: "bi.absolute_center_adapt",
8 years ago
element: this,
3 years ago
items: [{
type: "bi.label",
ref: function (_ref) {
self._tipText = _ref;
},
cls: "bi-tips",
text: o.tipText,
height: 25
}]
8 years ago
});
}
},
loading: function () {
var self = this, o = this.options;
var isIE = BI.isIE();
var loadingAnimation = BI.createWidget({
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),
3 years ago
width: this._getSize(5)
}, {
type: "bi.layout",
cls: "animate-rect rect2",
height: this._getSize(50),
3 years ago
width: this._getSize(5)
}, {
type: "bi.layout",
cls: "animate-rect rect3",
height: this._getSize(50),
3 years ago
width: this._getSize(5)
}]
});
// pane在同步方式下由items决定tipText的显示与否
6 years ago
// loading的异步情况下由loaded后对面板的populate的时机决定
this.setTipVisible(false);
8 years ago
if (o.overlap === true) {
if (!BI.Layers.has(this.getName() + "-loading")) {
8 years ago
BI.createWidget({
type: "bi.center_adapt",
cls: "loading-container",
items: this._getLoadingTipItems(loadingAnimation),
element: BI.Layers.make(this.getName() + "-loading", this)
8 years ago
});
}
BI.Layers.show(self.getName() + "-loading");
} else if (BI.isNull(this._loading)) {
3 years ago
loadingAnimation.element.css("zIndex", 1);
8 years ago
BI.createWidget({
type: "bi.center_adapt",
8 years ago
element: this,
cls: "loading-container",
3 years ago
items: this._getLoadingTipItems(loadingAnimation)
7 years ago
});
8 years ago
}
self.fireEvent(BI.Pane.EVENT_LOADING);
6 years ago
this.element.addClass("loading-status");
8 years ago
},
3 years ago
_getSize: function (v) {
return Math.ceil(v / (this.options.loadingSize === "small" ? 2 : 1));
},
_getLoadingTipItems: function (loadingTip) {
3 years ago
var self = this, o = this.options;
var loadingTipItems = [{
type: "bi.horizontal_adapt",
items: [loadingTip]
}];
BI.isNotEmptyString(o.loadingText) && loadingTipItems.push({
type: "bi.text",
text: o.loadingText,
3 years ago
tgap: this._getSize(10)
});
return [{
type: "bi.vertical",
3 years ago
ref: function (_ref) {
self._loading = _ref;
},
items: loadingTipItems
}];
},
8 years ago
loaded: function () {
4 years ago
var self = this, o = this.options;
BI.Layers.remove(self.getName() + "-loading");
4 years ago
this._loading && this._loading.destroy();
o.onLoaded();
self.fireEvent(BI.Pane.EVENT_LOADED);
this.element.removeClass("loading-status");
8 years ago
},
check: function () {
this.setTipVisible(BI.isEmpty(this.options.items));
},
setTipVisible: function (b) {
if (b === true) {
this._assertTip();
this._tipText && this._tipText.setVisible(true);
8 years ago
} else {
this._tipText && this._tipText.setVisible(false);
}
},
setTipText: function (text) {
this._assertTip();
this._tipText.setText(text);
},
8 years ago
populate: function (items) {
this.options.items = items || [];
this.check();
}
});
BI.Pane.EVENT_LOADED = "EVENT_LOADED";
3 years ago
BI.Pane.EVENT_LOADING = "EVENT_LOADING";
BI.shortcut("bi.pane", BI.Pane);