{"version":3,"file":"SocialShare.js","names":["SocialShare","parentEl","targetEl","listCtrlEl","wrapperEl","isListOpen","deactivateFocusTrap","initEventListeners","e","type","which","preventDefault","stopPropagation","list","document","querySelector","button","classList","remove","self","add","el","activateFocusTrap","onListToggle","target","isTarget","toString","search","nodeName","toLowerCase","href","test","url","trim","replace","config","width","height","openPopUpWindow","addEventListener","openWindow","bind","closePopup","init"],"sources":["components/SocialShare.js"],"sourcesContent":["import { openPopUpWindow } from './PopUpWindow';\r\nimport activateFocusTrap from '../utils/focusTrap';\r\n\r\nexport class SocialShare {\r\n\r\n //Requesting parent element and target element to allow for event delegation\r\n constructor(parentEl = '.ar-social-share', targetEl = 'a', listCtrlEl = null, wrapperEl = null) {\r\n this.parentEl = parentEl;\r\n this.targetEl = targetEl;\r\n this.listCtrlEl = listCtrlEl;\r\n this.wrapperEl = wrapperEl;\r\n this.isListOpen = false;\r\n this.deactivateFocusTrap = null;\r\n this.initEventListeners();\r\n }\r\n\r\n onListToggle(e) {\r\n if (e.type === 'click' || (e.type === 'keydown' && e.which === 13)) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n const list = document.querySelector(this.parentEl);\r\n const button = document.querySelector(this.listCtrlEl);\r\n if (this.isListOpen) {\r\n list.classList.remove(\"open\");\r\n button.classList.remove(\"close\");\r\n if(self.deactivateFocusTrap){\r\n self.deactivateFocusTrap();\r\n }\r\n } else {\r\n list.classList.add(\"open\");\r\n button.classList.add(\"close\");\r\n const el = document.querySelector(this.wrapperEl);\r\n self.deactivateFocusTrap = activateFocusTrap(el); \r\n }\r\n this.isListOpen = !this.isListOpen;\r\n }\r\n }\r\n\r\n closePopup(e) {\r\n if (this.isListOpen) {\r\n this.onListToggle(e);\r\n }\r\n }\r\n \r\n openWindow(e) {\r\n const target = e.target;\r\n const isTarget = (target.classList.toString().search(this.targetEl) > -1 || target.nodeName.toLowerCase() === this.targetEl);\r\n \r\n if(isTarget && target.href && /^http[s]*:\\/\\//.test(target.href)) {\r\n e.preventDefault();\r\n\r\n const url = target.href.trim().replace(/\\s+/g, '+'); //Some basic sanitization\r\n const config = {width: 500, height: 500};\r\n\r\n openPopUpWindow(url, config);\r\n }\r\n }\r\n\r\n initEventListeners() {\r\n document.querySelector(this.parentEl).addEventListener('click', this.openWindow.bind(this));\r\n if (this.listCtrlEl && this.wrapperEl) {\r\n const el = document.querySelector(this.listCtrlEl);\r\n el.addEventListener('keydown', this.onListToggle.bind(this));\r\n el.addEventListener('click', this.onListToggle.bind(this));\r\n document.addEventListener('click', this.closePopup.bind(this));\r\n }\r\n }\r\n}\r\n\r\nexport var init = (parentEl, targetEl, listCtrlEl, wrapperEl) => new SocialShare(parentEl, targetEl, listCtrlEl, wrapperEl);"],"mappings":";;;;;;AAAA;AACA;AAAmD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAEtCA,WAAW;EAEpB;EACA,uBAAgG;IAAA,IAApFC,QAAQ,uEAAG,kBAAkB;IAAA,IAAEC,QAAQ,uEAAG,GAAG;IAAA,IAAEC,UAAU,uEAAG,IAAI;IAAA,IAAEC,SAAS,uEAAG,IAAI;IAAA;IAC1F,IAAI,CAACH,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACC,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,UAAU,GAAG,KAAK;IACvB,IAAI,CAACC,mBAAmB,GAAG,IAAI;IAC/B,IAAI,CAACC,kBAAkB,EAAE;EAC7B;EAAC;IAAA;IAAA,OAEH,sBAAaC,CAAC,EAAE;MACd,IAAIA,CAAC,CAACC,IAAI,KAAK,OAAO,IAAKD,CAAC,CAACC,IAAI,KAAK,SAAS,IAAID,CAAC,CAACE,KAAK,KAAK,EAAG,EAAE;QAClEF,CAAC,CAACG,cAAc,EAAE;QAClBH,CAAC,CAACI,eAAe,EAAE;QACnB,IAAMC,IAAI,GAAGC,QAAQ,CA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