(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); } let bg_header_class = '', fg_header_class = '', fg_subtitle = 'text-muted', fg_dismiss = '', title = typeof opts === 'object' ? opts.title || '' : arguments[0] || 'Notice!', subtitle = typeof opts === 'object' ? opts.subtitle || '' : arguments[1] || '', content = typeof opts === 'object' ? opts.content || '' : arguments[2] || '', type = typeof opts === 'object' ? opts.type || '' : arguments[3] || 'info', delay = typeof opts === 'object' ? opts.delay || 3000 : arguments[4] || 3000; switch (type) { case 'info': bg_header_class = 'bg-info'; fg_header_class = 'text-white'; fg_subtitle = 'text-white'; fg_dismiss = 'text-white'; break; case 'success': bg_header_class = 'bg-success'; fg_header_class = 'text-white'; fg_subtitle = 'text-white'; fg_dismiss = 'text-white'; break; case 'warning': case 'warn': bg_header_class = 'bg-warning'; fg_header_class = 'text-white'; fg_subtitle = 'text-white'; fg_dismiss = 'text-white'; break; case 'error': case 'danger': bg_header_class = 'bg-danger'; fg_header_class = 'text-white'; fg_subtitle = 'text-white'; fg_dismiss = 'text-white'; break; } let html = ''; html += ''; $('#toast-wrapper').append(html); $('#toast-wrapper .toast:last').toast('show'); } }(jQuery));