{"version":3,"sources":["webpack:///./node_modules/@bluekiri/alexandria-contrib-components/components/top-button/client/js/index.js","webpack:///./node_modules/@bluekiri/alexandria-contrib-components/components/top-button/client/js/prototype.js","webpack:///./node_modules/@bluekiri/alexandria-contrib-components/components/top-button/client/js/config.js"],"names":["elementExist","require","config","prototype","module","exports","selector","arguments","length","undefined","configuration","instance","Object","create","element","document","querySelector","_objectSpread","init","scrollToTop","_this","intervalId","setInterval","window","pageYOffset","clearInterval","scroll","step","this","interval","checkScroll","scrollY","scrollToShow","classList","remove","add","events","addEventListener","bindEvents","bind","component"],"mappings":";suBAKA,IAAQA,EAAiBC,EAAQ,QAAzBD,aACFE,EAASD,EAAQ,QACjBE,EAAYF,EAAQ,QAM1BG,EAAOC,QAAU,WAAkF,IAA/DC,EAAQC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,+BAAgCG,EAAaH,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,GAC3F,GAAIP,EAAaM,GAAW,CAExB,IAAMK,EAAWC,OAAOC,OAAOV,GAS/B,OAPAQ,EAASG,QAAUC,SAASC,cAAc,gCAE1CL,EAAST,OAAMe,IAAA,GAAQf,KAAaQ,GAGhCC,EAAST,OAAOgB,MAAMP,EAASO,OAE5BP,K,mBCtBf,IAAMR,EAAY,CACdgB,YAAa,WAAc,IAAAC,EAAA,KACnBC,EAAa,EAEjBA,EAAaC,aAAY,WACM,IAAvBC,OAAOC,aACPC,cAAcJ,GAElBE,OAAOG,OAAO,EAAGH,OAAOC,YAAcJ,EAAKlB,OAAOyB,QACnDC,KAAK1B,OAAO2B,WAGnBC,YAAa,WACT,OAAIP,OAAOQ,SAAWH,KAAK1B,OAAO8B,cAC9BJ,KAAKd,QAAQmB,UAAUC,OAAO,aAC9BN,KAAKd,QAAQmB,UAAUE,IAAI,cAEpBP,OAEXA,KAAKd,QAAQmB,UAAUC,OAAO,cAC9BN,KAAKd,QAAQmB,UAAUE,IAAI,aAEpBP,OAGXQ,OAAQ,WAIJ,OAHAR,KAAKd,QAAQuB,iBAAiB,QAAST,KAAKT,aAC5CI,OAAOc,iBAAiB,SAAUT,KAAKE,aAEhCF,MAGXU,WAAY,WAIR,OAHAV,KAAKT,YAAcS,KAAKT,YAAYoB,KAAKX,MACzCA,KAAKE,YAAcF,KAAKE,YAAYS,KAAKX,MAElCA,MAGXV,KAAM,WACFU,KAAKU,aACLV,KAAKE,cACLF,KAAKQ,WAIbhC,EAAOC,QAAUF,G,mBC7CjB,IAAMD,EAAS,CACXsC,UAAW,YACXtB,MAAM,EACNS,KAAM,GACNE,SAAU,GACVG,aAAc,KAGlB5B,EAAOC,QAAU,kBAAMH","file":"top-button.55148e96e721dfed5d07.bundle.js","sourcesContent":["/* ==========================================================================\n TopButton > Client\n ========================================================================== */\n\n/* Import modules */\nconst { elementExist } = require('@bluekiri/alexandria/helpers/domHelpers');\nconst config = require('./config');\nconst prototype = require('./prototype');\n\n/**\n * TopButton component\n * @param {selector} String selector for the component in the client side.\n */\nmodule.exports = function TopButton(selector = '[data-component=\"TopButton\"]', configuration = {}) {\n if (elementExist(selector)) {\n // Instance reference\n const instance = Object.create(prototype);\n\n instance.element = document.querySelector('[data-component=\"TopButton\"]');\n\n instance.config = { ...config(), ...configuration };\n\n /* Auto init */\n if (instance.config.init) instance.init();\n\n return instance;\n }\n};\n","/* ==========================================================================\n TopButton > Client > Prototype\n ========================================================================== */\nconst prototype = {\n scrollToTop: function Fn() {\n let intervalId = 0;\n\n intervalId = setInterval(() => {\n if (window.pageYOffset === 0) {\n clearInterval(intervalId);\n }\n window.scroll(0, window.pageYOffset - this.config.step);\n }, this.config.interval);\n },\n\n checkScroll: function Fn() {\n if (window.scrollY >= this.config.scrollToShow) {\n this.element.classList.remove('is-hidden');\n this.element.classList.add('is-visible');\n\n return this;\n }\n this.element.classList.remove('is-visible');\n this.element.classList.add('is-hidden');\n\n return this;\n },\n\n events: function Fn() {\n this.element.addEventListener('click', this.scrollToTop);\n window.addEventListener('scroll', this.checkScroll);\n\n return this;\n },\n\n bindEvents: function Fn() {\n this.scrollToTop = this.scrollToTop.bind(this);\n this.checkScroll = this.checkScroll.bind(this);\n\n return this;\n },\n\n init: function Fn() {\n this.bindEvents();\n this.checkScroll();\n this.events();\n }\n};\n\nmodule.exports = prototype;\n","/* ==========================================================================\n TopButton > Config\n ========================================================================== */\n\nconst config = {\n component: 'TopButton',\n init: true,\n step: 50,\n interval: 16,\n scrollToShow: 350\n};\n\nmodule.exports = () => config;\n"],"sourceRoot":""}