From 972e5c9c4f39aa57891b004b3be269b13c4a90a7 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 20 Dec 2021 15:26:46 +0800 Subject: [PATCH] =?UTF-8?q?BI-96759=EF=BC=9Atoast=E6=94=AF=E6=8C=81closabl?= =?UTF-8?q?e=E5=B1=9E=E6=80=A7=EF=BC=8C=E5=8F=AF=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E6=98=BE=E7=A4=BA=E5=85=B3=E9=97=AD=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 1 + src/base/foundation/message.js | 5 +++++ src/base/single/tip/tip.toast.js | 11 ++++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 0aecc31a7..e9ae90d8a 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2021-12) +- toast支持closable属性,可控制是否显示关闭按钮 - 新增气泡弹框控件 - BI.point支持widget添加埋点 - childContext废弃,替换成provide diff --git a/src/base/foundation/message.js b/src/base/foundation/message.js index 54d66c8d7..8fade4b01 100644 --- a/src/base/foundation/message.js +++ b/src/base/foundation/message.js @@ -32,6 +32,7 @@ BI.Msg = function () { cls: "bi-message-animate bi-message-leave", level: level, autoClose: autoClose, + closable: options.closable, text: message, listeners: [{ eventName: BI.Toast.EVENT_DESTORY, @@ -67,6 +68,10 @@ BI.Msg = function () { toast.element.removeClass("bi-message-enter").addClass("bi-message-leave"); toast.destroy(); }, 5000); + return function () { + toast.element.removeClass("bi-message-enter").addClass("bi-message-leave"); + toast.destroy(); + }; }, _show: function (hasCancel, title, message, callback) { BI.isNull($mask) && ($mask = BI.Widget._renderEngine.createElement("
").css({ diff --git a/src/base/single/tip/tip.toast.js b/src/base/single/tip/tip.toast.js index aca66e47a..f853d8659 100644 --- a/src/base/single/tip/tip.toast.js +++ b/src/base/single/tip/tip.toast.js @@ -15,7 +15,9 @@ BI.Toast = BI.inherit(BI.Tip, { return BI.extend(BI.Toast.superclass._defaultConfig.apply(this, arguments), { extraCls: "bi-toast", text: "", - level: "success" // success或warning + level: "success", // success或warning + autoClose: true, + closable: null }); }, @@ -56,6 +58,9 @@ BI.Toast = BI.inherit(BI.Tip, { break; } + var hasCloseIcon = function () { + return o.closable === true || (o.closable === null && o.autoClose === false); + }; var items = [{ type: "bi.icon_label", cls: cls + " toast-icon", @@ -68,12 +73,12 @@ BI.Toast = BI.inherit(BI.Tip, { textHeight: 16, textAlign: "left" }, - rgap: o.autoClose ? this._const.hgap : 0 + rgap: hasCloseIcon() ? 0 : this._const.hgap }]; var columnSize = [36, "fill"]; - if (o.autoClose === false) { + if (hasCloseIcon()) { items.push({ type: "bi.icon_button", cls: "close-font toast-icon",