forked from fanruan/fineui
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.
148 lines
4.4 KiB
148 lines
4.4 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"),
|
||
4 years ago
|
loadingText: "",
|
||
4 years ago
|
loadingSize: "small",
|
||
8 years ago
|
overlap: true,
|
||
|
onLoaded: BI.emptyFn
|
||
7 years ago
|
});
|
||
8 years ago
|
},
|
||
|
|
||
|
_assertTip: function () {
|
||
|
var o = this.options;
|
||
|
if (!this._tipText) {
|
||
|
this._tipText = BI.createWidget({
|
||
|
type: "bi.label",
|
||
|
cls: "bi-tips",
|
||
|
text: o.tipText,
|
||
|
height: 25
|
||
|
});
|
||
|
BI.createWidget({
|
||
7 years ago
|
type: "bi.absolute_center_adapt",
|
||
8 years ago
|
element: this,
|
||
7 years ago
|
items: [this._tipText]
|
||
8 years ago
|
});
|
||
|
}
|
||
|
},
|
||
|
|
||
|
loading: function () {
|
||
|
var self = this, o = this.options;
|
||
6 years ago
|
var isIE = BI.isIE();
|
||
7 years ago
|
var loadingAnimation = BI.createWidget({
|
||
|
type: "bi.horizontal",
|
||
6 years ago
|
cls: "bi-loading-widget" + (isIE ? " wave-loading hack" : ""),
|
||
4 years ago
|
height: this._getSize(60),
|
||
|
width: this._getSize(60),
|
||
|
hgap: this._getSize(10),
|
||
6 years ago
|
vgap: 2.5,
|
||
6 years ago
|
items: isIE ? [] : [{
|
||
7 years ago
|
type: "bi.layout",
|
||
6 years ago
|
cls: "animate-rect rect1",
|
||
4 years ago
|
height: this._getSize(50),
|
||
|
width: this._getSize(5),
|
||
7 years ago
|
}, {
|
||
|
type: "bi.layout",
|
||
6 years ago
|
cls: "animate-rect rect2",
|
||
4 years ago
|
height: this._getSize(50),
|
||
|
width: this._getSize(5),
|
||
7 years ago
|
}, {
|
||
|
type: "bi.layout",
|
||
6 years ago
|
cls: "animate-rect rect3",
|
||
4 years ago
|
height: this._getSize(50),
|
||
|
width: this._getSize(5),
|
||
7 years ago
|
}]
|
||
|
});
|
||
6 years ago
|
// pane在同步方式下由items决定tipText的显示与否
|
||
6 years ago
|
// loading的异步情况下由loaded后对面板的populate的时机决定
|
||
6 years ago
|
this.setTipVisible(false);
|
||
8 years ago
|
if (o.overlap === true) {
|
||
8 years ago
|
if (!BI.Layers.has(this.getName())) {
|
||
8 years ago
|
BI.createWidget({
|
||
4 years ago
|
type: "bi.center_adapt",
|
||
6 years ago
|
cls: "loading-container",
|
||
4 years ago
|
items: this._getLoadingTipItems(loadingAnimation),
|
||
8 years ago
|
element: BI.Layers.make(this.getName(), this)
|
||
8 years ago
|
});
|
||
|
}
|
||
8 years ago
|
BI.Layers.show(self.getName());
|
||
8 years ago
|
} else if (BI.isNull(this._loading)) {
|
||
7 years ago
|
this._loading = loadingAnimation;
|
||
8 years ago
|
this._loading.element.css("zIndex", 1);
|
||
|
BI.createWidget({
|
||
4 years ago
|
type: "bi.center_adapt",
|
||
8 years ago
|
element: this,
|
||
6 years ago
|
cls: "loading-container",
|
||
4 years ago
|
items: this._getLoadingTipItems(this._loading)
|
||
7 years ago
|
});
|
||
8 years ago
|
}
|
||
4 years ago
|
self.fireEvent(BI.Pane.EVENT_LOADING);
|
||
6 years ago
|
this.element.addClass("loading-status");
|
||
8 years ago
|
},
|
||
|
|
||
4 years ago
|
_getSize: function(v) {
|
||
|
return Math.ceil(v / (this.options.loadingSize === 'small' ? 2 : 1));
|
||
|
},
|
||
|
|
||
4 years ago
|
_getLoadingTipItems: function (loadingTip) {
|
||
|
var o = this.options;
|
||
|
var loadingTipItems = [{
|
||
|
type: "bi.horizontal_adapt",
|
||
|
items: [loadingTip]
|
||
|
}];
|
||
|
BI.isNotEmptyString(o.loadingText) && loadingTipItems.push({
|
||
|
type: "bi.text",
|
||
4 years ago
|
text: o.loadingText,
|
||
|
tgap: this._getSize(10),
|
||
4 years ago
|
});
|
||
|
|
||
|
return [{
|
||
|
type: "bi.vertical",
|
||
|
items: loadingTipItems
|
||
|
}];
|
||
|
},
|
||
|
|
||
8 years ago
|
loaded: function () {
|
||
4 years ago
|
var self = this, o = this.options;
|
||
|
BI.Layers.remove(self.getName());
|
||
|
this._loading && this._loading.destroy();
|
||
|
this._loading && (this._loading = null);
|
||
|
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.setVisible(true);
|
||
|
} else {
|
||
|
this._tipText && this._tipText.setVisible(false);
|
||
|
}
|
||
|
},
|
||
|
|
||
|
populate: function (items) {
|
||
|
this.options.items = items || [];
|
||
|
this.check();
|
||
|
},
|
||
|
|
||
|
empty: function () {
|
||
|
|
||
|
}
|
||
|
});
|
||
4 years ago
|
BI.Pane.EVENT_LOADED = "EVENT_LOADED";
|
||
|
BI.Pane.EVENT_LOADING = "EVENT_LOADING";
|