fineui是帆软报表和BI产品线所使用的前端框架。

82 lines
2.9 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);
this.populate(this.options.items);
},
_addElement: function (i, item) {
var w = BI.FlexVerticalLayout.superclass._addElement.apply(this, arguments);
var o = this.options;
w.element.css({
5 years ago
position: "relative"
6 years ago
});
4 years ago
if (o.rowSize[i] !== "auto") {
if (o.verticalAlign === BI.VerticalAlign.Stretch && o.rowSize[i] !== "") {
4 years ago
w.element.addClass("f-f");
4 years ago
} else {
4 years ago
w.element.addClass("f-s-n");
4 years ago
}
5 years ago
}
6 years ago
if (o.rowSize[i] > 0) {
4 years ago
w.element.height(o.rowSize[i] === "" ? "" : (o.rowSize[i] <= 1 ? ((o.rowSize[i] * 100).toFixed(1) + "%") : (o.rowSize[i] / BI.pixRatio + BI.pixUnit)));
6 years ago
}
if (o.rowSize[i] === "fill") {
4 years ago
w.element.addClass("f-f");
6 years ago
}
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-top": ((i === 0 ? o.vgap : 0) + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
6 years ago
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
6 years ago
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
6 years ago
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
6 years ago
});
}
return w;
},
resize: function () {
// console.log("flex_vertical布局不需要resize");
},
populate: function (items) {
BI.FlexVerticalLayout.superclass.populate.apply(this, arguments);
this._mount();
}
});
5 years ago
BI.shortcut("bi.flex_vertical", BI.FlexVerticalLayout);