btn-loader
Version:
A javascript library for handling button loading in a beautiful and clean way.
1 lines • 1.22 kB
JavaScript
!function(){function t(t){var e=this.getAttribute("timer")||60,i=this.getAttribute("size"),r=this.getAttribute("thickness"),o=this.getAttribute("color-head"),s=this.getAttribute("bck-color"),l=this.getAttribute("color-bottom"),d=this.getAttribute("color-right"),n=this.getAttribute("color-left"),a=this.getAttribute("text-after"),c=!!this.getAttribute("hide-after");this.style.display="None";var g=document.createElement("div");g.classList.add("loader"),"sm"===i?g.classList.add("sm-loader"):"md"===i?g.classList.add("md-loader"):"lg"===i?g.classList.add("lg-loader"):"xl"===i&&g.classList.add("xl-loader"),r&&(g.style.borderWidth=r.toString()+"px",g.style.borderTopWidth=r.toString()+"px"),s&&(g.style.borderColor=s.toString()),o&&(g.style.borderTopColor=o.toString()),l&&(g.style.borderBottomColor=l.toString()),d&&(g.style.borderRightColor=d.toString()),n&&(g.style.borderLeftColor=n.toString()),this.insertAdjacentElement("beforebegin",g);var b=this;setTimeout(function(){a&&(b.style.display="inline",b.innerHTML=a.toString()),b.style.display=c?"None":"inline",g.style.display="None"},1e3*e)}var e=document.getElementsByClassName("btn-loader")||[];[].slice.call(e).forEach(function(e){e.addEventListener("click",t)})}();