{"version":3,"sources":["webpack:///./src/js/modules/LeavingPopup.js"],"names":["_core","__webpack_require__","LeavingPopup","el","_classCallCheck","this","_possibleConstructorReturn","__proto__","Object","getPrototypeOf","call","Component","dom","$modal","$el","$closeButton","find","$linkButton","$linkUrl","$anchors","$","body","document","getElementsByTagName","removeActiveState","setupIcons","anchor","dataset","dontOpenPopup","hostname","window","location","anchors","_this2","each","_","isAnchorExternal","classList","add","_this3","on","e","closePopup","openPopup","param","addEventListener","dynamicAnchors","text","attr","target","href","currentTarget","url","getAttribute","Boolean","ONEWORLD_LEAVING_WHITELIST","whiteListURL","toLowerCase","toLocaleLowerCase","cleanAttrs","preventDefault","style","overflow","addClass","removeClass","remove","removeAttribute"],"mappings":"kZAAAA,EAAAC,EAAA,QAEMC,cACJ,SAAAA,EAAYC,GAAI,mGAAAC,CAAAC,KAAAH,oKAAAI,CAAAD,MAAAH,EAAAK,WAAAC,OAAAC,eAAAP,IAAAQ,KAAAL,KACRF,uUAFiBQ,wDAMvBN,KAAKO,KACHC,OAAQR,KAAKS,IACbC,aAAcV,KAAKS,IAAIE,KAAK,sCAC5BC,YAAaZ,KAAKS,IAAIE,KAAK,qCAC3BE,SAAUb,KAAKS,IAAIE,KAAK,kCACxBG,SAAUC,EAAE,4CACZC,KAAMC,SAASC,qBAAqB,QAAQ,IAE9ClB,KAAKmB,oBACLnB,KAAKoB,WAAWpB,KAAKO,IAAIO,mDAGVO,GAEf,QADsBA,EAAOC,QAAQC,eAGnCF,EAAOG,WAAaC,OAAOC,SAASF,UAChB,qBAApBH,EAAOG,UACa,yBAApBH,EAAOG,UACa,yBAApBH,EAAOG,6CAIAG,GAAS,IAAAC,EAAA5B,KAClB2B,EAAQE,KAAK,SAACC,EAAGT,GACXO,EAAKG,iBAAiBV,IACxBA,EAAOW,UAAUC,IAAI,iEAKZ,IAAAC,EAAAlC,KACbA,KAAKO,IAAIG,aAAayB,GAAG,QAAS,SAAAC,GAAA,OAAKF,EAAKG,WAAWD,KACvDpC,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,OAAOmD,YAAY,UAC5B3D,KAAKO,IAAIS,KAAK6C,gBAAgB,SAC9B7D,KAAKO,IAAIS,KAAKgB,UAAU4B,OAAO,2CAIpB/D","file":"24.d96769d3ab3f6789dacc.bundle.js","sourcesContent":["import { Component } from '@verndale/core';\n\nclass LeavingPopup extends Component {\n constructor(el) {\n super(el);\n }\n\n setupDefaults() {\n this.dom = {\n $modal: this.$el,\n $closeButton: this.$el.find('.leaving-popup__card__close-button'),\n $linkButton: this.$el.find('.leaving-popup__card__link-button'),\n $linkUrl: this.$el.find('.leaving-popup__card__link-url'),\n $anchors: $('a:not(.leaving-popup__card__link-button)'),\n body: document.getElementsByTagName('body')[0]\n };\n this.removeActiveState();\n this.setupIcons(this.dom.$anchors);\n }\n\n isAnchorExternal(anchor) {\n const dontOpenPopup = anchor.dataset.dontOpenPopup;\n return !(\n dontOpenPopup ||\n anchor.hostname === window.location.hostname ||\n anchor.hostname === 'rtw.oneworld.com' ||\n anchor.hostname === 'assets.ctfassets.net' ||\n anchor.hostname === 'flights.oneworld.com'\n );\n }\n\n setupIcons(anchors) {\n anchors.each((_, anchor) => {\n if (this.isAnchorExternal(anchor)) {\n anchor.classList.add('external-anchor-icon');\n }\n });\n }\n\n addListeners() {\n this.dom.$closeButton.on('click', e => this.closePopup(e));\n this.dom.$anchors.on('click', e => this.openPopup(e));\n this.dom.$linkButton.on('click', e => this.closePopup(e));\n this.$el.on('trigger:open', (e, param) => this.openPopup(param));\n window.addEventListener('links-watch', () => {\n const dynamicAnchors = $('a:not(.leaving-popup__card__link-button)');\n dynamicAnchors.on('click', e => this.openPopup(e));\n this.setupIcons(dynamicAnchors);\n });\n }\n\n cleanAttrs() {\n this.dom.$linkUrl.text('');\n this.dom.$linkButton.attr({ target: '', href: '' });\n }\n\n openPopup(e) {\n const anchor = e.currentTarget;\n if (!this.isAnchorExternal(anchor)) return;\n const url = anchor.getAttribute('href');\n const existOnWhiteList = Boolean(\n window.ONEWORLD_LEAVING_WHITELIST.find(\n whiteListURL => whiteListURL.toLowerCase() === url.toLocaleLowerCase()\n )\n );\n if (existOnWhiteList) return;\n this.cleanAttrs();\n e.preventDefault();\n if (!url) return;\n this.dom.body.style.overflow = 'hidden';\n this.dom.body.classList.add('leaving-popup-active');\n const target = anchor.getAttribute('target');\n this.dom.$linkUrl.text(url);\n this.dom.$linkButton.attr({ target, href: url });\n this.dom.$modal.addClass('active');\n }\n\n closePopup(e) {\n e.preventDefault();\n const target = e.currentTarget;\n const href = target.getAttribute('href');\n this.dom.$modal.removeClass('active');\n this.dom.body.style.overflow = 'visible';\n this.dom.body.classList.remove('leaving-popup-active');\n if (href) {\n window.location.href = href;\n }\n }\n removeActiveState(){\n this.dom.$modal.removeClass('active');\n this.dom.body.removeAttribute('style');\n this.dom.body.classList.remove('leaving-popup-active');\n }\n}\n\nexport default LeavingPopup;\n"],"sourceRoot":""}