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ACrD,CACF,CAnFAgC,QAAQC,IAAI,CAAC,uFAAuCC,MAAK,KACvD,IAAIC,EAIFA,EAFqBpC,EAAE,mBAAmB8B,OAEjC9B,EAAE,6BAEFA,EAAE,6BAGboC,EAAOC,MAAK,SAAUC,EAAG1C,GACvBI,EAAEJ,GAAI2C,KAAK,SAAU,IAAI5C,EAAkBC,EAAI0C,IAC/CtC,EAAEwC,UAAUC,OAAM,WAChBzC,EAAEJ,GAAI2C,KAAK,UAAUvB,MACvB,GACF,GAAE,G","sources":["webpack://disp0001/./src/widgets/announcement-pop-up/announcement-pop-up.js"],"sourcesContent":["import Cookies from 'js-cookie'\r\n\r\nPromise.all([import('./announcement-pop-up.scss')]).then(() => {\r\n let widget\r\n\r\n let isParkDetailPage = $('.pt-park-detail').length\r\n if (isParkDetailPage) {\r\n widget = $('.park.announcement-pop-up')\r\n } else {\r\n widget = $('.page.announcement-pop-up')\r\n }\r\n\r\n widget.each(function (i, el) {\r\n $(el).data('widget', new AnnouncementPopUp(el, i))\r\n $(document).ready(function () {\r\n $(el).data('widget').init()\r\n })\r\n })\r\n})\r\n\r\nfunction AnnouncementPopUp(el, index) {\r\n const self = this\r\n self.el = $(el)\r\n self.uid = `AnnouncementPopUp_${index}`\r\n self.modal = self.el.find('.ui.modal')\r\n self.modalId = self.el.find('.ui.modal .id').val()\r\n\r\n self.getAppearanceLimit = () => parseInt(self.modal.find('.frequency').val())\r\n\r\n self.hasReachedAppearanceLimit = function () {\r\n if (self.getAppearanceLimit() === -1) return false\r\n\r\n const appearanceCount = parseInt(Cookies.get(`${self.modalId}-AnnouncementPopUpAppearanceCount`))\r\n return appearanceCount >= self.getAppearanceLimit()\r\n }\r\n\r\n self.close = function () {\r\n let appearanceCount = parseInt(Cookies.get(`${self.modalId}-AnnouncementPopUpAppearanceCount`))\r\n appearanceCount > 0 ? appearanceCount++ : (appearanceCount = 1)\r\n\r\n Cookies.set(`${self.modalId}-AnnouncementPopUpAppearanceCount`, appearanceCount, {\r\n expires: 365, // in days\r\n path: '/',\r\n })\r\n\r\n self.modal.modal('hide')\r\n }\r\n\r\n self.init = function () {\r\n if (process.env.NODE_ENV === 'development') {\r\n console.log('AnnouncementPopUp init', self)\r\n }\r\n\r\n // Check if we should show the modal on page load\r\n if (self.hasReachedAppearanceLimit()) return\r\n\r\n // NOTE: The contents of the widget is moved in the DOM\r\n // outside the widget element to the bottom of the page.\r\n // As such, this just sets opacity on the widget element\r\n // which will be empty.\r\n // self.el.css('opacity', 1);\r\n\r\n window.dbs.globalEvents.subscribe('shepherdNext', function (item) {\r\n if (item !== self.uid) return\r\n console.log('[SHEPHERD][popup]', item === self.uid, item)\r\n\r\n self.modal\r\n .modal({\r\n closable: false,\r\n onHidden: () => window.dbs.globalEvents.emit('shepherdDone', self.uid),\r\n })\r\n .modal('show')\r\n })\r\n\r\n self.modal.find('.close.icon').click(function (event) {\r\n event.preventDefault()\r\n self.close()\r\n\r\n if ($('.pop-up-modal.ui.modal-dhp.visible.active').length > 0) {\r\n window.location.reload()\r\n }\r\n })\r\n\r\n window.dbs.globalEvents.emit('shepherdQueue', self.uid)\r\n }\r\n}\r\n"],"names":["AnnouncementPopUp","el","index","self","this","$","uid","modal","find","modalId","val","getAppearanceLimit","parseInt","hasReachedAppearanceLimit","Cookies","get","close","appearanceCount","set","expires","path","init","window","dbs","globalEvents","subscribe","item","console","log","closable","onHidden","emit","click","event","preventDefault","length","location","reload","Promise","all","then","widget","each","i","data","document","ready"],"sourceRoot":""}