-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslick-loader.min.js
1 lines (1 loc) · 6.18 KB
/
slick-loader.min.js
1
"use strict";function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var o,t=0;t<r.length;t++)o=r[t],o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}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(){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(){var _this2=this;return this._waitForBody().then(function(){_this2.element.classList.add("active")}),this}},{key:"disable",value:function(){var _this3=this;return this._waitForBody().then(function(){_this3.element.classList.remove("active")}),this}},{key:"setText",value:function(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(){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(){var _this6=this;this._waitForBody().then(function(){_this6.element.remove()})}}],[{key:"destroy",value:function(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()}}}])}();window.SlickLoader=new Slickloader,window.Slickloader=Slickloader;