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",