Browse Source

Pull request #2148: 无JIAR任务 整理代码

Merge in VISUAL/fineui from ~GUY/fineui:master to master

* commit '37e48b32e77af91f0c902fcd6705c99e84d310c2':
  整理代码
es6
guy 3 years ago
parent
commit
161119428f
  1. 5
      changelog.md
  2. 12
      src/core/h.js
  3. 26
      src/core/wrapper/layout/adapt/absolute.leftrightvertical.js
  4. 38
      src/core/wrapper/layout/adapt/adapt.leftrightvertical.js
  5. 15
      src/core/wrapper/layout/flex/flex.leftrightvertical.center.js
  6. 15
      src/core/wrapper/layout/float/float.absolute.leftrightvertical.js

5
changelog.md

@ -1,6 +1,9 @@
# 更新日志 # 更新日志
2.0(2021-07) 2.0(2021-09)
- 支持h函数传递left、right,优化left_right_vertical_adapt布局的jsx写法
- 新增bi.virtual_group_list组件 - 新增bi.virtual_group_list组件
2.0(2021-07)
- layout支持forceUpdate刷新方式 - layout支持forceUpdate刷新方式
- width属性支持calc() - width属性支持calc()
- 修改了颜色选择器交互 - 修改了颜色选择器交互

12
src/core/h.js

@ -29,7 +29,17 @@ BI.h = function (type, props, children) {
el: children[0] el: children[0]
}, props); }, props);
} }
if (type === "left") {
return BI.extend({
left: children
}, props);
}
if (type === "right") {
return BI.extend({
right: children
}, props);
}
return BI.extend({ return BI.extend({
type: type, type: type
}, children.length > 0 ? {items: children} : {}, props); }, children.length > 0 ? {items: children} : {}, props);
}; };

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

@ -27,17 +27,28 @@ BI.AbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
self.layout = _ref; self.layout = _ref;
}, },
verticalAlign: o.verticalAlign, verticalAlign: o.verticalAlign,
items: this._formatItems(), items: this._formatItems(o.items),
scrollx: o.scrollx, scrollx: o.scrollx,
scrolly: o.scrolly, scrolly: o.scrolly,
scrollable: o.scrollable scrollable: o.scrollable
}; };
}, },
_formatItems: function () { _formatItems: function (items) {
var o = this.options; var o = this.options;
var leftItems = o.items.left || []; var left, right;
var rightItems = o.items.right || []; if (BI.isArray(items)) {
BI.each(items, function (i, item) {
if (item.left) {
left = item.left;
}
if (item.right) {
right = item.right;
}
});
}
var leftItems = left || items.left || [];
var rightItems = right || items.right || [];
leftItems = BI.map(leftItems, function (i, item) { leftItems = BI.map(leftItems, function (i, item) {
var json = { var json = {
el: BI.stripEL(item), el: BI.stripEL(item),
@ -80,7 +91,7 @@ BI.AbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
}, },
resize: function () { resize: function () {
this.layout.stroke(this._formatItems()) this.layout.stroke(this._formatItems(this.options.items));
}, },
addItem: function () { addItem: function () {
@ -89,8 +100,7 @@ BI.AbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
}, },
populate: function (items) { populate: function (items) {
this.options.items = items; this.layout.populate(this._formatItems(items));
this.layout.populate(this._formatItems());
} }
}); });
BI.shortcut("bi.absolute_left_right_vertical_adapt", BI.AbsoluteLeftRightVerticalAdaptLayout); BI.shortcut("bi.absolute_left_right_vertical_adapt", BI.AbsoluteLeftRightVerticalAdaptLayout);
@ -132,7 +142,7 @@ BI.AbsoluteRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
}, },
resize: function () { resize: function () {
this.layout.stroke([{}].concat(this.options.items)) this.layout.stroke([{}].concat(this.options.items));
}, },
addItem: function () { addItem: function () {

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

@ -29,8 +29,9 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
render: function () { render: function () {
var o = this.options, self = this; var o = this.options, self = this;
BI.LeftRightVerticalAdaptLayout.superclass.render.apply(this, arguments); BI.LeftRightVerticalAdaptLayout.superclass.render.apply(this, arguments);
var leftRight = this._getLeftRight(o.items);
var layoutArray = []; var layoutArray = [];
if ("left" in o.items) { if (leftRight.left || "left" in o.items) {
layoutArray.push({ layoutArray.push({
type: "bi.left", type: "bi.left",
items: [{ items: [{
@ -40,7 +41,7 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
self.left = _ref; self.left = _ref;
}, },
height: "100%", height: "100%",
items: o.items.left, items: leftRight.left || o.items.left,
hgap: o.lhgap, hgap: o.lhgap,
lgap: o.llgap, lgap: o.llgap,
rgap: o.lrgap, rgap: o.lrgap,
@ -51,7 +52,7 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
}] }]
}); });
} }
if ("right" in o.items) { if (leftRight.right || "right" in o.items) {
layoutArray.push({ layoutArray.push({
type: "bi.right", type: "bi.right",
items: [{ items: [{
@ -61,7 +62,7 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
self.right = _ref; self.right = _ref;
}, },
height: "100%", height: "100%",
items: o.items.right, items: leftRight.right || o.items.right,
hgap: o.rhgap, hgap: o.rhgap,
lgap: o.rlgap, lgap: o.rlgap,
rgap: o.rrgap, rgap: o.rrgap,
@ -75,9 +76,29 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
return layoutArray; return layoutArray;
}, },
_getLeftRight: function (items) {
var o = this.options;
var left, right;
if (BI.isArray(items)) {
BI.each(items, function (i, item) {
if (item.left) {
left = item.left;
}
if (item.right) {
right = item.right;
}
});
}
return {
left: left,
right: right
};
},
resize: function () { resize: function () {
this.left.stroke(this.options.items.left); var leftRight = this._getLeftRight(this.options.items);
this.right.stroke(this.options.items.right); this.left.stroke(leftRight.left || this.options.items.left);
this.right.stroke(leftRight.right || this.options.items.right);
}, },
addItem: function () { addItem: function () {
@ -86,8 +107,9 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
}, },
populate: function (items) { populate: function (items) {
this.left.populate(items.left); var leftRight = this._getLeftRight(items);
this.right.populate(items.right); this.left.populate(leftRight.left || items.left);
this.right.populate(leftRight.right || items.right);
} }
}); });
BI.shortcut("bi.left_right_vertical_adapt", BI.LeftRightVerticalAdaptLayout); BI.shortcut("bi.left_right_vertical_adapt", BI.LeftRightVerticalAdaptLayout);

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

@ -34,8 +34,19 @@ BI.FlexLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
_formatItems: function (items) { _formatItems: function (items) {
var o = this.options; var o = this.options;
var leftItems = items.left || []; var left, right;
var rightItems = items.right || []; if (BI.isArray(items)) {
BI.each(items, function (i, item) {
if (item.left) {
left = item.left;
}
if (item.right) {
right = item.right;
}
});
}
var leftItems = left || items.left || [];
var rightItems = right || items.right || [];
leftItems = BI.map(leftItems, function (i, item) { leftItems = BI.map(leftItems, function (i, item) {
var json = { var json = {
el: BI.stripEL(item) el: BI.stripEL(item)

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

@ -37,8 +37,19 @@ BI.FloatAbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
_formatItems: function (items) { _formatItems: function (items) {
var o = this.options; var o = this.options;
var leftItems = items.left || []; var left, right;
var rightItems = items.right || []; if (BI.isArray(items)) {
BI.each(items, function (i, item) {
if (item.left) {
left = item.left;
}
if (item.right) {
right = item.right;
}
});
}
var leftItems = left || items.left || [];
var rightItems = right || items.right || [];
leftItems = BI.map(leftItems, function (i, item) { leftItems = BI.map(leftItems, function (i, item) {
var el = BI.stripEL(item); var el = BI.stripEL(item);
if (o.verticalAlign === BI.VerticalAlign.Middle) { if (o.verticalAlign === BI.VerticalAlign.Middle) {

Loading…
Cancel
Save