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.FloatCenterLayout
* @extends BI.Layout
*/
BI.FloatCenterLayout = BI.inherit(BI.Layout, {
8 years ago
props: function () {
return BI.extend(BI.FloatCenterLayout.superclass.props.apply(this, arguments), {
4 years ago
baseCls: "bi-float-center",
8 years ago
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0
});
},
8 years ago
render: function () {
BI.FloatCenterLayout.superclass.render.apply(this, arguments);
var self = this, o = this.options, items = o.items;
8 years ago
var list = [], width = 100 / items.length;
BI.each(items, function (i) {
5 years ago
var widget = BI._lazyCreateWidget({
8 years ago
type: "bi.default"
7 years ago
});
8 years ago
widget.element.addClass("center-element " + (i === 0 ? "first-element " : "") + (i === items.length - 1 ? "last-element" : "")).css({
width: width + "%",
height: "100%"
});
list.push({
el: widget
});
});
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.left",
6 years ago
ref: function (_ref) {
4 years ago
self.layout = _ref;
6 years ago
},
8 years ago
items: list
6 years ago
};
},
resize: function () {
// console.log("floatcenter布局不需要resize");
},
addItem: function (item) {
// do nothing
throw new Error("不能添加子组件");
6 years ago
},
update: function (opt) {
4 years ago
return this.layout.update(opt);
8 years ago
},
populate: function (items) {
4 years ago
this.layout.populate.apply(this.layout, arguments);
8 years ago
}
});
5 years ago
BI.shortcut("bi.float_center", BI.FloatCenterLayout);