{"version":3,"file":"js/129-9d046bae37f04e641c29.chunk.js","mappings":"mHAWuBA,SAASC,iBAAiB,iBAGlCC,SAASC,IAEtB,MAAMC,EAASD,EAAGE,aAAa,eAEzBC,EAA4B,aAAXF,GAAoC,YAAXA,EAE1CG,EAAOJ,aAAcK,kBAAoBL,EAAKA,EAAGM,cAAc,KAGrEF,EAAKG,iBAAiB,SAAUC,IAE9B,GAAIL,EAAgB,CAElBK,EAAMC,iBAGN,MAAMC,EAAMN,EAAKF,aAAa,QAExBS,EAAMC,OAAOC,SAAWD,OAAOE,YAxB5B,KAwBoD,EAEvDC,EAAOH,OAAOI,SAAWJ,OAAOK,WA3B9B,KA2BoD,EAEtDC,EAAQN,OAAOO,KACnBT,EACA,SACA,4BAAuCC,UAAYI,KAIjDG,IACFA,EAAME,QACNF,EAAMG,OAAS,KAEnB,EAGA,QAAW,QAAS,CAClBC,OAAQrB,EACRsB,aAAc,UACdC,QAASZ,OAAOa,SAASC,MACzB,GACF,G","sources":["webpack://endrun/./app/javascript/app/analytics/sharetools.js"],"sourcesContent":["// packages\nimport debounce from 'underscore/modules/debounce.js';\n\n// local\nimport { trackEvent } from './helpers.js';\n\n// default sizes for now\nconst width = 570;\nconst height = 570;\n\n// all of the share buttons on a given page\nconst shareButtonEls = document.querySelectorAll('.share-button');\n\n// set up each share button\nshareButtonEls.forEach((el) => {\n // find its action...\n const action = el.getAttribute('data-action');\n // ...and preemptively determine if it's a popup or not...\n const shouldUsePopup = action === 'facebook' || action === 'twitter';\n // ...then finally get the element itself\n const link = el instanceof HTMLAnchorElement ? el : el.querySelector('a');\n\n // react to clicks on the share button\n link.addEventListener('click', (event) => {\n // if it's twitter or facebook, we use a popup\n if (shouldUsePopup) {\n // don't let links be links\n event.preventDefault();\n\n // grab our URL\n const url = link.getAttribute('href');\n // determine the top edge of the popup\n const top = window.screenY + (window.outerHeight - height) / 2;\n // determine the left edge of the popup\n const left = window.screenX + (window.outerWidth - width) / 2;\n // pop it open with those parameters\n const popup = window.open(\n url,\n '_blank',\n `width=${width},height=${height},top=${top},left=${left}`\n );\n\n // if it succeeds, focus on it\n if (popup) {\n popup.focus();\n popup.opener = null;\n }\n }\n\n // See https://developers.google.com/analytics/devguides/collection/ga4/reference/events?sjid=8256709344012883295-NA&client_type=gtag#share\n trackEvent('share', {\n method: action,\n content_type: 'article',\n item_id: window.location.href,\n });\n });\n});\n"],"names":["document","querySelectorAll","forEach","el","action","getAttribute","shouldUsePopup","link","HTMLAnchorElement","querySelector","addEventListener","event","preventDefault","url","top","window","screenY","outerHeight","left","screenX","outerWidth","popup","open","focus","opener","method","content_type","item_id","location","href"],"sourceRoot":""}