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AY0C,W,gFAlEPlC,G","sources":["webpack://jcb-golf/./src/js/components/globals.js","webpack://jcb-golf/./src/js/components/membership.js"],"sourcesContent":["const ScrollWatcher = require(\"scroll-watcher\");\r\nconst inViewport = require('in-viewport');\r\n\r\n\r\nexport function watchScroll(el, onEnterCallback, onExitCallback, offset) {\r\n const y = window.scrollY,\r\n elY = el.offsetTop,\r\n scroll = new ScrollWatcher(),\r\n that = this;\r\n\r\n let offsetAmount = offset || false;\r\n\r\n if (!inViewport(el)) {\r\n this.addUnseenClass(el);\r\n }\r\n\r\n if (!offsetAmount) {\r\n const dummy = document.createElement(\"div\");\r\n dummy.style.height = \"50vh\";\r\n dummy.style.width = \"0\";\r\n dummy.style.position = \"fixed\";\r\n dummy.style.top = \"0\";\r\n dummy.style.left = \"100%\"\r\n document.body.appendChild(dummy);\r\n const h = dummy.offsetHeight;\r\n document.body.removeChild(dummy);\r\n console.log(\"Offset height of\", h, \"px set for: \", el);\r\n offsetAmount = h;\r\n } else {\r\n console.log(\"Offset height of\", offsetAmount, \"px already set for: \", el);\r\n }\r\n\r\n scroll.watch(el, offsetAmount)\r\n .on(\"enter\", () => {\r\n that.unhide(el);\r\n if (onEnterCallback) {\r\n onEnterCallback()\r\n }\r\n })\r\n .on(\"exit\", () => {\r\n if (onExitCallback) {\r\n onExitCallback()\r\n }\r\n });\r\n\r\n}\r\n\r\nexport function addUnseenClass(el) {\r\n el.classList.add(\"unseen\");\r\n}\r\n\r\nexport function unhide(el) {\r\n el.classList.remove(\"unseen\");\r\n}\r\n\r\nexport function setNav(sectionId) {\r\n const nav = document.querySelector(\"header nav\"),\r\n currentActive = nav.querySelector(\".active\"),\r\n targetActive = nav.querySelector(\"[href='\"+sectionId+\"']\");\r\n\r\n if (currentActive) {\r\n currentActive.classList.remove(\"active\");\r\n }\r\n targetActive.classList.add(\"active\");\r\n}\r\n\r\nexport function unsetNav(el, sectionId) {\r\n const y = window.scrollY,\r\n elY = el.offsetTop,\r\n nav = document.querySelector(\"header nav\"),\r\n currentActive = nav.querySelector(\".active\"),\r\n targetActive = nav.querySelector(\"[href='\"+sectionId+\"']\");\r\n\r\n if(y < elY) {\r\n currentActive.classList.remove(\"active\");\r\n targetActive.classList.add(\"active\");\r\n }\r\n}","import * as globals from './globals.js';\r\n\r\nexport default class Membership {\r\n constructor(el) {\r\n this.el = el;\r\n this.init();\r\n }\r\n\r\n init() {\r\n if (this.el.querySelector('.form-component-outer')) {\r\n this.attachEvents();\r\n }\r\n this.initSelectBoxes();\r\n\r\n $('select').on('click', function (event) {\r\n event.stopPropagation();\r\n });\r\n }\r\n\r\n attachEvents() {\r\n const showFormButton = this.el.querySelector('button.show-form'),\r\n innerContent = this.el.querySelector('.inner-content'),\r\n thankyouContent = this.el.querySelector('.thankyou-content'),\r\n formWrapper = this.el.querySelector('.form-component-outer'),\r\n form = formWrapper.querySelector('form'),\r\n formAction = form.getAttribute('action'),\r\n that = this;\r\n\r\n showFormButton.addEventListener('click', (event) => {\r\n innerContent.classList.add('hide');\r\n formWrapper.classList.add('show');\r\n });\r\n\r\n form.addEventListener('submit', (event) => {\r\n event.preventDefault();\r\n const formContent = new FormData(form),\r\n fetchOptions = {\r\n method: 'POST',\r\n mode: 'same-origin',\r\n credentials: 'include',\r\n body: formContent,\r\n };\r\n\r\n if ($(form).valid()) {\r\n fetch(formAction, fetchOptions)\r\n .then((response) => {\r\n formWrapper.classList.remove('show');\r\n thankyouContent.classList.add('show');\r\n thankyouContent.focus();\r\n })\r\n .catch((error) => {\r\n console.error('Error submitting form:', error);\r\n });\r\n } else {\r\n console.warn('Form not valid!');\r\n }\r\n });\r\n }\r\n\r\n initSelectBoxes() {\r\n const selectBoxes = Array.prototype.slice.call(this.el.querySelectorAll('select'));\r\n\r\n selectBoxes.forEach((select) => {\r\n const parentEl = select.parentNode;\r\n let wrapperEl = document.createElement('div');\r\n wrapperEl.classList.add('select-wrapper');\r\n wrapperEl.innerHTML = ``;\r\n parentEl.insertBefore(wrapperEl, select);\r\n wrapperEl.appendChild(select);\r\n });\r\n }\r\n}\r\n"],"names":["el","classList","add","sectionId","nav","document","querySelector","currentActive","targetActive","remove","y","window","scrollY","elY","offsetTop","onEnterCallback","onExitCallback","offset","scroll","ScrollWatcher","that","this","offsetAmount","inViewport","addUnseenClass","console","log","dummy","createElement","style","height","width","position","top","left","body","appendChild","h","offsetHeight","removeChild","watch","on","unhide","require","Membership","init","attachEvents","initSelectBoxes","$","event","stopPropagation","showFormButton","innerContent","thankyouContent","formWrapper","form","formAction","getAttribute","addEventListener","preventDefault","fetchOptions","method","mode","credentials","FormData","valid","fetch","then","response","focus","error","warn","Array","prototype","slice","call","querySelectorAll","forEach","select","parentEl","parentNode","wrapperEl","innerHTML","insertBefore"],"sourceRoot":""}