/** * legacy-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 = jQuery(document.body); if (!jQuery('.notyn').length) { $body.append('
'); } type = type || 'success'; if (type === 'error') { type = 'danger'; } time = time || 5000; time = time < 100 ? time * 1000 : time; var idAttribute = id ? ' id="' + id + '"' : ''; var $notification = jQuery('
' + message + '
'); var shouldClose = !id; if (id && jQuery('#' + id).length) { jQuery('#' + id) .find('.notyf') .removeClass() .addClass('notyf ' + type) .html(message); $notification = jQuery('#' + id); shouldClose = true; } else { jQuery('.notyn').append($notification); } if (shouldClose) { window.setTimeout(function () { closeNotyf($notification); }, time); } } jQuery(document.body).on('click', '.noty1', function () { closeNotyf(jQuery(this)); }); window.notyf = notyf; })(jQuery, window, document);