/** * 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 = $(document.body); if (!$('.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 = $('
' + message + '
'); 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);