Browse Source

Pull request #2205: 无JIAR任务 优化一下

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

* commit 'be0c92c6dbb16cc5f6bae824b011052b8fdf52d7':
  优化代码
es6
guy 3 years ago
parent
commit
d8a277f041
  1. 36
      src/base/single/button/buttons/button.js
  2. 5
      src/base/single/label/icon.label.js

36
src/base/single/button/buttons/button.js

@ -41,12 +41,28 @@ BI.Button = BI.inherit(BI.BasicButton, {
render: function () { render: function () {
var o = this.options, self = this; var o = this.options, self = this;
// 由于button默认情况下有个边框,所以要主动算行高
var lineHeight, textHeight = o.textHeight;
if (BI.isNumber(o.height)) {
if (o.clear || o.block) {
lineHeight = o.height;
} else {
lineHeight = o.height - 2;
}
}
if (!textHeight) {
if (o.whiteSpace === "nowrap") {
textHeight = lineHeight;
}
}
if (BI.isKey(o.iconCls)) { if (BI.isKey(o.iconCls)) {
this.icon = BI.createWidget({ this.icon = BI.createWidget({
type: "bi.icon_label", type: "bi.icon_label",
cls: o.iconCls, cls: o.iconCls,
width: this._const.iconWidth, width: this._const.iconWidth,
height: o.height - 2, height: o.height,
lineHeight: lineHeight,
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
iconHeight: o.iconHeight iconHeight: o.iconHeight
}); });
@ -54,9 +70,9 @@ BI.Button = BI.inherit(BI.BasicButton, {
type: "bi.label", type: "bi.label",
text: o.text, text: o.text,
textWidth: BI.isNotNull(o.textWidth) ? o.textWidth - this._const.iconWidth : null, textWidth: BI.isNotNull(o.textWidth) ? o.textWidth - this._const.iconWidth : null,
textHeight: o.textHeight, textHeight: textHeight,
value: o.value, height: o.height,
height: o.height - 2 value: o.value
}); });
BI.createWidget({ BI.createWidget({
type: "bi.center_adapt", type: "bi.center_adapt",
@ -76,7 +92,7 @@ BI.Button = BI.inherit(BI.BasicButton, {
textAlign: o.textAlign, textAlign: o.textAlign,
whiteSpace: o.whiteSpace, whiteSpace: o.whiteSpace,
textWidth: o.textWidth, textWidth: o.textWidth,
textHeight: o.textHeight, textHeight: textHeight,
hgap: o.hgap, hgap: o.hgap,
vgap: o.vgap, vgap: o.vgap,
tgap: o.tgap, tgap: o.tgap,
@ -88,16 +104,6 @@ BI.Button = BI.inherit(BI.BasicButton, {
value: o.value value: o.value
}); });
} }
if (BI.isNumber(o.height) && !o.clear && !o.block) {
this.element.css({
height: o.height / BI.pixRatio + BI.pixUnit,
lineHeight: (o.height - 2) / BI.pixRatio + BI.pixUnit
});
} else if (o.clear || o.block) {
this.element.css({lineHeight: o.height / BI.pixRatio + BI.pixUnit});
} else {
this.element.css({lineHeight: (o.height - 2) / BI.pixRatio + BI.pixUnit});
}
if (o.block === true) { if (o.block === true) {
this.element.addClass("block"); this.element.addClass("block");
} }

5
src/base/single/label/icon.label.js

@ -8,7 +8,8 @@ BI.IconLabel = BI.inherit(BI.Single, {
props: { props: {
baseCls: "bi-icon-label horizon-center", baseCls: "bi-icon-label horizon-center",
iconWidth: null, iconWidth: null,
iconHeight: null iconHeight: null,
lineHeight: null,
}, },
render: function () { render: function () {
@ -22,7 +23,7 @@ BI.IconLabel = BI.inherit(BI.Single, {
height: o.iconHeight height: o.iconHeight
}); });
if (BI.isNumber(o.height) && o.height > 0 && BI.isNull(o.iconWidth) && BI.isNull(o.iconHeight)) { if (BI.isNumber(o.height) && o.height > 0 && BI.isNull(o.iconWidth) && BI.isNull(o.iconHeight)) {
this.element.css("lineHeight", o.height / BI.pixRatio + BI.pixUnit); this.element.css("lineHeight", (o.lineHeight || o.height) / BI.pixRatio + BI.pixUnit);
BI.createWidget({ BI.createWidget({
type: "bi.default", type: "bi.default",
element: this, element: this,

Loading…
Cancel
Save