Browse Source

Pull request #2087: 无JIRA任务 整理代码

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

* commit '2671995821cfab0eaae8fa7fa047e74e3c146238':
  整理代码
es6
guy 3 years ago
parent
commit
d86b5847b7
  1. 24
      src/core/wrapper/layout.js
  2. 21
      src/core/wrapper/layout/adapt/adapt.table.js
  3. 21
      src/core/wrapper/layout/adapt/auto.horizontal.js
  4. 21
      src/core/wrapper/layout/flex/flex.horizontal.js
  5. 21
      src/core/wrapper/layout/flex/flex.vertical.js
  6. 21
      src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js
  7. 21
      src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.js
  8. 31
      src/core/wrapper/layout/layout.adaptive.js
  9. 22
      src/core/wrapper/layout/layout.default.js
  10. 21
      src/core/wrapper/layout/layout.inline.js
  11. 21
      src/core/wrapper/layout/layout.vertical.js

24
src/core/wrapper/layout.js

@ -214,6 +214,30 @@ BI.Layout = BI.inherit(BI.Widget, {
this.options.items.splice(index, 1); this.options.items.splice(index, 1);
}, },
_handleGap: function (w, item, hIndex, vIndex) {
var o = this.options;
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-top": (((BI.isNull(vIndex) || vIndex === 0) ? o.vgap : 0) + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (((BI.isNull(hIndex) || hIndex === 0) ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
},
/** /**
* 添加一个子组件到容器中 * 添加一个子组件到容器中
* @param {JSON/BI.Widget} item 子组件 * @param {JSON/BI.Widget} item 子组件

21
src/core/wrapper/layout/adapt/adapt.table.js

@ -91,26 +91,7 @@ BI.TableAdaptLayout = BI.inherit(BI.Layout, {
"vertical-align": o.verticalAlign, "vertical-align": o.verticalAlign,
height: "100%" height: "100%"
}); });
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { this._handleGap(w, item, i);
w.element.css({
"margin-top": (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": ((i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
return td; return td;
}, },

21
src/core/wrapper/layout/adapt/auto.horizontal.js

@ -28,26 +28,7 @@ BI.HorizontalAutoLayout = BI.inherit(BI.Layout, {
position: "relative", position: "relative",
margin: "0px auto" margin: "0px auto"
}); });
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { this._handleGap(w, item, null, i);
w.element.css({
"margin-top": ((i === 0 ? o.vgap : 0) + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
return w; return w;
}, },

21
src/core/wrapper/layout/flex/flex.horizontal.js

@ -74,26 +74,7 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
if (i === o.items.length - 1) { if (i === o.items.length - 1) {
w.element.addClass("l-c"); w.element.addClass("l-c");
} }
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { this._handleGap(w, item, i);
w.element.css({
"margin-top": (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": ((i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
return w; return w;
}, },

21
src/core/wrapper/layout/flex/flex.vertical.js

@ -73,26 +73,7 @@ BI.FlexVerticalLayout = BI.inherit(BI.Layout, {
if (i === o.items.length - 1) { if (i === o.items.length - 1) {
w.element.addClass("l-c"); w.element.addClass("l-c");
} }
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { this._handleGap(w, item, null, i);
w.element.css({
"margin-top": ((i === 0 ? o.vgap : 0) + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
return w; return w;
}, },

21
src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js

@ -71,26 +71,7 @@ BI.FlexWrapperHorizontalLayout = BI.inherit(BI.Layout, {
if (i === o.items.length - 1) { if (i === o.items.length - 1) {
w.element.addClass("l-c"); w.element.addClass("l-c");
} }
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { this._handleGap(w, item, i);
w.element.css({
"margin-top": (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": ((i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
return w; return w;
}, },

21
src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.js

@ -71,26 +71,7 @@ BI.FlexWrapperVerticalLayout = BI.inherit(BI.Layout, {
if (i === o.items.length - 1) { if (i === o.items.length - 1) {
w.element.addClass("l-c"); w.element.addClass("l-c");
} }
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { this._handleGap(w, item, null, i);
w.element.css({
"margin-top": ((i === 0 ? o.vgap : 0) + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
return w; return w;
}, },

31
src/core/wrapper/layout/layout.adaptive.js

@ -19,7 +19,6 @@ BI.AdaptiveLayout = BI.inherit(BI.Layout, {
var o = this.options; var o = this.options;
var w = BI.AdaptiveLayout.superclass._addElement.apply(this, arguments); var w = BI.AdaptiveLayout.superclass._addElement.apply(this, arguments);
w.element.css({position: "relative"}); w.element.css({position: "relative"});
var left = 0, right = 0, top = 0, bottom = 0;
if (BI.isNotNull(item.left)) { if (BI.isNotNull(item.left)) {
w.element.css({ w.element.css({
left: BI.isNumber(item.left) ? item.left / BI.pixRatio + BI.pixUnit : item.left left: BI.isNumber(item.left) ? item.left / BI.pixRatio + BI.pixUnit : item.left
@ -41,35 +40,7 @@ BI.AdaptiveLayout = BI.inherit(BI.Layout, {
}); });
} }
if (BI.isNotNull(o.hgap)) { this._handleGap(w, item);
left += o.hgap;
w.element.css({"margin-left": left / BI.pixRatio + BI.pixUnit});
right += o.hgap;
w.element.css({"margin-right": right / BI.pixRatio + BI.pixUnit});
}
if (BI.isNotNull(o.vgap)) {
top += o.vgap;
w.element.css({"margin-top": top / BI.pixRatio + BI.pixUnit});
bottom += o.vgap;
w.element.css({"margin-bottom": bottom / BI.pixRatio + BI.pixUnit});
}
if (BI.isNotNull(o.lgap)) {
left += o.lgap;
w.element.css({"margin-left": left / BI.pixRatio + BI.pixUnit});
}
if (BI.isNotNull(o.rgap)) {
right += o.rgap;
w.element.css({"margin-right": right / BI.pixRatio + BI.pixUnit});
}
if (BI.isNotNull(o.tgap)) {
top += o.tgap;
w.element.css({"margin-top": top / BI.pixRatio + BI.pixUnit});
}
if (BI.isNotNull(o.bgap)) {
bottom += o.bgap;
w.element.css({"margin-bottom": bottom / BI.pixRatio + BI.pixUnit});
}
if (BI.isNotNull(item.width)) { if (BI.isNotNull(item.width)) {
w.element.css({width: BI.isNumber(item.width) ? item.width / BI.pixRatio + BI.pixUnit : item.width}); w.element.css({width: BI.isNumber(item.width) ? item.width / BI.pixRatio + BI.pixUnit : item.width});

22
src/core/wrapper/layout/layout.default.js

@ -22,28 +22,8 @@ BI.DefaultLayout = BI.inherit(BI.Layout, {
}, },
_addElement: function (i, item) { _addElement: function (i, item) {
var o = this.options;
var w = BI.DefaultLayout.superclass._addElement.apply(this, arguments); var w = BI.DefaultLayout.superclass._addElement.apply(this, arguments);
if (o.vgap + o.tgap + (item.tgap || 0) !== 0) { this._handleGap(w, item);
w.element.css({
"margin-top": (o.vgap + o.tgap + (item.tgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
w.element.css({
"margin-left": (o.hgap + o.lgap + (item.lgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
w.element.css({
"margin-right": (o.hgap + o.rgap + (item.rgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
w.element.css({
"margin-bottom": (o.vgap + o.bgap + (item.bgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
return w; return w;
}, },

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

@ -67,31 +67,12 @@ BI.InlineLayout = BI.inherit(BI.Layout, {
w.element.css("max-width", "calc(100% - " + ((left + right) / BI.pixRatio + BI.pixUnit) + ")"); w.element.css("max-width", "calc(100% - " + ((left + right) / BI.pixRatio + BI.pixUnit) + ")");
} }
} }
this._handleGap(w, item, i);
if (o.verticalAlign === BI.VerticalAlign.Stretch) { if (o.verticalAlign === BI.VerticalAlign.Stretch) {
var top = o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0), var top = o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0),
bottom = o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0); bottom = o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0);
w.element.css("height", "calc(100% - " + ((top + bottom) / BI.pixRatio + BI.pixUnit) + ")"); w.element.css("height", "calc(100% - " + ((top + bottom) / BI.pixRatio + BI.pixUnit) + ")");
} }
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-top": (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": ((i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
return w; return w;
}, },

21
src/core/wrapper/layout/layout.vertical.js

@ -28,26 +28,7 @@ BI.VerticalLayout = BI.inherit(BI.Layout, {
w.element.css({ w.element.css({
position: "relative" position: "relative"
}); });
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { this._handleGap(w, item, null, i);
w.element.css({
"margin-top": ((i === 0 ? o.vgap : 0) + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit
});
}
if (o.horizontalAlign === BI.HorizontalAlign.Center) { if (o.horizontalAlign === BI.HorizontalAlign.Center) {
w.element.css({ w.element.css({
marginLeft: "auto", marginLeft: "auto",

Loading…
Cancel
Save