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.

76 lines
2.3 KiB

8 years ago
/**
* 垂直方向都居中容器, 非自适应用于高度不固定的面板
* @class BI.VerticalCenterLayout
* @extends BI.Layout
*/
BI.VerticalCenterLayout = BI.inherit(BI.Layout, {
8 years ago
props: function () {
return BI.extend(BI.VerticalCenterLayout.superclass.props.apply(this, arguments), {
8 years ago
baseCls: "bi-vertical-center-layout",
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0
});
},
6 years ago
8 years ago
render: function () {
BI.VerticalCenterLayout.superclass.render.apply(this, arguments);
var self = this, o = this.options, items = o.items;
8 years ago
var list = [];
BI.each(items, function (i) {
list.push({
column: 0,
row: i,
5 years ago
el: BI._lazyCreateWidget({
8 years ago
type: "bi.default",
8 years ago
cls: "center-element " + (i === 0 ? "first-element " : "") + (i === items.length - 1 ? "last-element" : "")
7 years ago
})
8 years ago
});
});
BI.each(items, function (i, item) {
7 years ago
if (item) {
5 years ago
var w = BI._lazyCreateWidget(item);
8 years ago
w.element.css({
position: "absolute",
left: (o.hgap + o.lgap) / BI.pixRatio + BI.pixUnit,
right: (o.hgap + o.rgap) / BI.pixRatio + BI.pixUnit,
top: (o.vgap + o.tgap) / BI.pixRatio + BI.pixUnit,
bottom: (o.vgap + o.bgap) / BI.pixRatio + BI.pixUnit,
8 years ago
height: "auto"
8 years ago
});
list[i].el.addItem(w);
8 years ago
}
});
6 years ago
return {
8 years ago
type: "bi.grid",
6 years ago
ref: function (_ref) {
self.wrapper = _ref;
},
8 years ago
columns: 1,
rows: list.length,
items: list
6 years ago
};
},
resize: function () {
// console.log("vertical_center布局不需要resize");
},
addItem: function (item) {
// do nothing
throw new Error("cannot be added");
},
update: function (opt) {
return this.wrapper.update(opt);
8 years ago
},
populate: function (items) {
6 years ago
this.wrapper.populate.apply(this.wrapper, arguments);
8 years ago
}
});
5 years ago
BI.shortcut("bi.vertical_center", BI.VerticalCenterLayout);