-
Notifications
You must be signed in to change notification settings - Fork 6
/
jackbox.min.js
1 lines (1 loc) · 2.02 KB
/
jackbox.min.js
1
!function(a){var b={};b.version=1,b.settings={notification:{time:5,actionButtonText:"<i></i>",classNames:[],icon:"<i></i>"}},b.init=function(c){c&&(b.oldBrowserSupport=c.oldBrowserSupport||!1,b.settings.notification=Object.assign({},b.settings.notification,c.notification));var d=document.createElement("div");d.classList.add("notifications"),d.id="jackbox",a.document.body.appendChild(d)};var c=function(c,d,e){var f=Object.assign({},b.settings.notification,e),g=document.createElement("div"),h=document.createElement("div"),i=document.createElement("div"),j=document.createElement("div"),k=document.createElement("div"),l=document.createElement("div"),m=f.time;l.innerHTML=f.icon;var n=null;g.classList.add("notification"),void 0===!g.style.flex&&g.classList.add("old-support"),g.classList.add(d),f.classNames.forEach(function(a){g.classList.add(a)}),h.classList.add("progress"),h.style.transitionDuration=m+"s",i.innerHTML=c,i.classList.add("message"),j.classList.add("action"),k.classList.add("action-button"),k.innerHTML=f.actionButtonText,l.classList.add("icon"),j.appendChild(k),g.appendChild(l),g.appendChild(i),g.appendChild(j),g.appendChild(h);var o=function(){g.classList.remove("show"),g.removeEventListener("mouseleave",q),a.clearTimeout(n),setTimeout(function(){document.getElementById("jackbox").removeChild(g)},200)},p=function(){g.classList.remove("counting"),a.clearTimeout(n)},q=function(){g.classList.contains("stop-counting")||setTimeout(function(){g.classList.contains("counting")||g.classList.add("counting"),null!=n&&a.clearTimeout(n),n=a.setTimeout(o,1e3*m)},10)},r=function(){g.classList.toggle("stop-counting"),p()};k.addEventListener("click",o),g.addEventListener("mouseenter",p),g.addEventListener("click",r),g.addEventListener("mouseleave",q),document.getElementById("jackbox").appendChild(g),setTimeout(function(){g.classList.add("show")},10),q()};b.error=function(a,b){c(a,"error",b)},b.success=function(a,b){c(a,"success",b)},b.warning=function(a,b){c(a,"warning",b)},b.information=function(a,b){c(a,"information",b)},a.Jackbox=b}(window);