This commit is contained in:
2024-10-22 08:50:53 +03:00
parent 6631b29194
commit c8c76d59df
6 changed files with 55 additions and 16 deletions
+20 -4
View File
@@ -13,7 +13,7 @@ __PluginManager__.register('bsToastService', function(require, exports, module,
delay: 4000,
};
this.closeTemplate = '<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Закрыть"/>';
this.iconTemplate = '<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" preserveAspectRatio="xMidYMid slice" focusable="false"><rect width="100%" height="100%" fill="#007aff"/></svg>';
this.iconTemplate = '<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" preserveAspectRatio="xMidYMid slice" focusable="false"><rect width="100%" height="100%"/></svg>';
/**
* @type {HTMLElement}
*/
@@ -43,14 +43,30 @@ __PluginManager__.register('bsToastService', function(require, exports, module,
};
Service.prototype.getToastNode = function (title, message, desc = '') {
Service.prototype.getToastNode = function (title, message, desc = '', htmlClass = '') {
var closeTemplate = this.close?this.closeTemplate:'';
var toastTemplate = '<div class="toast fade hide" role="alert" aria-live="assertive" aria-atomic="true"><div class="toast-header"><div class="kit-icon toast-icon">'+this.iconTemplate+'</div><strong class="toast-title">'+title+'</strong><small class="toast-desc">' + desc+ '</small>'+closeTemplate+'</div><div class="toast-body">'+message+'</div></div>';
var toastTemplate = '<div class="toast fade hide ' + htmlClass + '" role="alert" aria-live="assertive" aria-atomic="true"><div class="toast-header"><div class="kit-icon toast-icon">'+this.iconTemplate+'</div><strong class="toast-title">'+title+'</strong><small class="toast-desc">' + desc+ '</small>'+closeTemplate+'</div><div class="toast-body">'+message+'</div></div>';
return support.makeNode(toastTemplate);
};
Service.prototype.info = function (title, message, desc = '') {
var toastNode = this.getToastNode(title, message, desc);
this.__show(title, message, desc, 'toast--info');
};
Service.prototype.success = function (title, message, desc = '') {
this.__show(title, message, desc, 'toast--success');
};
Service.prototype.warning = function (title, message, desc = '') {
this.__show(title, message, desc, 'toast--warning');
};
Service.prototype.error = function (title, message, desc = '') {
this.__show(title, message, desc, 'toast--error');
};
Service.prototype.__show = function (title, message, desc = '', htmlClass = '') {
var toastNode = this.getToastNode(title, message, desc, htmlClass);
var toast = new bsToast(toastNode, this.option);
toast.data = {
title: title,