(function ($) { const TOAST_CONTAINER_HTML = '
'; const TOAST_WRAPPER_HTML = '
'; $.toast = function (opts) { if (!$('#toast-container').length) { $('body').prepend(TOAST_CONTAINER_HTML); $('#toast-container').append(TOAST_WRAPPER_HTML); $('body').on('hidden.bs.toast', '.toast', function () { $(this).remove(); }); } let bg_header_class = '', fg_header_class = '', fg_subtitle_class = 'text-muted', fg_dismiss_class = '', title = opts.title || 'Notice!', subtitle = opts.subtitle || '', content = opts.content || '', type = opts.type || 'info', delay = opts.delay || -1, img = opts.img; switch (type) { case 'info': bg_header_class = 'bg-info'; fg_header_class = 'text-white'; fg_subtitle_class = 'text-white'; fg_dismiss_class = 'text-white'; break; case 'success': bg_header_class = 'bg-success'; fg_header_class = 'text-white'; fg_subtitle_class = 'text-white'; fg_dismiss_class = 'text-white'; break; case 'warning': case 'warn': bg_header_class = 'bg-warning'; fg_header_class = 'text-white'; fg_subtitle_class = 'text-white'; fg_dismiss_class = 'text-white'; break; case 'error': case 'danger': bg_header_class = 'bg-danger'; fg_header_class = 'text-white'; fg_subtitle_class = 'text-white'; fg_dismiss_class = 'text-white'; break; } let delay_or_autohide = ''; if (delay === -1) { delay_or_autohide = 'data-autohide="false"'; } else { delay_or_autohide = 'data-delay="' + delay + '"'; } let html = ''; $('#toast-wrapper').append(html); $('#toast-wrapper .toast:last').toast('show'); } }(jQuery));