{"version":3,"sources":["webpack:///./src/js/services/LoaderService.js"],"names":["LoaderService","activeLoader","timeoutFunction","this","CUSTOM_MESSAGES","LOADER_EVENTS","show","appendLoader","hide","removeLoader","loader","message","container","querySelector","SELECTORS","dataUuid","getAttribute","push","elUuid","uuid","setAttribute","style","overflow","insertBefore","loaderElement","firstChild","e","console","error","icon","messageEl","appendMessage","setTimeout","classList","remove","parentElement","removeChild","length","pop","removeAttribute","loaderEl","document","createElement","add","innerHTML","innerText","messageElement","appendChild","BaseService"],"mappings":"gQAGqBA,E,YAenB,aAAc,0BACZ,+BAEKC,aAAe,GACpB,EAAKC,gBAAkB,GAJX,E,sDAdC,MACb,kBACGC,KAAKC,gBAAgBC,cAAcC,KAAOH,KAAKI,cADlD,MAEGJ,KAAKC,gBAAgBC,cAAcG,KAAOL,KAAKM,cAFlD,K,iCAOA,MAAO,CACLC,OAAQ,aACRC,QAAS,mB,6CAgDwB,IAAtBC,EAAsB,EAAtBA,UAAWD,EAAW,EAAXA,QACxB,IACE,IAAMV,EAAeW,EAAUC,cAAcb,EAAcc,UAAUJ,QAC/DK,EAAWH,EAAUI,aAAa,eAExC,GAAKD,EAKHZ,KAAKF,aAAac,GAAUE,KAAKL,OALpB,CACb,IAAMM,EAASC,MACfP,EAAUQ,aAAa,cAAeF,GACtCf,KAAKF,aAAaiB,GAAU,CAACN,GAK1BX,IACHW,EAAUS,MAAMC,SAAW,SAC3BV,EAAUQ,aAAa,WAAY,YACnCR,EAAUW,aAAavB,EAAcwB,cAAcb,GAAUC,EAAUa,aAEzE,MAAOC,GACPC,QAAQC,MAAMF,M,sCAoBf,IADDd,EACC,EADDA,UAAWD,EACV,EADUA,QAASkB,EACnB,EADmBA,KAAMD,EACzB,EADyBA,MAE1B,IACE,IAAMb,EAAWH,EAAUI,aAAa,eAClCf,EAAeW,EAAUC,cAAcb,EAAcc,UAAUJ,QAErE,GAAIC,EAAS,CACX,IAAMmB,EAAY9B,EAAc+B,cAAcpB,EAASC,EAAWiB,EAAMD,GACxEI,YAAW,WACTF,EAAUG,UAAUC,OAAO,aAC1B,MACHF,YAAW,WACTF,EAAUK,cAAcC,YAAYN,KACnC,MAGD3B,KAAKF,aAAac,IAAaZ,KAAKF,aAAac,GAAUsB,SAC7DlC,KAAKF,aAAac,GAAUuB,MACe,IAAvCnC,KAAKF,aAAac,GAAUsB,eAAqBlC,KAAKF,aAAac,IAGrEd,IAAiBE,KAAKF,aAAac,KACrCH,EAAU2B,gBAAgB,eAC1B3B,EAAU2B,gBAAgB,YAC1B3B,EAAUS,MAAMC,SAAW,GAC3BrB,EAAakC,cAAcC,YAAYnC,IAEzC,MAAOyB,GACPC,QAAQC,MAAMF,O,qCAnGGf,GACnB,IAAM6B,EAAWC,SAASC,cAAc,OAMxC,OAJAF,EAASP,UAAUU,IAAI,SAAU,aACjCH,EAASI,UAFI,8EAGTjC,GAASX,EAAc+B,cAAcpB,EAAS6B,GAE3CA,I,qCAWa7B,GAA6C,IAApCkB,EAAoC,uDAA7B,aAAcD,EAAe,wDAC3DE,EAAYW,SAASC,cAAc,OAOzC,OANAZ,EAAUG,UAAUU,IAAI,UAAW,cAC/Bd,GAAMC,EAAUG,UAAUU,IAAIf,EAAQ,aAAeC,GACrDD,GAAOE,EAAUG,UAAUU,IAAI,SAC9Bf,GAAOE,EAAUG,UAAUU,IAAI,WACpCb,EAAUe,UAAYlC,EAEfmB,I,oCA8BYnB,EAASC,EAAWiB,EAAMD,GAC7C,IAAME,EAAY9B,EAAc8C,eAAenC,EAASkB,EAAMD,GAG9D,OAFAhB,EAAUmC,YAAYjB,GACtBA,EAAUG,UAAUU,IAAI,WACjBb,M,SAtFgCkB","file":"js/service-loader.chunks.js","sourcesContent":["import uuid from 'uuid/v1';\nimport BaseService from '../abstracts/BaseService';\n\nexport default class LoaderService extends BaseService {\n get Messages() {\n return {\n [this.CUSTOM_MESSAGES.LOADER_EVENTS.show]: this.appendLoader,\n [this.CUSTOM_MESSAGES.LOADER_EVENTS.hide]: this.removeLoader\n };\n }\n\n static get SELECTORS() {\n return {\n loader: '.js-loader',\n message: '.js-message'\n };\n }\n\n constructor() {\n super();\n\n this.activeLoader = {};\n this.timeoutFunction = {};\n }\n\n /**\n *\n * @param {String} [message]\n */\n static loaderElement(message) {\n const loaderEl = document.createElement('div');\n const dots = '';\n loaderEl.classList.add('loader', 'js-loader');\n loaderEl.innerHTML = dots;\n if (message) LoaderService.appendMessage(message, loaderEl);\n\n return loaderEl;\n }\n\n /**\n *\n * @param {String} message\n * @param {String} [icon=icon-check]\n * @param {Boolean} [error=false]\n *\n * @returns {Element}\n */\n static messageElement(message, icon = 'icon-check', error = false) {\n const messageEl = document.createElement('div');\n messageEl.classList.add('message', 'js-message');\n if (icon) messageEl.classList.add(error ? 'icon-alert' : icon);\n if (error) messageEl.classList.add('error');\n if (!error) messageEl.classList.add('success');\n messageEl.innerText = message;\n\n return messageEl;\n }\n\n /**\n *\n * @param {HTMLElement} [container]\n */\n appendLoader({ container, message }) {\n try {\n const activeLoader = container.querySelector(LoaderService.SELECTORS.loader);\n const dataUuid = container.getAttribute('data-loader');\n\n if (!dataUuid) {\n const elUuid = uuid();\n container.setAttribute('data-loader', elUuid);\n this.activeLoader[elUuid] = [container];\n } else {\n this.activeLoader[dataUuid].push(container);\n }\n\n if (!activeLoader) {\n container.style.overflow = 'hidden';\n container.setAttribute('disabled', 'disabled');\n container.insertBefore(LoaderService.loaderElement(message), container.firstChild);\n }\n } catch (e) {\n console.error(e);\n }\n }\n\n static appendMessage(message, container, icon, error) {\n const messageEl = LoaderService.messageElement(message, icon, error);\n container.appendChild(messageEl);\n messageEl.classList.add('visible');\n return messageEl;\n }\n\n /**\n *\n * @param {HTMLElement} [container]\n * @param {String} [message]\n * @param {String} [icon]\n * @param {Boolean} [error]\n */\n removeLoader({\n container, message, icon, error\n }) {\n try {\n const dataUuid = container.getAttribute('data-loader');\n const activeLoader = container.querySelector(LoaderService.SELECTORS.loader);\n\n if (message) {\n const messageEl = LoaderService.appendMessage(message, container, icon, error);\n setTimeout(() => {\n messageEl.classList.remove('visible');\n }, 1500);\n setTimeout(() => {\n messageEl.parentElement.removeChild(messageEl);\n }, 2500);\n }\n\n if (this.activeLoader[dataUuid] && this.activeLoader[dataUuid].length) {\n this.activeLoader[dataUuid].pop();\n if (this.activeLoader[dataUuid].length === 0) delete this.activeLoader[dataUuid];\n }\n\n if (activeLoader && !this.activeLoader[dataUuid]) {\n container.removeAttribute('data-loader');\n container.removeAttribute('disabled');\n container.style.overflow = '';\n activeLoader.parentElement.removeChild(activeLoader);\n }\n } catch (e) {\n console.error(e);\n }\n }\n}\n"],"sourceRoot":""}