You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openpower.foundation/themes/openpowerfoundation/static/lib/loader/loader.min.js

1 line
2.1 KiB
JavaScript

"use strict";Rocket.defaults.loader={target:"",append:!1,body:"",colour:"grey-blue",delay:0,size:"normal",type:"spinner"},Rocket.loader=function(e){var o=e.target,d=void 0===o?Rocket.defaults.loader.target:o,t=e.append,a=void 0===t?Rocket.defaults.loader.append:t,l=e.body,n=void 0===l?Rocket.defaults.loader.body:l,r=e.colour,c=void 0===r?Rocket.defaults.loader.colour:r,i=e.delay,s=void 0===i?Rocket.defaults.loader.delay:i,m=e.size,u=void 0===m?Rocket.defaults.loader.size:m,p=e.type,v=void 0===p?Rocket.defaults.loader.type:p,k=void 0,y=void 0,R={add:function(){setTimeout(function(){y=Rocket.dom.element(d),Rocket.is.element(y)&&(Rocket.has.class(y,"is-loading")||(Rocket.classes.add(y,"is-loading"),a?y.appendChild(k):(y.style.display="none",y.parentNode.insertBefore(k,y))))},1e3*s)},changeBody:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";if(Rocket.is.element(k)){var o=k.querySelector(".mod-loader-body");if(Rocket.is.element(o)&&Rocket.is.string(e)){for(var d=o.childNodes,t=0,a=d.length;t<a;t++)d[t].parentNode.removeChild(d[t]);o.appendChild(document.createTextNode(e))}}},remove:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";y=Rocket.dom.element(d),Rocket.is.element(y)&&setTimeout(function(){Rocket.classes.remove(y,"is-loading"),y.style.display=Rocket.is.string(e)?e:"",Rocket.is.element(k)&&Rocket.dom.remove(k)},0)}};return k=function(){var e=document.createElement("div"),o=document.createElement("div"),d=document.createElement("div"),t=1;switch(e.className="mod-loader _mod-type-"+v,"grey-blue"!==c&&(e.className+=" _mod-colour-"+c),"normal"!==u&&(e.className+=" _mod-size-"+u),o.className="mod-loader-inner",d.className="mod-loader-element",v){case"dots":t=3;break;case"pulse":t=2}for(var a=1,l=t;a<=l;a++){var r=document.createElement("div");r.className="mod-loader-part-"+a,d.appendChild(r)}if(o.appendChild(d),n.length>0){var i=document.createElement("div");i.className="mod-loader-body",i.appendChild(document.createTextNode(n)),o.appendChild(i)}return e.appendChild(o),e}(),R.add(),{loader:k,changeBody:R.changeBody,add:R.add,remove:R.remove}};