{"version":3,"sources":["webpack:///./widgets/welcomeBannerModal.js"],"names":["CLS","REGION_STORAGE_NAME","concat","WelcomeBannerModal","el","_classCallCheck","this","$el","$","onModalOpen","checkLocalStorage","checkHash","handleLink","key","value","region","localStorage","getItem","JSON","parse","currentUrl","window","location","href","baseAddress","data","pathName","replace","link","newUrl","modal","find","on","e","$link","target","hasClass","parent","param","code","attr","name","text","setItem","stringify","urlHashString","hash","urlHash","substr","indexOf","$modal","length","css"],"mappings":"s2BAEA,IACMA,EAAM,qBACNC,EAAsB,OAAHC,OAAUF,EAAG,WAEzBG,EAAkB,WAS7B,O,EARD,SAAAA,EAAYC,I,4FAAIC,CAAA,KAAAF,GACfG,KAAKF,GAAKA,EACVE,KAAKC,IAAMC,EAAEJ,GAEbE,KAAKG,cACLH,KAAKI,oBACLJ,KAAKK,YACLL,KAAKM,e,EACL,EAAAC,IAAA,oBAAAC,MAED,WACC,IAAIC,EAASC,aAAaC,QAAQhB,GAGlC,GAAKc,EAEE,CAGNA,EAASG,KAAKC,MAAMJ,GACpB,IAAIK,EAAaC,OAAOC,SAASC,KAC7BC,EAAclB,KAAKC,IAAIkB,KAAK,eAC5BC,EAAWN,EAAWO,QAAQH,EAAa,IAC/C,GAAIA,IAAgBT,EAAOa,KAAM,CAChC,IAAIC,EAAS,GAAH3B,OAAMa,EAAOa,MAAI1B,OAAGwB,GAC9BL,OAAOC,SAASC,KAAOM,QAVxBvB,KAAKC,IAAIuB,MAAM,UAahB,CAAAjB,IAAA,aAAAC,MAED,WACCR,KAAKC,IAAIwB,KAAK,IAAD7B,OAAKF,EAAG,UAASgC,GAAG,SAAS,SAACC,GAC1C,IAAIC,EAAQ1B,EAAEyB,EAAEE,QAEXD,EAAME,SAAS,GAADlC,OAAIF,EAAG,YACzBkC,EAAQA,EAAMG,OAAO,IAADnC,OAAKF,EAAG,WAG7B,IAAIsC,EAAQ,CACXC,KAAML,EAAMT,KAAK,QACjBG,KAAMM,EAAMM,KAAK,QACjBC,KAAMP,EAAMH,KAAK,IAAD7B,OAAKF,EAAG,iBAAgB0C,QAGzCrB,OAAOL,aAAa2B,QAAQ1C,EAAqBiB,KAAK0B,UAAUN,SAIlE,CAAAzB,IAAA,YAAAC,MACA,WACC,IAAI+B,EAAgBxB,OAAOC,SAASwB,KAChCC,EAAWF,EAAcG,OAAO,GAAIH,EAAgB,KAAKI,QAAQ,MACrE,GAAKF,EAAL,CAEA,IAAIG,EAAS1C,EAAEuC,GACO,IAAlBG,EAAOC,QAAgBD,EAAOd,SAAS,UAC1Cc,EAAOpB,MAAM,WAEd,CAAAjB,IAAA,cAAAC,MAED,WACCR,KAAKC,IAAIyB,GAAG,iBAAiB,WAC5BxB,EAAE,QAAQ4C,IAAI,YAAa,kB,0FA/DC,I","file":"87.js","sourcesContent":["/* eslint-disable max-len */\n// CONSTANTS are all caps.\nconst NS = 'WelcomeBannerModal';\nconst CLS = 'welcomeBannerModal';\nconst REGION_STORAGE_NAME = `awi.${CLS}.region`;\n\nexport class WelcomeBannerModal {\n\tconstructor(el) {\n\t\tthis.el = el;\n\t\tthis.$el = $(el);\n\n\t\tthis.onModalOpen();\n\t\tthis.checkLocalStorage();\n\t\tthis.checkHash();\n\t\tthis.handleLink();\n\t}\n\n\tcheckLocalStorage() {\n\t\tlet region = localStorage.getItem(REGION_STORAGE_NAME);\n\n\t\t// if there is local storage doesn't have value, it will trigger modal\n\t\tif (!region) {\n\t\t\tthis.$el.modal('show');\n\t\t} else {\n\t\t\t// compare the saved \"link\" from local storage to the current url\n\t\t\t// if not match, it will redirect (modify the url using from the saved one)\n\t\t\tregion = JSON.parse(region);\n\t\t\tlet currentUrl = window.location.href;\n\t\t\tlet baseAddress = this.$el.data('baseaddress');\n\t\t\tlet pathName = currentUrl.replace(baseAddress, '');\n\t\t\tif (baseAddress !== region.link) {\n\t\t\t\tlet newUrl = `${region.link}${pathName}`;\n\t\t\t\twindow.location.href = newUrl;\n\t\t\t}\n\t\t}\n\t}\n\n\thandleLink() {\n\t\tthis.$el.find(`.${CLS}-link`).on('click', (e) => {\n\t\t\tlet $link = $(e.target);\n\n\t\t\tif (!$link.hasClass(`${CLS}-link`)) {\n\t\t\t\t$link = $link.parent(`.${CLS}-link`);\n\t\t\t}\n\n\t\t\tlet param = {\n\t\t\t\tcode: $link.data('code'),\n\t\t\t\tlink: $link.attr('href'),\n\t\t\t\tname: $link.find(`.${CLS}-countryName`).text(),\n\t\t\t};\n\n\t\t\twindow.localStorage.setItem(REGION_STORAGE_NAME, JSON.stringify(param));\n\t\t});\n\t}\n\n\t// trigger modal using hash on url, eg: wool4school.com#welcomeBannerModal\n\tcheckHash() {\n\t\tlet urlHashString = window.location.hash;\n\t\tlet urlHash = (urlHashString.substr(0, (urlHashString + '?').indexOf('?')));\n\t\tif (!urlHash) return;\n\n\t\tlet $modal = $(urlHash);\n\t\tif ($modal.length !== 0 && $modal.hasClass('modal')) {\n\t\t\t$modal.modal('show');\n\t\t}\n\t}\n\n\tonModalOpen() {\n\t\tthis.$el.on('show.bs.modal', () => {\n\t\t\t$('html').css('overflowY', 'hidden');\n\t\t});\n\t}\n}\n"],"sourceRoot":""}