/*! * Ladda 0.6.0 (2013-07-07, 19:10) * http://lab.hakim.se/ladda * MIT licensed * * Copyright (C) 2013 Hakim El Hattab, http://hakim.se */ (function(t,e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(["spin"],e):t.Ladda=e(t.Spinner)})(this,function(t){"use strict";function e(t){if(t===void 0)throw"Button target must be defined.";t.querySelector(".ladda-label")||(t.innerHTML=''+t.innerHTML+"");var e=a(t),n=document.createElement("span");n.className="ladda-spinner",t.appendChild(n);var i,o={start:function(){return t.setAttribute("disabled",""),t.setAttribute("data-loading",""),clearTimeout(i),e.spin(n),this.setProgress(0),this},stop:function(){return t.removeAttribute("disabled"),t.removeAttribute("data-loading"),clearTimeout(i),i=setTimeout(function(){e.stop()},1e3),this},toggle:function(){return this.isLoading()?this.stop():this.start(),this},setProgress:function(e){var n=t.querySelector(".ladda-progress");0===e&&n&&n.parentNode?n.parentNode.removeChild(n):(n||(n=document.createElement("div"),n.className="ladda-progress",t.appendChild(n)),n.style.width=(e||0)*t.offsetWidth+"px")},enable:function(){return this.stop(),this},disable:function(){return this.stop(),t.setAttribute("disabled",""),this},isLoading:function(){return t.hasAttribute("data-loading")}};return r.push(o),o}function n(t,n){n=n||{};var i=[];"string"==typeof t?i=[].slice.call(document.querySelectorAll(t)):"object"==typeof t&&"string"==typeof t.nodeName&&(i=[t]);for(var a=0,r=i.length;r>a;a++)(function(){var t=i[a];if("function"==typeof t.addEventListener){var r=e(t),o=-1;t.addEventListener("click",function(){r.start(),"number"==typeof n.timeout&&(clearTimeout(o),o=setTimeout(r.stop,n.timeout)),"function"==typeof n.callback&&n.callback.apply(null,[r])},!1)}})()}function i(){for(var t=0,e=r.length;e>t;t++)r[t].stop()}function a(e){var n=e.offsetHeight;n>32&&(n*=.8),e.hasAttribute("data-spinner-size")&&(n=parseInt(e.getAttribute("data-spinner-size"),10));var i=12,a=.2*n,r=.6*a,o=7>a?2:3;return new t({color:"#fff",lines:i,radius:a,length:r,width:o,zIndex:"initial",top:"auto",left:"auto",className:""})}var r=[];return{bind:n,create:e,stopAll:i}});