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.

77 lines
2.3 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), {
4 years ago
baseCls: "bi-center",
8 years ago
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
var self = this, o = this.options;
var list = [], items = o.items;
8 years ago
BI.each(items, function (i) {
list.push({
column: i,
row: 0,
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
width: "auto",
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: list.length,
rows: 1,
items: list
6 years ago
};
},
resize: function () {
// console.log("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.center", BI.CenterLayout);