Browse Source

feature: 支持align

es6
guy 3 years ago
parent
commit
1243cb6746
  1. 26
      src/core/wrapper/layout/layout.table.js

26
src/core/wrapper/layout/layout.table.js

@ -8,9 +8,11 @@ BI.TableLayout = BI.inherit(BI.Layout, {
props: function () { props: function () {
return BI.extend(BI.TableLayout.superclass.props.apply(this, arguments), { return BI.extend(BI.TableLayout.superclass.props.apply(this, arguments), {
baseCls: "bi-t", baseCls: "bi-t",
scrolly: true, // scrolly: true,
columnSize: [], columnSize: [],
rowSize: [], rowSize: [],
horizontalAlign: BI.HorizontalAlign.Stretch,
verticalAlign: BI.VerticalAlign.Stretch,
// rowSize: 30, // or [30,30,30] // rowSize: 30, // or [30,30,30]
hgap: 0, hgap: 0,
vgap: 0, vgap: 0,
@ -43,8 +45,8 @@ BI.TableLayout = BI.inherit(BI.Layout, {
return self._optimiseGap(size); return self._optimiseGap(size);
}).join(" ") : BI.range(o.items.length).fill(this._optimiseGap(o.rowSize)).join(" "), }).join(" ") : BI.range(o.items.length).fill(this._optimiseGap(o.rowSize)).join(" "),
"grid-row-gap": this._optimiseGap(o.vgap), "grid-row-gap": this._optimiseGap(o.vgap),
"grid-column-gap": this._optimiseGap(o.hgap), "grid-column-gap": this._optimiseGap(o.hgap)
}) });
} }
return { return {
type: "bi.default", type: "bi.default",
@ -57,6 +59,7 @@ BI.TableLayout = BI.inherit(BI.Layout, {
_formatItems: function (items) { _formatItems: function (items) {
var o = this.options; var o = this.options;
function firstElement (item, row, col) { function firstElement (item, row, col) {
if (row === 0) { if (row === 0) {
item.addClass("first-row"); item.addClass("first-row");
@ -95,14 +98,25 @@ BI.TableLayout = BI.inherit(BI.Layout, {
return firstObject(item, row, col); return firstObject(item, row, col);
} }
} }
function wrapLayout (item) {
return {
type: "bi.horizontal_fill",
columnSize: ["fill"],
horizontalAlign: o.horizontalAlign,
verticalAlign: o.verticalAlign,
items: [BI.formatEL(item)]
};
}
return BI.reduce(items, function (row, result, i) { return BI.reduce(items, function (row, result, i) {
return result.concat(BI.map(row, function (j, item) { return result.concat(BI.map(row, function (j, item) {
if (BI.isEmpty(item)) { if (BI.isEmpty(item)) {
return { return first(wrapLayout({
type: "bi.layout" type: "bi.layout"
} }), i, j);
} }
return first(item, i, j); return first(wrapLayout(item), i, j);
})); }));
}, []); }, []);
}, },

Loading…
Cancel
Save