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.

170 lines
5.2 KiB

8 years ago
/**
* 水平布局
* @class BI.HorizontalLayout
* @extends BI.Layout
*/
BI.HorizontalLayout = BI.inherit(BI.Layout, {
8 years ago
props: function () {
return BI.extend(BI.HorizontalLayout.superclass.props.apply(this, arguments), {
8 years ago
baseCls: "bi-horizontal-layout",
8 years ago
verticalAlign: BI.VerticalAlign.Top,
8 years ago
columnSize: [],
scrollx: true,
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0
});
},
8 years ago
render: function () {
BI.HorizontalLayout.superclass.render.apply(this, arguments);
this.$table = BI.Widget._renderEngine.createElement("<table>").attr({cellspacing: 0, cellpadding: 0}).css({
7 years ago
position: "relative",
8 years ago
"white-space": "nowrap",
"border-spacing": "0px",
7 years ago
border: "none",
8 years ago
"border-collapse": "separate"
});
this.$tr = BI.Widget._renderEngine.createElement("<tr>");
8 years ago
this.$tr.appendTo(this.$table);
8 years ago
this.populate(this.options.items);
},
_addElement: function (i, item) {
var o = this.options;
var td;
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i];
8 years ago
if (!this.hasWidget(this._getChildName(i))) {
7 years ago
var w = BI.createWidget(item);
7 years ago
w.element.css({position: "relative", margin: "0px auto"});
8 years ago
td = BI.createWidget({
type: "bi.default",
tagName: "td",
attributes: {
width: width
},
items: [w]
7 years ago
});
8 years ago
this.addWidget(this._getChildName(i), td);
8 years ago
} else {
8 years ago
td = this.getWidgetByName(this._getChildName(i));
8 years ago
td.element.attr("width", width);
}
if (i === 0) {
td.element.addClass("first-element");
}
td.element.css({
7 years ago
position: "relative",
8 years ago
"vertical-align": o.verticalAlign,
7 years ago
margin: "0",
padding: "0",
border: "none"
8 years ago
});
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
8 years ago
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) + "px"
7 years ago
});
8 years ago
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
8 years ago
w.element.css({
"margin-left": (i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0) +"px"
7 years ago
});
8 years ago
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
8 years ago
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) + "px"
7 years ago
});
8 years ago
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
8 years ago
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) + "px"
7 years ago
});
8 years ago
}
return td;
},
7 years ago
appendFragment: function (frag) {
this.$tr.append(frag);
this.element.append(this.$table);
8 years ago
},
resize: function () {
// console.log("horizontal layout do not need to resize");
},
7 years ago
_getWrapper: function () {
8 years ago
return this.$tr;
8 years ago
},
populate: function (items) {
BI.HorizontalLayout.superclass.populate.apply(this, arguments);
8 years ago
this._mount();
8 years ago
}
});
7 years ago
BI.shortcut("bi.horizontal", BI.HorizontalLayout);
8 years ago
/**
* 水平布局
* @class BI.HorizontalCellLayout
* @extends BI.Layout
*/
BI.HorizontalCellLayout = BI.inherit(BI.Layout, {
8 years ago
props: function () {
return BI.extend(BI.HorizontalCellLayout.superclass.props.apply(this, arguments), {
8 years ago
baseCls: "bi-horizontal-cell-layout",
scrollable: true,
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0
});
},
8 years ago
render: function () {
BI.HorizontalCellLayout.superclass.render.apply(this, arguments);
7 years ago
this.element.css({display: "table", "vertical-align": "top"});
8 years ago
this.populate(this.options.items);
},
_addElement: function (i, item) {
var o = this.options;
var w = BI.HorizontalCellLayout.superclass._addElement.apply(this, arguments);
7 years ago
w.element.css({position: "relative", display: "table-cell", "vertical-align": "middle"});
8 years ago
if (o.hgap + o.lgap > 0) {
w.element.css({
"margin-left": o.hgap + o.lgap + "px"
7 years ago
});
8 years ago
}
if (o.hgap + o.rgap > 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + "px"
7 years ago
});
8 years ago
}
if (o.vgap + o.tgap > 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + "px"
7 years ago
});
8 years ago
}
if (o.vgap + o.bgap > 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + "px"
7 years ago
});
8 years ago
}
return w;
},
resize: function () {
// console.log("horizontal do not need to resize");
},
populate: function (items) {
BI.HorizontalCellLayout.superclass.populate.apply(this, arguments);
8 years ago
this._mount();
8 years ago
}
});
7 years ago
BI.shortcut("bi.horizontal_cell", BI.HorizontalCellLayout);