{"version":3,"file":"shareModule-DJhzHpDS.js","sources":["../../src/scripts/modules/shareModule.ts"],"sourcesContent":["import { Component } from '@verndale/core';\n\nclass ShareModule extends Component {\n url: string;\n\n constructor(el: HTMLElement) {\n super(el);\n this.url = window.location.href;\n }\n\n setupDefaults() {\n this.dom = {\n svgIcons: this.el.querySelectorAll<HTMLElement>('.share-module__icon-button svg'),\n options: this.el.querySelectorAll<HTMLElement>('[data-service]')\n };\n }\n\n addListeners() {\n (this.dom.options as NodeListOf<HTMLButtonElement>).forEach(option => {\n option.addEventListener('click', this.handleOptionClick.bind(this));\n });\n }\n\n handleOptionClick(e: Event) {\n const target = e.currentTarget as HTMLElement;\n const service = target.dataset.service;\n\n if (service) {\n this.share(service);\n }\n }\n\n share(service: string) {\n switch (service) {\n case 'facebook':\n this.openModal(`https://www.facebook.com/share.php?u=${this.url}`);\n break;\n case 'x':\n this.openModal(`https://twitter.com/share?url=${this.url}`);\n break;\n case 'linkedin':\n this.openModal(`https://www.linkedin.com/sharing/share-offsite/?url=${this.url}`);\n break;\n case 'mail':\n this.openModal(`mailto:?body=${window.location.href}`);\n break;\n case 'email':\n this.openModal(`mailto:?body=${window.location.href}`);\n break;\n default:\n break;\n }\n }\n\n openModal(url: string) {\n const winTop = window.innerHeight / 3 - 200;\n const winLeft = window.innerWidth / 2 - 300;\n\n window.open(\n url,\n 'sharer',\n `top=${winTop}, left=${winLeft}, width=600, height=400, scrollbars=no`\n );\n }\n}\n\nexport default ShareModule;\n"],"names":["ShareModule","Component","el","__publicField","option","service","url","winTop","winLeft"],"mappings":"iNAEA,MAAMA,UAAoBC,CAAU,CAGlC,YAAYC,EAAiB,CAC3B,MAAMA,CAAE,EAHVC,EAAA,YAIO,KAAA,IAAM,OAAO,SAAS,IAAA,CAG7B,eAAgB,CACd,KAAK,IAAM,CACT,SAAU,KAAK,GAAG,iBAA8B,gCAAgC,EAChF,QAAS,KAAK,GAAG,iBAA8B,gBAAgB,CACjE,CAAA,CAGF,cAAe,CACZ,KAAK,IAAI,QAA0C,QAAkBC,GAAA,CACpEA,EAAO,iBAAiB,QAAS,KAAK,kBAAkB,KAAK,IAAI,CAAC,CAAA,CACnE,CAAA,CAGH,kBAAkB,EAAU,CAEpB,MAAAC,EADS,EAAE,cACM,QAAQ,QAE3BA,GACF,KAAK,MAAMA,CAAO,CACpB,CAGF,MAAMA,EAAiB,CACrB,OAAQA,EAAS,CACf,IAAK,WACH,KAAK,UAAU,wCAAwC,KAAK,GAAG,EAAE,EACjE,MACF,IAAK,IACH,KAAK,UAAU,iCAAiC,KAAK,GAAG,EAAE,EAC1D,MACF,IAAK,WACH,KAAK,UAAU,uDAAuD,KAAK,GAAG,EAAE,EAChF,MACF,IAAK,OACH,KAAK,UAAU,gBAAgB,OAAO,SAAS,IAAI,EAAE,EACrD,MACF,IAAK,QACH,KAAK,UAAU,gBAAgB,OAAO,SAAS,IAAI,EAAE,EACrD,KAEA,CACJ,CAGF,UAAUC,EAAa,CACf,MAAAC,EAAS,OAAO,YAAc,EAAI,IAClCC,EAAU,OAAO,WAAa,EAAI,IAEjC,OAAA,KACLF,EACA,SACA,OAAOC,CAAM,UAAUC,CAAO,wCAChC,CAAA,CAEJ"}