{"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","config","prototype","module","exports","selector","configuration","instance","Object","create","element","document","querySelector","init","scrollToTop","intervalId","setInterval","window","pageYOffset","clearInterval","scroll","this","step","interval","checkScroll","scrollY","scrollToShow","classList","remove","add","events","addEventListener","bindEvents","bind","component"],"mappings":";iFAKA,MAAM,aAAEA,GAAiB,EAAQ,QAC3BC,EAAS,EAAQ,QACjBC,EAAY,EAAQ,QAM1BC,EAAOC,QAAU,SAAmBC,EAAW,+BAAgCC,EAAgB,IAC3F,GAAIN,EAAaK,GAAW,CAExB,MAAME,EAAWC,OAAOC,OAAOP,GAS/B,OAPAK,EAASG,QAAUC,SAASC,cAAc,gCAE1CL,EAASN,OAAS,IAAKA,OAAaK,GAGhCC,EAASN,OAAOY,MAAMN,EAASM,OAE5BN,K,mBCtBf,MAAML,EAAY,CACdY,YAAa,WACT,IAAIC,EAAa,EAEjBA,EAAaC,YAAY,KACM,IAAvBC,OAAOC,aACPC,cAAcJ,GAElBE,OAAOG,OAAO,EAAGH,OAAOC,YAAcG,KAAKpB,OAAOqB,OACnDD,KAAKpB,OAAOsB,WAGnBC,YAAa,WACT,OAAIP,OAAOQ,SAAWJ,KAAKpB,OAAOyB,cAC9BL,KAAKX,QAAQiB,UAAUC,OAAO,aAC9BP,KAAKX,QAAQiB,UAAUE,IAAI,cAEpBR,OAEXA,KAAKX,QAAQiB,UAAUC,OAAO,cAC9BP,KAAKX,QAAQiB,UAAUE,IAAI,aAEpBR,OAGXS,OAAQ,WAIJ,OAHAT,KAAKX,QAAQqB,iBAAiB,QAASV,KAAKP,aAC5CG,OAAOc,iBAAiB,SAAUV,KAAKG,aAEhCH,MAGXW,WAAY,WAIR,OAHAX,KAAKP,YAAcO,KAAKP,YAAYmB,KAAKZ,MACzCA,KAAKG,YAAcH,KAAKG,YAAYS,KAAKZ,MAElCA,MAGXR,KAAM,WACFQ,KAAKW,aACLX,KAAKG,cACLH,KAAKS,WAIb3B,EAAOC,QAAUF,G,mBC7CjB,MAAMD,EAAS,CACXiC,UAAW,YACXrB,MAAM,EACNS,KAAM,GACNC,SAAU,GACVG,aAAc,KAGlBvB,EAAOC,QAAU,IAAMH","file":"top-button.cda53c65870815c89eef.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":""}