Browse Source

ddd8fcf - DESIGN-4069 fix: 删除了 iconSize 属性,增加了按钮的 loading 状态

es6
treecat 3 years ago
parent
commit
dceef8f14e
  1. 3
      demo/js/base/button/demo.button.js
  2. 30
      src/base/single/button/buttons/button.js

3
demo/js/base/button/demo.button.js

@ -216,8 +216,9 @@ Demo.Button = BI.inherit(BI.Widget, {
}, { }, {
el: { el: {
type: "bi.button", type: "bi.button",
text: "图标在上面的按钮", text: "图标在上面的按钮,而且可以自动撑开高度",
iconCls: "close-font", iconCls: "close-font",
iconGap: 24,
iconPosition: "top" iconPosition: "top"
} }
}, { }, {

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

@ -36,6 +36,7 @@
block: false, // 是否块状显示,即不显示边框,没有最小宽度的限制 block: false, // 是否块状显示,即不显示边框,没有最小宽度的限制
clear: false, // 是否去掉边框和背景 clear: false, // 是否去掉边框和背景
ghost: false, // 是否幽灵显示, 即正常状态无背景 ghost: false, // 是否幽灵显示, 即正常状态无背景
loading: false, // 是否处于加载中
textAlign: "center", textAlign: "center",
whiteSpace: "nowrap", whiteSpace: "nowrap",
textWidth: null, textWidth: null,
@ -46,9 +47,8 @@
bgap: 0, bgap: 0,
lgap: 0, lgap: 0,
rgap: 0, rgap: 0,
iconGap: 4, iconGap: 8,
iconPosition: "left", iconPosition: "left"
iconSize: props.iconSize
}); });
}, },
@ -74,19 +74,12 @@
} }
} }
if (BI.isKey(o.iconCls)) { if (BI.isKey(o.iconCls)) {
var iconCss = {};
if (o.iconSize) {
iconCss.fontSize = o.iconSize / BI.pixRatio + BI.pixUnit;
}
this.icon = BI.createWidget({ this.icon = BI.createWidget({
type: "bi.icon_label", type: "bi.icon_label",
cls: o.iconCls, cls: o.iconCls,
width: o.iconWidth, width: this._const.iconWidth,
height: o.iconHeight, height: lineHeight,
lineHeight: o.iconHeight, lineHeight: lineHeight
iconWidth: o.iconSize,
iconHeight: o.iconSize,
css: iconCss
}); });
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.label", type: "bi.label",
@ -150,6 +143,9 @@
if (o.ghost === true) { if (o.ghost === true) {
this.element.addClass("ghost"); this.element.addClass("ghost");
} }
if (o.loading === true) {
this.element.addClass("loading");
}
if (o.minWidth > 0) { if (o.minWidth > 0) {
this.element.css({"min-width": o.minWidth / BI.pixRatio + BI.pixUnit}); this.element.css({"min-width": o.minWidth / BI.pixRatio + BI.pixUnit});
} }
@ -171,6 +167,14 @@
} }
}, },
setLoading: function (loading) {
if(loading) {
this.element.addClass("loading");
} else {
this.element.removeClass("loading");
}
},
setText: function (text) { setText: function (text) {
BI.Button.superclass.setText.apply(this, arguments); BI.Button.superclass.setText.apply(this, arguments);
this.text.setText(text); this.text.setText(text);

Loading…
Cancel
Save