You've already forked fm-dx-webserver
mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-02-27 06:23:53 +01:00
optimization pack
This commit is contained in:
@@ -1,22 +1,18 @@
|
||||
function sendToast(type, title, message, persistent, important) {
|
||||
var toastId = 'toast-' + new Date().getTime(); // Unique ID for each toast
|
||||
var toastId = 'toast-' + new Date().getTime();
|
||||
|
||||
// If title isn't provided, use the type as the title
|
||||
var toastTitle = title ? title : capitalizeFirstLetter(type);
|
||||
|
||||
// Icon mapping based on the toast type
|
||||
var toastIcons = {
|
||||
success: 'fa-check-circle',
|
||||
error: 'fa-times-circle',
|
||||
warning: 'fa-exclamation-triangle',
|
||||
info: 'fa-info-circle',
|
||||
default: 'fa-bell' // Default icon if the type is not found
|
||||
default: 'fa-bell'
|
||||
};
|
||||
|
||||
// Get the icon class based on the toast type, fallback to 'default' if type doesn't exist
|
||||
var iconClass = toastIcons[type] || toastIcons['default'];
|
||||
var iconClass = toastIcons[type] || toastIcons['default']; // Get the icon class based on the toast type, fallback to 'default' if type doesn't exist
|
||||
|
||||
// Create the toast element
|
||||
var $toast = $(`
|
||||
<div class="toast ${type} flex-container flex-phone ${important ? 'important' : ''}" id="${toastId}">
|
||||
<div class="toast-icon"><i class="fa-solid ${iconClass}"></i></div>
|
||||
@@ -28,33 +24,28 @@ function sendToast(type, title, message, persistent, important) {
|
||||
</div>
|
||||
`);
|
||||
|
||||
// Append the toast to the container
|
||||
$('#toast-container').append($toast);
|
||||
|
||||
// Add the 'show' class after appending for fade-in effect
|
||||
setTimeout(function () {
|
||||
$toast.addClass('show');
|
||||
}, 10); // Timeout to ensure the element is appended before the animation triggers
|
||||
}, 10);
|
||||
|
||||
// Close button functionality
|
||||
$toast.find('.close-btn').click(function () {
|
||||
closeToast($toast);
|
||||
});
|
||||
|
||||
// If not persistent, remove it after 5 seconds
|
||||
if (!persistent) {
|
||||
setTimeout(function () {
|
||||
closeToast($toast);
|
||||
}, 5000); // 5000 ms = 5 seconds
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to close and remove the toast
|
||||
function closeToast($toast) {
|
||||
$toast.removeClass('show'); // Trigger fade-out
|
||||
$toast.removeClass('show');
|
||||
setTimeout(function () {
|
||||
$toast.remove(); // Remove the element from DOM after the animation
|
||||
}, 300); // Timeout matches the CSS transition duration
|
||||
$toast.remove();
|
||||
}, 300);
|
||||
}
|
||||
|
||||
function capitalizeFirstLetter(string) {
|
||||
|
||||
Reference in New Issue
Block a user