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组件
2.0(2021-07)
- layout支持forceUpdate刷新方式
- width属性支持calc()
- 修改了颜色选择器交互

12
src/core/h.js

@ -29,7 +29,17 @@ BI.h = function (type, props, children) {
el: children[0]
}, props);
}
if (type === "left") {
return BI.extend({
left: children
}, props);
}
if (type === "right") {
return BI.extend({
right: children
}, props);
}
return BI.extend({
type: type,
type: type
}, 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;
},
verticalAlign: o.verticalAlign,
items: this._formatItems(),
items: this._formatItems(o.items),
scrollx: o.scrollx,
scrolly: o.scrolly,
scrollable: o.scrollable
};
},
_formatItems: function () {
_formatItems: function (items) {
var o = this.options;
var leftItems = o.items.left || [];
var rightItems = o.items.right || [];
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;
}
});
}
var leftItems = left || items.left || [];
var rightItems = right || items.right || [];
leftItems = BI.map(leftItems, function (i, item) {
var json = {
el: BI.stripEL(item),
@ -80,7 +91,7 @@ BI.AbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
this.layout.stroke(this._formatItems())
this.layout.stroke(this._formatItems(this.options.items));
},
addItem: function () {
@ -89,8 +100,7 @@ BI.AbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
populate: function (items) {
this.options.items = items;
this.layout.populate(this._formatItems());
this.layout.populate(this._formatItems(items));
}
});
BI.shortcut("bi.absolute_left_right_vertical_adapt", BI.AbsoluteLeftRightVerticalAdaptLayout);
@ -132,7 +142,7 @@ BI.AbsoluteRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
this.layout.stroke([{}].concat(this.options.items))
this.layout.stroke([{}].concat(this.options.items));
},
addItem: function () {

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

@ -29,8 +29,9 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
render: function () {
var o = this.options, self = this;
BI.LeftRightVerticalAdaptLayout.superclass.render.apply(this, arguments);
var leftRight = this._getLeftRight(o.items);
var layoutArray = [];
if ("left" in o.items) {
if (leftRight.left || "left" in o.items) {
layoutArray.push({
type: "bi.left",
items: [{
@ -40,7 +41,7 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
self.left = _ref;
},
height: "100%",
items: o.items.left,
items: leftRight.left || o.items.left,
hgap: o.lhgap,
lgap: o.llgap,
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({
type: "bi.right",
items: [{
@ -61,7 +62,7 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
self.right = _ref;
},
height: "100%",
items: o.items.right,
items: leftRight.right || o.items.right,
hgap: o.rhgap,
lgap: o.rlgap,
rgap: o.rrgap,
@ -75,9 +76,29 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
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 () {
this.left.stroke(this.options.items.left);
this.right.stroke(this.options.items.right);
var leftRight = this._getLeftRight(this.options.items);
this.left.stroke(leftRight.left || this.options.items.left);
this.right.stroke(leftRight.right || this.options.items.right);
},
addItem: function () {
@ -86,8 +107,9 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
populate: function (items) {
this.left.populate(items.left);
this.right.populate(items.right);
var leftRight = this._getLeftRight(items);
this.left.populate(leftRight.left || items.left);
this.right.populate(leftRight.right || items.right);
}
});
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) {
var o = this.options;
var leftItems = items.left || [];
var rightItems = items.right || [];
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;
}
});
}
var leftItems = left || items.left || [];
var rightItems = right || items.right || [];
leftItems = BI.map(leftItems, function (i, item) {
var json = {
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) {
var o = this.options;
var leftItems = items.left || [];
var rightItems = items.right || [];
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;
}
});
}
var leftItems = left || items.left || [];
var rightItems = right || items.right || [];
leftItems = BI.map(leftItems, function (i, item) {
var el = BI.stripEL(item);
if (o.verticalAlign === BI.VerticalAlign.Middle) {

Loading…
Cancel
Save