Browse Source

BI-96759:toast支持closable属性,可控制是否显示关闭按钮

es6
guy 3 years ago
parent
commit
972e5c9c4f
  1. 1
      changelog.md
  2. 5
      src/base/foundation/message.js
  3. 11
      src/base/single/tip/tip.toast.js

1
changelog.md

@ -1,5 +1,6 @@
# 更新日志 # 更新日志
2.0(2021-12) 2.0(2021-12)
- toast支持closable属性,可控制是否显示关闭按钮
- 新增气泡弹框控件 - 新增气泡弹框控件
- BI.point支持widget添加埋点 - BI.point支持widget添加埋点
- childContext废弃,替换成provide - childContext废弃,替换成provide

5
src/base/foundation/message.js

@ -32,6 +32,7 @@ BI.Msg = function () {
cls: "bi-message-animate bi-message-leave", cls: "bi-message-animate bi-message-leave",
level: level, level: level,
autoClose: autoClose, autoClose: autoClose,
closable: options.closable,
text: message, text: message,
listeners: [{ listeners: [{
eventName: BI.Toast.EVENT_DESTORY, eventName: BI.Toast.EVENT_DESTORY,
@ -67,6 +68,10 @@ BI.Msg = function () {
toast.element.removeClass("bi-message-enter").addClass("bi-message-leave"); toast.element.removeClass("bi-message-enter").addClass("bi-message-leave");
toast.destroy(); toast.destroy();
}, 5000); }, 5000);
return function () {
toast.element.removeClass("bi-message-enter").addClass("bi-message-leave");
toast.destroy();
};
}, },
_show: function (hasCancel, title, message, callback) { _show: function (hasCancel, title, message, callback) {
BI.isNull($mask) && ($mask = BI.Widget._renderEngine.createElement("<div class=\"bi-z-index-mask\">").css({ BI.isNull($mask) && ($mask = BI.Widget._renderEngine.createElement("<div class=\"bi-z-index-mask\">").css({

11
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), { return BI.extend(BI.Toast.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-toast", extraCls: "bi-toast",
text: "", text: "",
level: "success" // success或warning level: "success", // success或warning
autoClose: true,
closable: null
}); });
}, },
@ -56,6 +58,9 @@ BI.Toast = BI.inherit(BI.Tip, {
break; break;
} }
var hasCloseIcon = function () {
return o.closable === true || (o.closable === null && o.autoClose === false);
};
var items = [{ var items = [{
type: "bi.icon_label", type: "bi.icon_label",
cls: cls + " toast-icon", cls: cls + " toast-icon",
@ -68,12 +73,12 @@ BI.Toast = BI.inherit(BI.Tip, {
textHeight: 16, textHeight: 16,
textAlign: "left" textAlign: "left"
}, },
rgap: o.autoClose ? this._const.hgap : 0 rgap: hasCloseIcon() ? 0 : this._const.hgap
}]; }];
var columnSize = [36, "fill"]; var columnSize = [36, "fill"];
if (o.autoClose === false) { if (hasCloseIcon()) {
items.push({ items.push({
type: "bi.icon_button", type: "bi.icon_button",
cls: "close-font toast-icon", cls: "close-font toast-icon",

Loading…
Cancel
Save