From dceef8f14e07e0ceb05e23b6295ecdb4fda45573 Mon Sep 17 00:00:00 2001 From: treecat Date: Thu, 26 May 2022 10:11:30 +0800 Subject: [PATCH] =?UTF-8?q?ddd8fcf=20-=20DESIGN-4069=20fix:=20=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E4=BA=86=20iconSize=20=E5=B1=9E=E6=80=A7=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=8C=89=E9=92=AE=E7=9A=84=20loadin?= =?UTF-8?q?g=20=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/base/button/demo.button.js | 3 ++- src/base/single/button/buttons/button.js | 30 ++++++++++++++---------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/demo/js/base/button/demo.button.js b/demo/js/base/button/demo.button.js index 56a38620d..195fe06e2 100644 --- a/demo/js/base/button/demo.button.js +++ b/demo/js/base/button/demo.button.js @@ -216,8 +216,9 @@ Demo.Button = BI.inherit(BI.Widget, { }, { el: { type: "bi.button", - text: "图标在上面的按钮", + text: "图标在上面的按钮,而且可以自动撑开高度", iconCls: "close-font", + iconGap: 24, iconPosition: "top" } }, { diff --git a/src/base/single/button/buttons/button.js b/src/base/single/button/buttons/button.js index 63e78faab..7c3f4c186 100644 --- a/src/base/single/button/buttons/button.js +++ b/src/base/single/button/buttons/button.js @@ -36,6 +36,7 @@ block: false, // 是否块状显示,即不显示边框,没有最小宽度的限制 clear: false, // 是否去掉边框和背景 ghost: false, // 是否幽灵显示, 即正常状态无背景 + loading: false, // 是否处于加载中 textAlign: "center", whiteSpace: "nowrap", textWidth: null, @@ -46,9 +47,8 @@ bgap: 0, lgap: 0, rgap: 0, - iconGap: 4, - iconPosition: "left", - iconSize: props.iconSize + iconGap: 8, + iconPosition: "left" }); }, @@ -74,19 +74,12 @@ } } if (BI.isKey(o.iconCls)) { - var iconCss = {}; - if (o.iconSize) { - iconCss.fontSize = o.iconSize / BI.pixRatio + BI.pixUnit; - } this.icon = BI.createWidget({ type: "bi.icon_label", cls: o.iconCls, - width: o.iconWidth, - height: o.iconHeight, - lineHeight: o.iconHeight, - iconWidth: o.iconSize, - iconHeight: o.iconSize, - css: iconCss + width: this._const.iconWidth, + height: lineHeight, + lineHeight: lineHeight }); this.text = BI.createWidget({ type: "bi.label", @@ -150,6 +143,9 @@ if (o.ghost === true) { this.element.addClass("ghost"); } + if (o.loading === true) { + this.element.addClass("loading"); + } if (o.minWidth > 0) { 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) { BI.Button.superclass.setText.apply(this, arguments); this.text.setText(text);