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Aa,YAC7BC,MAAKC,IACGA,EAASC,KAGd1C,KAAKkB,iBACLlB,KAAKmC,cACLvB,YAAW,KAAQZ,KAAKyB,MAAMH,WAAW,GAAI,KAAK,IAErDqB,OAAMC,IACH5C,KAAKmC,cACLU,EAAQD,MAAM,iDAAkDA,EAAM,IAGnE5C,IACX,EAiBAwB,EAAatC,MAAMF,E","sources":["webpack:///./modules/Popup.ts","webpack:///./modules/ReportReview.ts"],"sourcesContent":["/// \r\n\r\nimport { getOptions } from '../helpers/helperFunctions';\r\n\r\nconst moduleSelector = '[data-module=\"Popup\"]';\r\n\r\nexport default class Popup {\r\n private button: HTMLElement;\r\n private content: HTMLElement;\r\n private closePopupElements: HTMLElement[];\r\n\r\n static setup(selector: string = moduleSelector): void {\r\n Array.from(document.querySelectorAll(selector)).filter((node: HTMLElement) => !node.dataset.moduleInitialized).forEach((element: HTMLElement) => {\r\n new Popup(element);\r\n element.dataset.moduleInitialized = 'true';\r\n });\r\n }\r\n\r\n constructor(public element: HTMLElement, private options: PopupOptions = {}) {\r\n this.options = getOptions(this.element, Object.assign(this.getDefaultOptions(), this.options));\r\n\r\n this.button = this.element.querySelector(this.options.buttonSelector);\r\n this.content = this.element.querySelector(this.options.contentSelector);\r\n this.closePopupElements = Array.from(this.element.querySelectorAll(this.options.closePopupClassList));\r\n\r\n this.init();\r\n }\r\n\r\n private init(): void {\r\n setTimeout(() => {\r\n this.element.parentElement.classList.add(this.options.loadedClass);\r\n }, 500); // 500 is 0.5s animation time from \\resrc\\NiveaX\\less\\block\\_sharing.less\r\n this.button.addEventListener('click', () => this.toggleElements());\r\n this.closePopupElements.forEach((closeElement: HTMLElement) => {\r\n closeElement.addEventListener('click', () => this.toggleElements());\r\n });\r\n }\r\n\r\n toggleElements() {\r\n this.content.classList.toggle(this.options.toggleClass + '--hidden');\r\n this.content.classList.toggle(this.options.toggleClass + '--visible');\r\n return this;\r\n }\r\n\r\n hidePopup() {\r\n this.content.classList.add(this.options.toggleClass + '--hidden');\r\n this.content.classList.remove(this.options.toggleClass + '--visible');\r\n return this;\r\n }\r\n\r\n private getDefaultOptions(): PopupOptions {\r\n return {\r\n buttonSelector: '.nx-popup__button',\r\n contentSelector: '.nx-popup__content',\r\n closePopupClassList: '.nx-popup__close-btn',\r\n loadedClass: 'nx-popup-loaded',\r\n toggleClass: 'nx-popup__content'\r\n };\r\n }\r\n}\r\n\r\n// Hot Module Replacement\r\nif (module.hot) {\r\n let nodesCache: HMRNodes[] = Array.from(document.querySelectorAll(moduleSelector)).map((element: Node) => ({ nodeToReplace: element, nodeOrigin: element.cloneNode(true) }));\r\n\r\n Popup.setup(moduleSelector);\r\n\r\n module.hot.accept(() => {\r\n Popup.setup(moduleSelector);\r\n });\r\n module.hot.dispose(() => {\r\n nodesCache.forEach(({ nodeToReplace, nodeOrigin }) => { nodeToReplace = nodeToReplace.parentElement.replaceChild(nodeOrigin.cloneNode(true), nodeToReplace) });\r\n });\r\n} else {\r\n Popup.setup(moduleSelector);\r\n}","/// \r\nimport Popup from './Popup';\r\n\r\nconst moduleSelector = '[data-module=\"ReportReview\"]';\r\n\r\nexport default class ReportReview {\r\n private popup: Popup;\r\n private reportReviewLink: HTMLElement;\r\n\r\n static setup(selector: string = moduleSelector): void {\r\n Array.from(document.querySelectorAll(selector)).filter((node: HTMLElement) => !node.dataset.moduleInitialized).forEach((element: HTMLElement) => {\r\n new ReportReview(element);\r\n element.dataset.moduleInitialized = 'true';\r\n });\r\n }\r\n\r\n constructor(public element: HTMLElement) {\r\n this.popup = new Popup(element, { closePopupClassList: '.nx-popup__close, .nx-popup__close-btn' });\r\n this.reportReviewLink = this.element.querySelector('[data-report-url]');\r\n \r\n this.init();\r\n }\r\n\r\n private init(): void {\r\n if (this.reportReviewLink) {\r\n this.reportReviewLink.addEventListener('click', () => this.sendAjaxRequest());\r\n }\r\n }\r\n\r\n\r\n private toggleElements() :void {\r\n const text = this.popup.element.querySelector('.nx-product-reviews__report-abuse-text'),\r\n thankyouText = this.popup.element.querySelector('.nx-product-reviews__report-thankyou-text'),\r\n buttons = this.popup.element.querySelectorAll('.nx-action-link');\r\n\r\n thankyouText.style.display ='';\r\n text.style.display = 'none';\r\n buttons.forEach((btn: HTMLElement) => btn.style.display = 'none');\r\n }\r\n\r\n private showSpinner() {\r\n return this.popup.element.querySelector('.nx-popup__inner')?.classList.add('nx-u-spinner');\r\n }\r\n\r\n private hideSpinner() {\r\n return this.popup.element.querySelector('.nx-popup__inner')?.classList.remove('nx-u-spinner');\r\n }\r\n\r\n private sendAjaxRequest() {\r\n const ajaxUrl: string = this.reportReviewLink.dataset.reportUrl;\r\n\r\n this.showSpinner()\r\n\r\n fetch(ajaxUrl, { credentials: 'include' })\r\n .then(response => {\r\n if (!response.ok)\r\n return;\r\n \r\n this.toggleElements()\r\n this.hideSpinner();\r\n setTimeout(() => { this.popup.hidePopup() }, 5000);\r\n })\r\n .catch(error => {\r\n this.hideSpinner();\r\n console.error('There was a problem with your fetch operation:', error)\r\n });\r\n\r\n return this;\r\n }\r\n\r\n}\r\n\r\n// Hot Module Replacement\r\nif (module.hot) {\r\n let nodesCache: HMRNodes[] = Array.from(document.querySelectorAll(moduleSelector)).map((element: Node) => ({ nodeToReplace: element, nodeOrigin: element.cloneNode(true) }));\r\n\r\n ReportReview.setup(moduleSelector);\r\n\r\n module.hot.accept(() => {\r\n ReportReview.setup(moduleSelector);\r\n });\r\n module.hot.dispose(() => {\r\n nodesCache.forEach(({ nodeToReplace, nodeOrigin }) => { nodeToReplace = nodeToReplace.parentElement.replaceChild(nodeOrigin.cloneNode(true), nodeToReplace) });\r\n });\r\n} else {\r\n ReportReview.setup(moduleSelector);\r\n}"],"names":["moduleSelector","Popup","setup","selector","Array","from","document","querySelectorAll","filter","node","dataset","moduleInitialized","forEach","element","constructor","options","this","Object","assign","getDefaultOptions","button","querySelector","buttonSelector","content","contentSelector","closePopupElements","closePopupClassList","init","setTimeout","parentElement","classList","add","loadedClass","addEventListener","toggleElements","closeElement","toggle","toggleClass","hidePopup","remove","ReportReview","popup","reportReviewLink","sendAjaxRequest","text","thankyouText","buttons","style","display","btn","showSpinner","hideSpinner","ajaxUrl","reportUrl","fetch","credentials","then","response","ok","catch","error","console"],"sourceRoot":""}