Browse Source

chore: 优化布局

es6
guy 3 years ago
parent
commit
b38da911c6
  1. 14
      src/base/layer/layer.popup.js
  2. 22
      src/core/wrapper/layout.js
  3. 4
      src/core/wrapper/layout/adapt/absolute.horizontal.js
  4. 4
      src/core/wrapper/layout/adapt/absolute.leftrightvertical.js
  5. 4
      src/core/wrapper/layout/adapt/absolute.vertical.js
  6. 4
      src/core/wrapper/layout/adapt/adapt.center.js
  7. 16
      src/core/wrapper/layout/adapt/adapt.leftrightvertical.js
  8. 4
      src/core/wrapper/layout/adapt/adapt.vertical.js
  9. 4
      src/core/wrapper/layout/adapt/inline.center.js
  10. 4
      src/core/wrapper/layout/adapt/inline.horizontal.js
  11. 4
      src/core/wrapper/layout/adapt/inline.vertical.js
  12. 4
      src/core/wrapper/layout/flex/flex.center.js
  13. 4
      src/core/wrapper/layout/flex/flex.horizontal.center.js
  14. 4
      src/core/wrapper/layout/flex/flex.leftrightvertical.center.js
  15. 4
      src/core/wrapper/layout/flex/flex.vertical.center.js
  16. 4
      src/core/wrapper/layout/float/float.absolute.horizontal.js
  17. 4
      src/core/wrapper/layout/float/float.absolute.leftrightvertical.js
  18. 4
      src/core/wrapper/layout/float/float.absolute.vertical.js
  19. 4
      src/core/wrapper/layout/float/float.horizontal.js
  20. 8
      src/core/wrapper/layout/layout.flow.js
  21. 6
      src/core/wrapper/layout/layout.inline.js
  22. 16
      src/core/wrapper/layout/layout.tape.js
  23. 2
      src/widget/downlist/popup.downlist.js
  24. 2
      src/widget/multilayerdownlist/popup.downlist.js
  25. 4
      typescript/shims-tsx.ts

14
src/base/layer/layer.popup.js

@ -22,8 +22,8 @@ BI.PopupView = BI.inherit(BI.Widget, {
bgap: 0,
vgap: 0,
hgap: 0,
innerVGap: 0,
innerHGap: 0,
innerVgap: 0,
innerHgap: 0,
showArrow: false,
direction: BI.Direction.Top, // 工具栏的方向
stopEvent: false, // 是否停止mousedown、mouseup事件
@ -134,10 +134,10 @@ BI.PopupView = BI.inherit(BI.Widget, {
this.button_group = BI.createWidget(o.el, {type: "bi.button_group", value: o.value});
this.button_group.element.css({
"min-height": BI.isNumeric(o.minHeight) ? (o.minHeight / BI.pixRatio + BI.pixUnit) : o.minHeight,
"padding-top": o.innerVGap / BI.pixRatio + BI.pixUnit,
"padding-bottom": o.innerVGap / BI.pixRatio + BI.pixUnit,
"padding-left": o.innerHGap / BI.pixRatio + BI.pixUnit,
"padding-right": o.innerHGap / BI.pixRatio + BI.pixUnit
"padding-top": o.innerVgap / BI.pixRatio + BI.pixUnit,
"padding-bottom": o.innerVgap / BI.pixRatio + BI.pixUnit,
"padding-left": o.innerHgap / BI.pixRatio + BI.pixUnit,
"padding-right": o.innerHgap / BI.pixRatio + BI.pixUnit
});
return this.button_group;
},
@ -397,7 +397,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
var tbHeight = this.toolbar ? (this.toolbar.attr("height") || 24) : 0,
tabHeight = this.tab ? (this.tab.attr("height") || 24) : 0,
toolHeight = ((this.tool && this.tool.attr("height")) || 24) * ((this.tool && this.tool.isVisible()) ? 1 : 0);
var resetHeight = h - tbHeight - tabHeight - toolHeight - 2 * this.options.innerVGap;
var resetHeight = h - tbHeight - tabHeight - toolHeight - 2 * this.options.innerVgap;
this.view.resetHeight ? this.view.resetHeight(resetHeight) :
this.view.element.css({"max-height": resetHeight / BI.pixRatio + BI.pixUnit});
},

22
src/core/wrapper/layout.js

@ -15,8 +15,8 @@ BI.Layout = BI.inherit(BI.Widget, {
scrollx: false, // true, false
scrolly: false, // true, false
items: [],
innerHGap: 0,
innerVGap: 0,
innerHgap: 0,
innerVgap: 0,
};
},
@ -286,13 +286,13 @@ BI.Layout = BI.inherit(BI.Widget, {
var o = this.options;
var innerLgap, innerRgap, innerTgap, innerBgap;
if (BI.isNull(vIndex)) {
innerTgap = innerBgap = o.innerVGap;
innerLgap = hIndex === 0 ? o.innerHGap : 0;
innerRgap = hIndex === o.items.length - 1 ? o.innerHGap : 0;
innerTgap = innerBgap = o.innerVgap;
innerLgap = hIndex === 0 ? o.innerHgap : 0;
innerRgap = hIndex === o.items.length - 1 ? o.innerHgap : 0;
} else {
innerLgap = innerRgap = o.innerHGap;
innerTgap = vIndex === 0 ? o.innerVGap : 0;
innerBgap = vIndex === o.items.length - 1 ? o.innerVGap : 0;
innerLgap = innerRgap = o.innerHgap;
innerTgap = vIndex === 0 ? o.innerVgap : 0;
innerBgap = vIndex === o.items.length - 1 ? o.innerVgap : 0;
}
if (o.vgap + o.tgap + innerTgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
var top = ((BI.isNull(vIndex) || vIndex === 0) ? o.vgap : 0) + o.tgap + innerTgap + (item.tgap || 0) + (item.vgap || 0);
@ -324,9 +324,9 @@ BI.Layout = BI.inherit(BI.Widget, {
_handleReverseGap: function (w, item, index) {
var o = this.options;
var innerLgap, innerRgap, innerTgap, innerBgap;
innerLgap = innerRgap = o.innerHGap;
innerTgap = index === 0 ? o.innerVGap : 0;
innerBgap = index === o.items.length - 1 ? o.innerVGap : 0;
innerLgap = innerRgap = o.innerHgap;
innerTgap = index === 0 ? o.innerVgap : 0;
innerBgap = index === o.items.length - 1 ? o.innerVgap : 0;
if (o.vgap + o.tgap + innerTgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
var top = (index === 0 ? o.vgap : 0) + (index === 0 ? o.tgap : 0) + innerTgap + (item.tgap || 0) + (item.vgap || 0);
w.element.css({

4
src/core/wrapper/layout/adapt/absolute.horizontal.js

@ -38,8 +38,8 @@ BI.AbsoluteHorizontalLayout = BI.inherit(BI.Layout, {
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
};
},

4
src/core/wrapper/layout/adapt/absolute.leftrightvertical.js

@ -23,8 +23,8 @@ BI.AbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
BI.AbsoluteLeftRightVerticalAdaptLayout.superclass.render.apply(this, arguments);
return {
type: "bi.htape",
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
ref: function (_ref) {
self.layout = _ref;
},

4
src/core/wrapper/layout/adapt/absolute.vertical.js

@ -38,8 +38,8 @@ BI.AbsoluteVerticalLayout = BI.inherit(BI.Layout, {
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
};
},

4
src/core/wrapper/layout/adapt/adapt.center.js

@ -39,8 +39,8 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, {
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
};
},

16
src/core/wrapper/layout/adapt/adapt.leftrightvertical.js

@ -34,8 +34,8 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
if (leftRight.left || "left" in o.items) {
layoutArray.push({
type: "bi.left",
lgap: o.innerHGap,
vgap: o.innerVGap,
lgap: o.innerHgap,
vgap: o.innerVgap,
items: [{
el: {
type: "bi.vertical_adapt",
@ -57,8 +57,8 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
if (leftRight.right || "right" in o.items) {
layoutArray.push({
type: "bi.right",
rgap: o.innerHGap,
vgap: o.innerVGap,
rgap: o.innerHgap,
vgap: o.innerVgap,
items: [{
el: {
type: "bi.vertical_adapt",
@ -148,8 +148,8 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, {
tgap: o.tgap,
bgap: o.bgap,
vgap: o.vgap,
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
scrollx: o.scrollx,
scrolly: o.scrolly,
scrollable: o.scrollable
@ -202,8 +202,8 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
tgap: o.tgap,
bgap: o.bgap,
vgap: o.vgap,
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
scrollx: o.scrollx,
scrolly: o.scrolly,
scrollable: o.scrollable

4
src/core/wrapper/layout/adapt/adapt.vertical.js

@ -39,8 +39,8 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, {
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
};
},

4
src/core/wrapper/layout/adapt/inline.center.js

@ -41,8 +41,8 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, {
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
};
},

4
src/core/wrapper/layout/adapt/inline.horizontal.js

@ -41,8 +41,8 @@ BI.InlineHorizontalAdaptLayout = BI.inherit(BI.Layout, {
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
};
},

4
src/core/wrapper/layout/adapt/inline.vertical.js

@ -41,8 +41,8 @@ BI.InlineVerticalAdaptLayout = BI.inherit(BI.Layout, {
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
};
},

4
src/core/wrapper/layout/flex/flex.center.js

@ -37,8 +37,8 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, {
vgap: o.vgap,
tgap: o.tgap,
bgap: o.bgap,
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
items: o.items
};
},

4
src/core/wrapper/layout/flex/flex.horizontal.center.js

@ -38,8 +38,8 @@ BI.FlexHorizontalCenter = BI.inherit(BI.Layout, {
vgap: o.vgap,
tgap: o.tgap,
bgap: o.bgap,
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
items: o.items
};
},

4
src/core/wrapper/layout/flex/flex.leftrightvertical.center.js

@ -29,8 +29,8 @@ BI.FlexLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
scrollx: o.scrollx,
scrolly: o.scrolly,
scrollable: o.scrollable,
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
};
},

4
src/core/wrapper/layout/flex/flex.vertical.center.js

@ -39,8 +39,8 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, {
lgap: o.lgap,
rgap: o.rgap,
hgap: o.hgap,
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
items: o.items
};
},

4
src/core/wrapper/layout/float/float.absolute.horizontal.js

@ -36,8 +36,8 @@ BI.FloatAbsoluteHorizontalLayout = BI.inherit(BI.Layout, {
// lgap和rgap不传的话内部不会设置left和right
lgap: o.lgap,
rgap: o.rgap,
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
};
},

4
src/core/wrapper/layout/float/float.absolute.leftrightvertical.js

@ -29,8 +29,8 @@ BI.FloatAbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
verticalAlign: o.verticalAlign,
items: this._formatItems(o.items),
vgap: "50%",
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
scrollx: o.scrollx,
scrolly: o.scrolly,
scrollable: o.scrollable

4
src/core/wrapper/layout/float/float.absolute.vertical.js

@ -36,8 +36,8 @@ BI.FloatAbsoluteVerticalLayout = BI.inherit(BI.Layout, {
// tgap和bgap不传的话内部不会设置top和bottom
tgap: o.tgap,
bgap: o.bgap,
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
};
},

4
src/core/wrapper/layout/float/float.horizontal.js

@ -51,8 +51,8 @@ BI.FloatHorizontalLayout = BI.inherit(BI.Layout, {
}],
horizontalAlign: o.horizontalAlign,
verticalAlign: o.verticalAlign,
innerHGap: o.innerHGap,
innerVGap: o.innerVGap,
innerHgap: o.innerHgap,
innerVgap: o.innerVgap,
scrollx: o.scrollx,
scrolly: o.scrolly,
scrollable: o.scrollable

8
src/core/wrapper/layout/layout.flow.js

@ -22,16 +22,16 @@ BI.FloatLeftLayout = BI.inherit(BI.Layout, {
render: function () {
BI.FloatLeftLayout.superclass.render.apply(this, arguments);
var o = this.options;
if (o.innerHGap !== 0) {
if (o.innerHgap !== 0) {
this.element.css({
paddingLeft: this._optimiseGap(o.innerHgap),
paddingRight: this._optimiseGap(o.innerHgap)
})
}
if (o.innerVGap !== 0) {
if (o.innerVgap !== 0) {
this.element.css({
paddingTop: this._optimiseGap(o.innerVGap),
paddingBottom: this._optimiseGap(o.innerVGap)
paddingTop: this._optimiseGap(o.innerVgap),
paddingBottom: this._optimiseGap(o.innerVgap)
})
}
this.populate(this.options.items);

6
src/core/wrapper/layout/layout.inline.js

@ -52,7 +52,7 @@ BI.InlineLayout = BI.inherit(BI.Layout, {
});
w.element.addClass("i-item");
if (columnSize === "fill" || columnSize === "") {
var length = 0, gap = o.hgap + o.innerHGap;
var length = 0, gap = o.hgap + o.innerHgap;
var fillCount = 0, autoCount = 0;
for (var k = 0, len = o.columnSize.length || o.items.length; k < len; k++) {
var cz = o.columnSize.length > 0 ? o.columnSize[k] : o.items[k].width;
@ -81,8 +81,8 @@ BI.InlineLayout = BI.inherit(BI.Layout, {
}
this._handleGap(w, item, i);
if (o.verticalAlign === BI.VerticalAlign.Stretch && BI.isNull(item.height)) {
var top = o.innerVGap + o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0),
bottom = o.innerVGap + o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0);
var top = o.innerVgap + o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0),
bottom = o.innerVgap + o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0);
var gap = (top + bottom) > 0 && (top + bottom) < 1 ? ((top + bottom) * 100).toFixed(1) + "%" : (top + bottom) / BI.pixRatio + BI.pixUnit;
w.element.css("height", "calc(100% - " + gap + ")");
}

16
src/core/wrapper/layout/layout.tape.js

@ -43,8 +43,8 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
}
w.element.css({
position: "absolute",
top: self._optimiseGap((item.vgap || 0) + (item.tgap || 0) + o.innerVGap + o.vgap + o.tgap),
bottom: self._optimiseGap((item.bgap || 0) + (item.vgap || 0) + o.innerVGap + o.vgap + o.bgap)
top: self._optimiseGap((item.vgap || 0) + (item.tgap || 0) + o.innerVgap + o.vgap + o.tgap),
bottom: self._optimiseGap((item.bgap || 0) + (item.vgap || 0) + o.innerVgap + o.vgap + o.bgap)
});
if (o.verticalAlign === BI.VerticalAlign.Middle) {
w.element.css({
@ -59,8 +59,8 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
});
var left = {}, right = {};
left[0] = o.innerHGap;
right[items.length - 1] = o.innerHGap;
left[0] = o.innerHgap;
right[items.length - 1] = o.innerHgap;
BI.any(items, function (i, item) {
if (BI.isEmptyObject(item)) {
@ -163,8 +163,8 @@ BI.VTapeLayout = BI.inherit(BI.Layout, {
}
w.element.css({
position: "absolute",
left: self._optimiseGap((item.lgap || 0) + (item.hgap || 0) + o.innerHGap + o.hgap + o.lgap),
right: self._optimiseGap((item.hgap || 0) + (item.rgap || 0) + o.innerHGap + o.hgap + o.rgap)
left: self._optimiseGap((item.lgap || 0) + (item.hgap || 0) + o.innerHgap + o.hgap + o.lgap),
right: self._optimiseGap((item.hgap || 0) + (item.rgap || 0) + o.innerHgap + o.hgap + o.rgap)
});
if (o.horizontalAlign === BI.HorizontalAlign.Center) {
w.element.css({
@ -179,8 +179,8 @@ BI.VTapeLayout = BI.inherit(BI.Layout, {
});
var top = {}, bottom = {};
top[0] = o.innerVGap;
bottom[items.length - 1] = o.innerVGap;
top[0] = o.innerVgap;
bottom[items.length - 1] = o.innerVgap;
BI.any(items, function (i, item) {
if (BI.isEmptyObject(item)) {

2
src/widget/downlist/popup.downlist.js

@ -110,7 +110,7 @@ BI.DownListPopup = BI.inherit(BI.Pane, {
}]
},
innerVGap: 5,
innerVgap: 5,
maxHeight: 378
};
item.el.childValues = [];

2
src/widget/multilayerdownlist/popup.downlist.js

@ -107,7 +107,7 @@ BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, {
}]
},
innerVGap: 5,
innerVgap: 5,
maxHeight: 378,
};
self._createChildren(item);

4
typescript/shims-tsx.ts

@ -19,8 +19,8 @@ interface UIProps {
interface AdditionalProps {
column: number;
row: number;
innerVGap: number;
innerHGap: number;
innerVgap: number;
innerHgap: number;
}
interface ElementClassProps<T> extends UIProps {

Loading…
Cancel
Save