Current Path : /var/www/www-root/data/www.catalog.monolith-realty.ru/bitrix/js/main/loader/ |
Current File : /var/www/www-root/data/www.catalog.monolith-realty.ru/bitrix/js/main/loader/loader.min.js |
(function(){"use strict";BX.namespace("BX");if(typeof BX.Loader!=="undefined"){return}var e="ready";var t="shown";var i="hidden";function n(e){var t=new BX.Promise;if(!!e&&(e.dataset.isShown==="false"||!e.dataset.isShown)){var i=function(n){if(n.animationName==="showMainLoader"){t.fulfill(n);e.removeEventListener("animationend",i);e.removeEventListener("oAnimationEnd",i);e.removeEventListener("webkitAnimationEnd",i)}};e.addEventListener("animationend",i);e.addEventListener("oAnimationEnd",i);e.addEventListener("webkitAnimationEnd",i);e.dataset.isShown=true;requestAnimationFrame(function(){e.style.display=null;e.classList.remove("main-ui-hide");e.classList.add("main-ui-show")})}else{t.fulfill()}return t}function a(e){var t=new BX.Promise;if(!!e&&e.dataset.isShown==="true"){var i=function(n){if(n.animationName==="hideMainLoader"){e.style.display="none";e.removeEventListener("animationend",i);e.removeEventListener("oAnimationEnd",i);e.removeEventListener("webkitAnimationEnd",i);t.fulfill(n)}};e.addEventListener("animationend",i);e.addEventListener("oAnimationEnd",i);e.addEventListener("webkitAnimationEnd",i);e.dataset.isShown=false;requestAnimationFrame(function(){e.classList.remove("main-ui-show");e.classList.add("main-ui-hide")})}else{t.fulfill()}return t}function o(e,t){var i={};var n={};if(typeof t.target==="object"&&!!t.target){e.target=t.target}if(typeof t.size==="number"){i["width"]=t.size+"px";i["height"]=t.size+"px"}if(typeof t.color==="string"){n["stroke"]=t.color}if(typeof t.offset==="object"&&!!t.offset){if(typeof t.offset.top==="string"){i[t.mode==="inline"||t.mode==="custom"?"top":"margin-top"]=t.offset.top}if(typeof t.offset.left==="string"){i[t.mode==="inline"||t.mode==="custom"?"left":"margin-left"]=t.offset.left}}if(t.mode==="inline"){e.layout.classList.add("main-ui-loader-inline")}else{e.layout.classList.remove("main-ui-loader-inline")}if(t.mode==="custom"){e.layout.classList.add("main-ui-loader-custom");e.layout.classList.remove("main-ui-loader-inline")}requestAnimationFrame(function(){for(var t in i){if(i.hasOwnProperty(t)){e.layout.style[t]=i[t]}}for(var a in n){if(n.hasOwnProperty(a)){e.circle.style[a]=n[a]}}})}BX.Loader=function(t){this.state=e;this.layout=this.createLayout();this.circle=this.layout.querySelector(".main-ui-loader-svg-circle");this.target=null;o(this,BX.type.isPlainObject(t)?t:{})};BX.Loader.prototype={createLayout:function(){var e=""+'<div class="main-ui-loader">'+'<svg class="main-ui-loader-svg" viewBox="25 25 50 50">'+'<circle class="main-ui-loader-svg-circle" cx="50" cy="50" r="20" fill="none" stroke-miterlimit="10"/>'+"</svg>"+"</div>";return BX.create("div",{html:e}).firstElementChild},show:function(e){var i=new BX.Promise;i.setAutoResolve();e=!!e?e:this.target;if(!!e&&e!==this.layout.parentNode){e.appendChild(this.layout)}if(this.state!==t){this.state=t;i=n(this.layout)}return i},hide:function(){var e=new BX.Promise;e.setAutoResolve();if(this.state!==i){this.state=i;e=a(this.layout)}return e},isShown:function(){return this.state===t},setOptions:function(e){o(this,e)},destroy:function(){BX.remove(this.layout)}}})();