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
+12 -1
View File
@@ -57,11 +57,22 @@
word-wrap: break-word;
}
.toast-container--default {
z-index: 10000;
position: fixed!important;
bottom: 0!important;
right: 0!important;
padding: 1rem !important;
}
.toast--error .toast-icon svg {
fill: var(--kit-color-error, red);
}
.toast--warning .toast-icon svg {
fill: var(--kit-color-warning, orange);
}
.toast--info .toast-icon svg {
fill: var(--kit-color-primary, dodgerblue);
}
.toast--success .toast-icon svg {
fill: var(--kit-color-success, green);
}
+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,
+1 -1
View File
@@ -561,7 +561,7 @@ kit.config = kit.config || {};
script.onerror = function() {
var error = new Error(`Ошибка загрузки скрипта ${src}`);
self.errors.push(error);
console.log(`%cPlugin.load(${self.id}): error load script!`, "color: red;");
console.log(`%cPlugin.load(${self.id}): error load script ${src}!`, "color: red;");
reject(error);
};
document.head.append(script);
+1 -1
View File
File diff suppressed because one or more lines are too long
+20 -8
View File
@@ -377,10 +377,10 @@ __PluginManager__.register('support', function(require, exports, module, global)
},
});
}
function args2array(arguments) {
function args2array(_args) {
var args = [];
for (var i = 0; i < arguments.length; i++) {
args.push(arguments[i]);
for (var i = 0; i < _args.length; i++) {
args.push(_args[i]);
}
return args;
}
@@ -477,13 +477,25 @@ __PluginManager__.register('support', function(require, exports, module, global)
}
}
function arrayToObject(ar){
return Object.assign({}, ar);
}
function namespace(namespace, parent = window){
var parts=namespace.split(".");
for(var i=0;i<parts.length;i++){
if(typeof parent[parts[i]]==="undefined"){parent[parts[i]]={};}
parent=parent[parts[i]];
if(isArray(namespace)){
var parts=namespace;
} else {
var parts=namespace.split(".");
}
return parent;
var cursor = parent;
for(var i=0;i<parts.length;i++){
if(typeof cursor[parts[i]]==="undefined"){cursor[parts[i]]={};}
if(Array.isArray(cursor[parts[i]])){
cursor[parts[i]] = arrayToObject(cursor[parts[i]]);
}
cursor=cursor[parts[i]];
}
return cursor;
}
/**
+1 -1
View File
File diff suppressed because one or more lines are too long