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.

75 lines
2.1 KiB

8 years ago
/**
* 水平和垂直方向都居中容器, 非自适应用于宽度高度固定的面板
* @class BI.CenterLayout
* @extends BI.Layout
*/
BI.CenterLayout = BI.inherit(BI.Layout, {
8 years ago
props: function () {
return BI.extend(BI.CenterLayout.superclass.props.apply(this, arguments), {
8 years ago
baseCls: "bi-center-layout",
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0
});
},
8 years ago
render: function () {
BI.CenterLayout.superclass.render.apply(this, arguments);
8 years ago
this.populate(this.options.items);
},
resize: function () {
// console.log("center布局不需要resize");
},
addItem: function (item) {
7 years ago
// do nothing
8 years ago
throw new Error("cannot be added");
8 years ago
},
stroke: function (items) {
var self = this, o = this.options;
var list = [];
BI.each(items, function (i) {
list.push({
column: i,
row: 0,
el: BI.createWidget({
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
}, self)
8 years ago
});
});
BI.each(items, function (i, item) {
7 years ago
if (item) {
7 years ago
var w = BI.createWidget(item, self);
8 years ago
w.element.css({
position: "absolute",
left: o.hgap + o.lgap,
right: o.hgap + o.rgap,
top: o.vgap + o.tgap,
bottom: o.vgap + o.bgap,
width: "auto",
height: "auto"
8 years ago
});
list[i].el.addItem(w);
8 years ago
}
});
BI.createWidget({
type: "bi.grid",
8 years ago
element: this,
8 years ago
columns: list.length,
rows: 1,
items: list
});
},
populate: function (items) {
BI.CenterLayout.superclass.populate.apply(this, arguments);
8 years ago
this._mount();
8 years ago
}
});
7 years ago
BI.shortcut("bi.center", BI.CenterLayout);