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.

98 lines
3.2 KiB

6 years ago
/**
* Created by GUY on 2016/12/2.
*
* @class BI.FlexVerticalLayout
* @extends BI.Layout
*/
BI.FlexVerticalLayout = BI.inherit(BI.Layout, {
props: function () {
return BI.extend(BI.FlexVerticalLayout.superclass.props.apply(this, arguments), {
4 years ago
baseCls: "bi-f-v",
6 years ago
horizontalAlign: BI.HorizontalAlign.Left,
verticalAlign: BI.VerticalAlign.Top,
rowSize: [],
scrolly: true,
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0
});
},
render: function () {
BI.FlexVerticalLayout.superclass.render.apply(this, arguments);
var o = this.options;
this.element.addClass("h-" + o.horizontalAlign).addClass("v-" + o.verticalAlign);
4 years ago
if (o.scrollable === true || o.scrollx === true) {
this.element.addClass("f-scroll-x");
}
if (o.scrollable === true || o.scrolly === true) {
this.element.addClass("f-scroll-y");
}
6 years ago
this.populate(this.options.items);
},
4 years ago
_hasFill: function () {
var o = this.options;
if (o.rowSize.length > 0) {
return o.rowSize.indexOf("fill") >= 0;
}
return BI.some(o.items, function (i, item) {
if (item.height === "fill") {
return true;
}
});
},
6 years ago
_addElement: function (i, item) {
var o = this.options;
4 years ago
var w = BI.FlexVerticalLayout.superclass._addElement.apply(this, arguments);
4 years ago
var rowSize = o.rowSize.length > 0 ? o.rowSize[i] : item.height >= 1 ? null : item.height;
4 years ago
if (o.rowSize.length > 0) {
if (item.height >= 1 && o.rowSize[i] >= 1 && o.rowSize[i] !== item.height) {
4 years ago
rowSize = null;
4 years ago
}
}
6 years ago
w.element.css({
5 years ago
position: "relative"
6 years ago
});
4 years ago
if (rowSize !== "auto") {
if (rowSize === "fill" || rowSize === "") {
if (o.verticalAlign !== BI.VerticalAlign.Stretch) {
if (o.scrollable === true || o.scrolly === true) {
w.element.addClass("f-s-n");
}
}
// 当既有动态宽度和自适应宽度的时候只压缩自适应
4 years ago
if (rowSize === "" && this._hasFill()) {
w.element.addClass("f-s-n");
}
} else {
w.element.addClass("f-s-n");
4 years ago
}
5 years ago
}
4 years ago
if (rowSize > 0) {
4 years ago
w.element.height(rowSize < 1 ? ((rowSize * 100).toFixed(1) + "%") : (rowSize / BI.pixRatio + BI.pixUnit));
6 years ago
}
4 years ago
if (rowSize === "fill") {
4 years ago
w.element.addClass("f-f");
6 years ago
}
4 years ago
w.element.addClass("c-e");
if (i === 0) {
w.element.addClass("f-c");
}
if (i === o.items.length - 1) {
w.element.addClass("l-c");
}
4 years ago
this._handleGap(w, item, null, i);
6 years ago
return w;
},
populate: function (items) {
BI.FlexVerticalLayout.superclass.populate.apply(this, arguments);
this._mount();
}
});
5 years ago
BI.shortcut("bi.flex_vertical", BI.FlexVerticalLayout);