-
Notifications
You must be signed in to change notification settings - Fork 0
/
slick-loader.min.js
1 lines (1 loc) · 5.79 KB
/
slick-loader.min.js
1
"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _defineProperties(target,props){for(var descriptor,i=0;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}function _createClass(Constructor,protoProps,staticProps){return protoProps&&_defineProperties(Constructor.prototype,protoProps),staticProps&&_defineProperties(Constructor,staticProps),Constructor}if(Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),window.LOADER=document.createElement("div"),window.LOADER.classList.add("loadingScreen"),window.LOADER.innerHTML="<svg width=\"100%\" height=\"100%\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 100 100\" preserveAspectRatio=\"xMidYMid\" class=\"lds-eclipse\" style=\"background: none;\"> <path ng-attr-d=\"{{config.pathCmd}}\" ng-attr-fill=\"{{config.color}}\" stroke=\"none\" d=\"M10 50A40 40 0 0 0 90 50A40 42 0 0 1 10 50\" fill=\"#ffffff\"></path> <text style=\"cursor: move;\" stroke=\"#000\" xml:space=\"preserve\" text-anchor=\"middle\" font-family=\"Helvetica, Arial, sans-serif\" font-size=\"5\" id=\"svg_4\" y=\"48.875258\" x=\"50\" stroke-opacity=\"null\" stroke-width=\"0\" fill=\"#ffffff\"></text> <text xml:space=\"preserve\" text-anchor=\"middle\" font-family=\"Helvetica, Arial, sans-serif\" font-size=\"5\" id=\"svg_5\" y=\"55.010217\" x=\"50\" stroke-opacity=\"null\" stroke-width=\"0\" stroke=\"#000\" fill=\"#ffffff\"></text> </svg>",document.body)document.body.appendChild(window.LOADER);else{var observer=new MutationObserver(function(){document.body&&(observer.disconnect(),document.body.appendChild(window.LOADER))});observer.observe(document.documentElement,{childList:!0})}window.LOADER.enable=function(){return console.warn("LOADER is depcrecated. Use SlickLoader instead."),window.LOADER.classList.add("active"),window.LOADER},window.LOADER.disable=function(){return console.warn("LOADER is depcrecated. Use SlickLoader instead."),window.LOADER.classList.remove("active"),window.LOADER},window.LOADER.setText=function(text1,text2){console.warn("LOADER is depcrecated. Use SlickLoader instead.");var textList=window.LOADER.getElementsByTagName("text");return void 0!==text1&&(textList[0].innerHTML=text1),void 0!==text2&&(textList[1].innerHTML=text2),window.LOADER},window.LOADER.clearText=function(){console.warn("LOADER is depcrecated. Use SlickLoader instead.");var textList=window.LOADER.getElementsByTagName("text");return textList[0].innerHTML="",textList[1].innerHTML="",window.LOADER};var Slickloader=function(){function Slickloader(parent){var _this=this;_classCallCheck(this,Slickloader),this._waitForBody().then(function(){if(_this._parent=parent?parent instanceof Element?parent:document.querySelector(parent):document.body,!_this._parent)throw new Error("SlickLoader: "+("string"==typeof parent?"The selector `"+parent+"` didn't match any element.":"The element you provided was undefined"));Array.from(_this._parent.children).some(function(e){return e.matches(".slick-loader")})&&console.warn("SlickLoader: The loader has already been initialized in this context."),_this.element=document.createElement("div"),_this.element.classList.add("slick-loader"),_this.element.innerHTML="<svg width=\"100%\" height=\"100%\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 100 100\" preserveAspectRatio=\"xMidYMid\" class=\"lds-eclipse\" style=\"background: none;\"> <path ng-attr-d=\"{{config.pathCmd}}\" ng-attr-fill=\"{{config.color}}\" stroke=\"none\" d=\"M10 50A40 40 0 0 0 90 50A40 42 0 0 1 10 50\" fill=\"#ffffff\"></path> <text style=\"cursor: move;\" stroke=\"#000\" xml:space=\"preserve\" text-anchor=\"middle\" font-family=\"Helvetica, Arial, sans-serif\" font-size=\"5\" id=\"svg_4\" y=\"48.875258\" x=\"50\" stroke-opacity=\"null\" stroke-width=\"0\" fill=\"#ffffff\"></text> <text xml:space=\"preserve\" text-anchor=\"middle\" font-family=\"Helvetica, Arial, sans-serif\" font-size=\"5\" id=\"svg_5\" y=\"55.010217\" x=\"50\" stroke-opacity=\"null\" stroke-width=\"0\" stroke=\"#000\" fill=\"#ffffff\"></text> </svg>",parent&&_this.element.classList.add("slick-loader-inner"),_this._parent.appendChild(_this.element)})}return _createClass(Slickloader,[{key:"_waitForBody",value:function _waitForBody(){return new Promise(function(resolve){if(document.body)resolve();else{var _observer=new MutationObserver(function(){document.body&&(_observer.disconnect(),resolve())});_observer.observe(document.documentElement,{childList:!0})}})}},{key:"enable",value:function enable(){var _this2=this;return this._waitForBody().then(function(){_this2.element.classList.add("active")}),this}},{key:"disable",value:function disable(){var _this3=this;return this._waitForBody().then(function(){_this3.element.classList.remove("active")}),this}},{key:"setText",value:function setText(text1,text2){var _this4=this;return this._waitForBody().then(function(){var textList=_this4.element.getElementsByTagName("text");void 0!==text1&&(textList[0].innerHTML=text1),void 0!==text2&&(textList[1].innerHTML=text2)}),this}},{key:"clearText",value:function clearText(){var _this5=this;return this._waitForBody().then(function(){var textList=_this5.element.getElementsByTagName("text");textList[0].innerHTML="",textList[1].innerHTML=""}),this}},{key:"destroy",value:function destroy(){var _this6=this;this._waitForBody().then(function(){_this6.element.remove()})}}],[{key:"destroy",value:function destroy(selector){var element=document.querySelector(selector);if(element){var loader=Array.from(element.children).find(function(e){return e.matches(".slick-loader")});loader&&loader.remove()}}}]),Slickloader}();window.SlickLoader=new Slickloader,window.Slickloader=Slickloader;