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.

132 lines
4.9 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
8 years ago
throw new Error("cannot be added")
8 years ago
},
stroke: function(regions){
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.getName() + "north")) {
var w = BI.createWidget(item);
this.addWidget(this.getName() + "north", w);
}
this.getWidgetByName(this.getName() + "north").element.height(item.height)
.css({
"position": "absolute",
"top": (item.top || 0),
"left": (item.left || 0),
"right": (item.right || 0),
"bottom": "initial"
});
}
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.getName() + "south")) {
var w = BI.createWidget(item);
this.addWidget(this.getName() + "south", w);
}
this.getWidgetByName(this.getName() + "south").element.height(item.height)
.css({
"position": "absolute",
"bottom": (item.bottom || 0),
"left": (item.left || 0),
"right": (item.right || 0),
"top": "initial"
});
}
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.getName() + "west")) {
var w = BI.createWidget(item);
this.addWidget(this.getName() + "west", w);
}
this.getWidgetByName(this.getName() + "west").element.width(item.width)
.css({
"position": "absolute",
"left": (item.left || 0),
top: top,
bottom: bottom,
"right": "initial"
});
}
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.getName() + "east")) {
var w = BI.createWidget(item);
this.addWidget(this.getName() + "east", w);
}
this.getWidgetByName(this.getName() + "east").element.width(item.width)
.css({
"position": "absolute",
"right": (item.right || 0),
top: top,
bottom: bottom,
"left": "initial"
});
}
right = (item.width || 0) + (item.left || 0) + (item.right || 0);
}
}
if ("center" in regions) {
item = regions["center"];
if (item != null) {
if (!this.hasWidget(this.getName() + "center")) {
var w = BI.createWidget(item);
this.addWidget(this.getName() + "center", w);
}
this.getWidgetByName(this.getName() + "center").element
.css({"position": "absolute", "top": top, "bottom": bottom, "left": left, "right": right});
}
}
},
populate: function (items) {
BI.BorderLayout.superclass.populate.apply(this, arguments);
8 years ago
this._mount();
8 years ago
}
});
8 years ago
BI.shortcut('bi.border', BI.BorderLayout);