UNPKG

18x

Version:

util js for build web site

1 lines 1.02 kB
var t,e,o,s,i;e=(t=document).createElement.bind(t),s=()=>e("div"),o=new(o=class{constructor(){this._li=[],this._bottom=0}new(o,i={}){var n,a,r,l,d,m,c,f,h,p;if((h=[...t.getElementsByTagName("dialog")]).length>0){for(c of(h.reverse(),h))if(c.open){n=c;break}}return n||(n=t.body),{timeout:p,body:n,close:a,html:m}=Object.assign({timeout:9,body:n,close:1},i),h=this._li,(d=s()).className="animated fadeInLeft toast",d.style.marginBottom=this._bottom+"px",f=s(),m?f.innerHTML=o:f.innerText=o,d.appendChild(f),a&&((l=e("i")).className="x",d.appendChild(l)),h.push(d),n.appendChild(d),this._bottom+=14+d.offsetHeight,d.close=r=()=>{d.classList.add("fadeOutLeft"),setTimeout(()=>{var t,e,o,s;for(h.splice(h.indexOf(d),1),n.removeChild(d),o=0,s=t=0,e=h.length;t<e;s=++t)(c=h[s]).style.marginBottom=o+"px",o+=14+c.offsetHeight;return this._bottom=o},500)},a&&(l.onclick=r),p&&setTimeout(r,1e3*p),d}});export default i=function(...t){return o.new(...t)};export const toastErr=(...t)=>{var e;return(e=i(...t)).classList.add("ERR"),e};