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.

136 lines
5.0 KiB

8 years ago
/**
* 上下的高度固定/左右的宽度固定中间的高度/宽度自适应
*
* @class BI.BorderLayout
* @extends BI.Layout
*/
BI.BorderLayout = BI.inherit(BI.Layout, {
8 years ago
props: function () {
return BI.extend(BI.BorderLayout.superclass.props.apply(this, arguments), {
8 years ago
baseCls: "bi-border-layout",
items: {}
});
},
8 years ago
render: function () {
BI.BorderLayout.superclass.render.apply(this, arguments);
8 years ago
this.populate(this.options.items);
},
resize: function () {
this.stroke(this.options.items);
},
addItem: function (item) {
// do nothing
7 years ago
throw new Error("cannot be added");
8 years ago
},
7 years ago
stroke: function (regions) {
8 years ago
var item;
var top = 0;
var bottom = 0;
var left = 0;
var right = 0;
if ("north" in regions) {
item = regions["north"];
if (item != null) {
if (item.el) {
if (!this.hasWidget(this._getChildName("north"))) {
5 years ago
var w = BI._lazyCreateWidget(item);
this.addWidget(this._getChildName("north"), w);
8 years ago
}
this.getWidgetByName(this._getChildName("north")).element.height(item.height)
8 years ago
.css({
7 years ago
position: "absolute",
top: (item.top || 0),
left: (item.left || 0),
right: (item.right || 0),
bottom: "initial"
8 years ago
});
}
top = (item.height || 0) + (item.top || 0) + (item.bottom || 0);
}
}
if ("south" in regions) {
item = regions["south"];
if (item != null) {
if (item.el) {
if (!this.hasWidget(this._getChildName("south"))) {
5 years ago
var w = BI._lazyCreateWidget(item);
this.addWidget(this._getChildName("south"), w);
8 years ago
}
this.getWidgetByName(this._getChildName("south")).element.height(item.height)
8 years ago
.css({
7 years ago
position: "absolute",
bottom: (item.bottom || 0),
left: (item.left || 0),
right: (item.right || 0),
top: "initial"
8 years ago
});
}
bottom = (item.height || 0) + (item.top || 0) + (item.bottom || 0);
}
}
if ("west" in regions) {
item = regions["west"];
if (item != null) {
if (item.el) {
if (!this.hasWidget(this._getChildName("west"))) {
5 years ago
var w = BI._lazyCreateWidget(item);
this.addWidget(this._getChildName("west"), w);
8 years ago
}
this.getWidgetByName(this._getChildName("west")).element.width(item.width)
8 years ago
.css({
7 years ago
position: "absolute",
left: (item.left || 0),
8 years ago
top: top,
bottom: bottom,
7 years ago
right: "initial"
8 years ago
});
}
left = (item.width || 0) + (item.left || 0) + (item.right || 0);
}
}
if ("east" in regions) {
item = regions["east"];
if (item != null) {
if (item.el) {
if (!this.hasWidget(this._getChildName("east"))) {
5 years ago
var w = BI._lazyCreateWidget(item);
this.addWidget(this._getChildName("east"), w);
8 years ago
}
this.getWidgetByName(this._getChildName("east")).element.width(item.width)
8 years ago
.css({
7 years ago
position: "absolute",
right: (item.right || 0),
8 years ago
top: top,
bottom: bottom,
7 years ago
left: "initial"
8 years ago
});
}
right = (item.width || 0) + (item.left || 0) + (item.right || 0);
}
}
if ("center" in regions) {
item = regions["center"];
if (item != null) {
if (!this.hasWidget(this._getChildName("center"))) {
5 years ago
var w = BI._lazyCreateWidget(item);
this.addWidget(this._getChildName("center"), w);
8 years ago
}
this.getWidgetByName(this._getChildName("center")).element
7 years ago
.css({position: "absolute", top: top, bottom: bottom, left: left, right: right});
8 years ago
}
}
},
6 years ago
update: function (opt) {
},
8 years ago
populate: function (items) {
BI.BorderLayout.superclass.populate.apply(this, arguments);
8 years ago
this._mount();
8 years ago
}
});
5 years ago
BI.shortcut("bi.border", BI.BorderLayout);