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.

108 lines
3.4 KiB

8 years ago
/**
* 固定子组件上下左右的布局容器
* @class BI.AbsoluteLayout
* @extends BI.Layout
*/
BI.AbsoluteLayout = BI.inherit(BI.Layout, {
8 years ago
props: function () {
return BI.extend(BI.AbsoluteLayout.superclass.props.apply(this, arguments), {
8 years ago
baseCls: "bi-absolute-layout",
hgap: null,
vgap: null,
lgap: null,
rgap: null,
tgap: null,
bgap: null
});
},
8 years ago
render: function () {
BI.AbsoluteLayout.superclass.render.apply(this, arguments);
8 years ago
this.populate(this.options.items);
},
_addElement: function (i, item) {
var o = this.options;
var w = BI.AbsoluteLayout.superclass._addElement.apply(this, arguments);
var left = 0, right = 0, top = 0, bottom = 0;
if (BI.isNotNull(item.left)) {
w.element.css({left: item.left / BI.pixRatio + BI.pixUnit});
8 years ago
left += item.left;
}
if (BI.isNotNull(item.right)) {
w.element.css({right: item.right / BI.pixRatio + BI.pixUnit});
8 years ago
right += item.right;
}
if (BI.isNotNull(item.top)) {
w.element.css({top: item.top / BI.pixRatio + BI.pixUnit});
8 years ago
top += item.top;
}
if (BI.isNotNull(item.bottom)) {
w.element.css({bottom: item.bottom / BI.pixRatio + BI.pixUnit});
8 years ago
bottom += item.bottom;
}
if (BI.isNotNull(o.hgap)) {
left += o.hgap;
w.element.css({left: left / BI.pixRatio + BI.pixUnit});
8 years ago
right += o.hgap;
w.element.css({right: right / BI.pixRatio + BI.pixUnit});
8 years ago
}
if (BI.isNotNull(o.vgap)) {
top += o.vgap;
w.element.css({top: top / BI.pixRatio + BI.pixUnit});
8 years ago
bottom += o.vgap;
w.element.css({bottom: bottom / BI.pixRatio + BI.pixUnit});
8 years ago
}
if (BI.isNotNull(o.lgap)) {
left += o.lgap;
w.element.css({left: left / BI.pixRatio + BI.pixUnit});
8 years ago
}
if (BI.isNotNull(o.rgap)) {
right += o.rgap;
w.element.css({right: right / BI.pixRatio + BI.pixUnit});
8 years ago
}
if (BI.isNotNull(o.tgap)) {
top += o.tgap;
w.element.css({top: top / BI.pixRatio + BI.pixUnit});
8 years ago
}
if (BI.isNotNull(o.bgap)) {
bottom += o.bgap;
w.element.css({bottom: bottom / BI.pixRatio + BI.pixUnit});
8 years ago
}
if (BI.isNotNull(item.width)) {
w.element.css({width: item.width / BI.pixRatio + BI.pixUnit});
8 years ago
}
if (BI.isNotNull(item.height)) {
w.element.css({height: item.height / BI.pixRatio + BI.pixUnit});
8 years ago
}
7 years ago
w.element.css({position: "absolute"});
8 years ago
return w;
},
resize: function () {
this.stroke(this.options.items);
},
stroke: function (items) {
8 years ago
this.options.items = items || [];
8 years ago
var self = this;
BI.each(items, function (i, item) {
7 years ago
if (item) {
8 years ago
if (!BI.isWidget(item) && !item.el) {
8 years ago
throw new Error("el must be exist");
8 years ago
}
self._addElement(i, item);
}
});
},
populate: function (items) {
BI.AbsoluteLayout.superclass.populate.apply(this, arguments);
8 years ago
this._mount();
8 years ago
}
});
BI.shortcut("bi.absolute", BI.AbsoluteLayout);