refactor(frontend): replace toast system with zibll notyf

This commit is contained in:
kate522 committed 2026-08-18 02:38:43 +08:00
1 parent fb11a7ed0c
commit 86614c4905
33 files changed
+603 -802

No files matched your search

+60
View File
@@ -0,0 +1,60 @@
/**
* Zibll-compatible frontend notifications.
*
* @package AKSRT
*/
(function ($, window, document) {
'use strict';
function closeNotyf($element) {
$element.addClass('notyn-out');
window.setTimeout(function () {
$element.remove();
}, 1000);
}
function notyf(message, type, time, id) {
var $body = $(document.body);
if (!$('.notyn').length) {
$body.append('<div class="notyn"></div>');
}
type = type || 'success';
if (type === 'error') {
type = 'danger';
}
time = time || 5000;
time = time < 100 ? time * 1000 : time;
var idAttribute = id ? ' id="' + id + '"' : '';
var $notification = $('<div class="noty1"' + idAttribute + '><div class="notyf ' + type + '">' + message + '</div></div>');
var shouldClose = !id;
if (id && $('#' + id).length) {
$('#' + id)
.find('.notyf')
.removeClass()
.addClass('notyf ' + type)
.html(message);
$notification = $('#' + id);
shouldClose = true;
} else {
$('.notyn').append($notification);
}
if (shouldClose) {
window.setTimeout(function () {
closeNotyf($notification);
}, time);
}
}
$(document.body).on('click', '.noty1', function () {
closeNotyf($(this));
});
window.notyf = notyf;
})(jQuery, window, document);