Toast - A Bootstrap 4.2+ jQuery plugin for the toast component https://github.com/exacti/Toast
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

8 lines
1.6 KiB

/**
* @author Script47 (https://github.com/Script47/Toast)
* @description Toast - A Bootstrap 4.2+ jQuery plugin for the toast component
* @version 0.6.0
**/
(function(b){b.toast=function(a){b("#toast-container").length||(b("body").prepend('<div id="toast-container" aria-live="polite" aria-atomic="true"></div>'),b("#toast-container").append('<div id="toast-wrapper"></div>'),b("body").on("hidden.bs.toast",".toast",function(){b(this).remove()}));var d="",e="",f="text-muted",g="",l=a.title||"Notice!",m=a.subtitle||"",h=a.content||"",k=a.delay||-1,c=a.img;switch(a.type||"info"){case "info":d="bg-info";g=f=e="text-white";break;case "success":d="bg-success";
g=f=e="text-white";break;case "warning":case "warn":d="bg-warning";g=f=e="text-white";break;case "error":case "danger":d="bg-danger",g=f=e="text-white"}a='<div class="toast" role="alert" aria-live="assertive" aria-atomic="true" '+(-1===k?'data-autohide="false"':'data-delay="'+k+'"')+">"+('<div class="toast-header '+d+" "+e+'">');"undefined"!==typeof c&&(a+='<img src="'+c.src+'" class="'+(c["class"]||"")+' mr-2" alt="'+(c.alt||"Image")+'" '+("undefined"!==typeof c.title?'data-toggle="tooltip" title="'+
c.title+'"':"")+">");a=a+('<strong class="mr-auto">'+l+"</strong>")+('<small class="'+f+'">'+m+"</small>");a+='<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">';a+='<span aria-hidden="true" class="'+g+'">&times;</span>';a+="</button>";a+="</div>";""!==h&&(a+='<div class="toast-body">',a+=h,a+="</div>");a+="</div>";b("#toast-wrapper").append(a);b("#toast-wrapper .toast:last").toast("show")}})(jQuery);