document.addEventListener("alpine:init", () => { //set modal open value globally Alpine.store('modalBackdrop', { open: false, setOpen(value) { this.open = value; } }); Alpine.store('viewport', { mobileMenu: false }) Alpine.store('fitlerList', { results: [], }) Alpine.data("search", (locations) => ({ locations: Object.values(locations), locationsSelected: "All Regions", locationsOpen: false, searchQuery: "", updateSearchQuery(searchQuery, locationsSelected) { let items = []; document.querySelectorAll('.list-card').forEach(el => { let checkSearch = searchQuery === "" || el.innerText.toLowerCase().includes(searchQuery.toLowerCase()); let checkLocations = locationsSelected === "All Regions" || el.dataset.locations.toString().toLowerCase().includes(locationsSelected.toLowerCase()); if (checkSearch && checkLocations) { items.push(el); el.style.display = 'flex'; } else { el.style.display = 'none'; } }) Alpine.store('fitlerList').results = items; document.querySelectorAll('.wp-block-nlsn-accordion-tab').forEach(el => { let childCards = [].slice.call(el.querySelectorAll('.list-card')); let activeChildCards = childCards.filter(el => el.style.display === "flex"); if (activeChildCards.length > 0) { el.style.display = 'block' } else { el.style.display = 'none' } }) }, init() { this.locations.unshift({ name: "All Regions", slug: "all-regions", term_id: false }); this.updateSearchQuery(this.searchQuery, this.locationsSelected); this.$watch('searchQuery', (searchQuery) => { this.updateSearchQuery(searchQuery, this.locationsSelected); this.searchQuery = searchQuery; }) this.$watch('locationsSelected', (locationsSelected) => { this.updateSearchQuery(this.searchQuery, locationsSelected); this.locationsSelected = locationsSelected; }) } })); Alpine.data("accordion", (initialOpenState = false) => ({ isOpen: initialOpenState, init() { this.isOpen = ( encodeURIComponent(window.location.hash) === "%23" + this.$el.id) ? true : false; } })); /** * used by all nlsn popups & modals * parameters : * isOpen = false, isGated = false, initialBackdropState = true, triggerType = 'button', timeoutSeconds = 5 */ Alpine.data("modal", (...modalArgs) => ({ isOpen: modalArgs[0] ?? false, isGated: modalArgs[1] ?? false, isDisabled: false, hasBackdrop: modalArgs[2] ?? true, timerID: null, triggerType : modalArgs[3] ?? 'button', // default trigger type is onClick of button timeoutSeconds : modalArgs[4] ?? 5, // The pop up will close after '5 seconds'(default). delaySeconds : modalArgs[5] ?? 1, // The pop up starts after 5 seconds of page load(default). buttonPosition: '' != modalArgs[6] ? modalArgs[6]: undefined, //stored button position value hasTriggeredByHyperlink: false, // variable to track if already triggered by hyperlink linkClickListener: null, // To store the event listener for removal hasPopupTriggeredOnce:false, init() { this.isOpen = ( encodeURIComponent(window.location.hash) === "%23" + this.$el.id) ? true : this.isOpen; if (this.isOpen) { //call this.open() after the specified delay const initialIsOpen = this.isOpen; this.isOpen = false; setTimeout(() => { this.isOpen = initialIsOpen; this.open(); }, parseInt(this.delaySeconds) * 1000); } const pop_up_cookies = document.cookie.split('; ').filter((cookie_string) => cookie_string.startsWith('nlsn-pop-up')); let form_ids = pop_up_cookies?.map((cookie) => cookie.split('=')[0]?.split('|')[1]); let modal_form_id = this.$el.querySelector('.nf-form-cont')?.getAttribute('id')?.split('-')[2]; let hasFormCookie = form_ids.some(form_id => form_id === (modal_form_id)); if (hasFormCookie) { this.isGated = false; if (this.triggerType !== 'button') { this.isDisabled = true; // this should be enabled only for scroll and onload } let form_div = this.$el.querySelector('.nf-form-cont'); if (form_div) { let thankYouMessage = nfForms?.find(nfForm => nfForm.id === modal_form_id)?.fields?.find(field => field.key.includes('message'))?.value; let div_thank_you_msg = document.createElement('div'); div_thank_you_msg.innerHTML = DOMPurify.sanitize(thankYouMessage ?? 'Thank you'); //fallback thank you message if custom thank you message/NF thank you message is empty form_div.parentNode.insertBefore(div_thank_you_msg, form_div); form_div.classList.add('hidden'); if (this.triggerType === 'page-load') { this.isOpen = false; // this should be not open thank you page popup on page load. } } } if (this.triggerType === 'hyperlinkClick') { this.linkClickListener = (event) => { if (!this.hasPopupTriggeredOnce) { event.preventDefault(); this.open(); this.hasPopupTriggeredOnce = true; // Set the flag to true after the first trigger this.removeHyperlinkListeners(); // Remove all listeners after the first trigger } }; document.querySelectorAll('a').forEach(link => { link.addEventListener('click', this.linkClickListener); }); } if (this.triggerType === 'on-closing-tab') { this.exitTabListener = (event) => { // mouse leaving the top edge (clientY <= 0) // or relatedTarget is null (mouse moving out of the browser window) if (!this.hasPopupTriggeredOnce && (event.clientY <= 0 || event.relatedTarget === null)) { this.open(); // Open the popup this.hasPopupTriggeredOnce = true; // Remove listener so it doesn't fire again this.removeExitTabListener(); } }; // Attach to document.documentElement to detect mouse leaving the entire browser window area document.documentElement.addEventListener('mouseleave', this.exitTabListener); } }, removeExitTabListener() { if (this.exitTabListener) { document.documentElement.removeEventListener('mouseleave', this.exitTabListener); this.exitTabListener = null; } }, removeHyperlinkListeners() { if (this.linkClickListener) { document.querySelectorAll('a').forEach(link => { link.removeEventListener('click', this.linkClickListener); }); this.linkClickListener = null; } }, open(eventDetails=null,clickText) { if (this.isDisabled) { this.$el.classList.toggle("animate-shake"); return; } this.delaySeconds = typeof eventDetails.delaySeconds === 'undefined' ? this.delaySeconds: eventDetails.delaySeconds; this.timeoutSeconds = typeof eventDetails.timeoutSeconds === 'undefined' ? this.timeoutSeconds: eventDetails.timeoutSeconds; let formID = this.$el.querySelector('.nf-form-cont')?.getAttribute('id')?.split('-')[2]; let buttonPosition; // for datalayer trigger if (eventDetails === null || (Object.keys(eventDetails).length === 0)) { //Get the button position value from the additional attribute.If its undefined use the value from the button position dropdown buttonPosition = this.$el.querySelector('[btnPosition]')?.getAttribute('btnPosition') ?? this.buttonPosition; } else{ buttonPosition = eventDetails.buttonPosition; } this.buttonPosition = buttonPosition; // 1444 Add pdf param to the popup event const objectElement = this.$el.querySelector('object[data]'); let pdfFile = undefined; if (objectElement) { const pdfUrl = objectElement.getAttribute('data'); if (pdfUrl.includes(".pdf")) { pdfFile = pdfUrl.split('/').pop().replace(".pdf", ""); } } //pop up open datalayer popup_datalayer(formID, 'open', buttonPosition, pdfFile, clickText);//Data layer event popup_open setTimeout(() => { this.isOpen = true; if (this.hasBackdrop) { //set modal open true. In this whay we can avoid the modal background getting blurred immediatly even before the modal opens. Alpine.store('modalBackdrop', { open: true }); document.body.classList.add('overflow-hidden'); } //keyboard accessibility let firstFocusableElement = this.$el.querySelector('button'); let lastFocusableElement = this.$el.querySelector('input[type="submit"]'); //focus the first element when the pop up opens setTimeout(() => { firstFocusableElement.focus(); },500); //A nominal delay for stability //accessibility for screen reader let wp_blocks = document.querySelector('.wp-site-blocks'); if(wp_blocks) { wp_blocks.setAttribute('aria-hidden',true); } if(!lastFocusableElement && (firstFocusableElement.getAttribute('listener-present') === null)){ firstFocusableElement.setAttribute('listener-present','true') firstFocusableElement.addEventListener('keydown', (e)=>{ let tabPressed = (e.key == "Tab" || e.key == 9); if (tabPressed) { e.preventDefault(); } }); } if(lastFocusableElement) { let lastElementID = lastFocusableElement.getAttribute('id'); let focusableElements = this.$el.querySelectorAll('input:not([type="hidden"]),textarea,a'); let elPrevSubmitButton = focusableElements[focusableElements.length-3]; firstFocusableElement.addEventListener('keydown', (e)=>{ if ( firstFocusableElement.getAttribute('listener-added') === true) return; firstFocusableElement.setAttribute('listener-added',true); let submitButton = document.getElementById(lastElementID); let isDisabled = submitButton.getAttribute('disabled'); let tabPressed = (e.key == "Tab" || e.key == 9); let shiftPressed = (e.shiftKey); if (tabPressed && shiftPressed) { e.preventDefault(); (isDisabled === 'true') ? elPrevSubmitButton.focus() : submitButton.focus(); } }) lastFocusableElement.addEventListener('keydown', (e)=>{ if ( e.target.getAttribute('listener-added') === true) return; e.target.setAttribute('listener-added',true); let tabPressed = (e.key == "Tab" || e.key == 9); let shiftPressed = (e.shiftKey); if (tabPressed && !shiftPressed) { e.preventDefault(); firstFocusableElement.focus(); } }) elPrevSubmitButton.addEventListener('keydown', (e) => { if ( elPrevSubmitButton.getAttribute('listener-added') === true) return; elPrevSubmitButton.setAttribute('listener-added',true); let submitButton = document.getElementById(lastElementID); let isDisabled = submitButton.getAttribute('disabled'); let tabPressed = (e.key == "Tab" || e.key == 9); let shiftPressed = (e.shiftKey); if (tabPressed && !shiftPressed) { e.preventDefault(); if (isDisabled === 'true') { firstFocusableElement.focus() } else { submitButton.focus(); document.getElementById(lastElementID).addEventListener('keydown',(e)=>{ if ( e.target.getAttribute('listener-added') === true) return; e.target.setAttribute('listener-added',true); let tabPressed = (e.key == "Tab" || e.key == 9); let shiftPressed = (e.shiftKey); if (tabPressed && !shiftPressed) { e.preventDefault(); firstFocusableElement.focus(); } }) } } }) //add checks for submitButton and elPrevSubmitButton } }, parseInt(this.delaySeconds) * 1000); }, disableGate() { let popUpContainer = this.$el.firstElementChild.firstElementChild; if (popUpContainer !== null) { let timerBar = document.createElement('div'); timerBar.classList.add('timer-bar','h-2','bg-blurple-300','relative','w-[96%]','left-[2%]','rounded-large'); timerBar.setAttribute('style', '--duration:'+this.timeoutSeconds); popUpContainer?.prepend(timerBar); } this.isGated = false; if (String(this.timeoutSeconds) === '0') { this.close(); } else { this.timerID = setTimeout(() => { this.close(); let timerBar = this.$el.querySelector('.timer-bar') timerBar && timerBar.remove(); }, parseInt(this.timeoutSeconds) * 1000); } }, close(buttonTriggered = false) { if (this.isGated) { this.$root.classList.add("animate-shake"); setInterval(() => { this.$root.classList.remove("animate-shake"); }, 800) return; } if (this.hasBackdrop) { window.dispatchEvent(new CustomEvent('backdrop', { detail: { open: false } })); } this.isOpen = false; //pop up exit datalayer if (buttonTriggered) { let formID = this.$el.parentNode.querySelector('.nf-form-cont')?.getAttribute('id')?.split('-')[2]; // 1444 Add pdf param to the popup event const objectElement = this.$el.parentNode.querySelector('object[data]'); let pdfFile = 'undefined'; if (objectElement) { const pdfUrl = objectElement.getAttribute('data'); if (pdfUrl.includes(".pdf")) { pdfFile = pdfUrl.split('/').pop().replace(".pdf", ""); } } // data layer event popup_exit // buttonPosition is set, when the popup opens. popup_datalayer(formID, 'exit' , this.buttonPosition, pdfFile); } document.body.classList.remove('overflow-hidden'); if (this.timerID) { clearTimeout(this.timerID); // clear timeout for gated content if pop-up is closed manually let timerBar = this.$el.parentNode.querySelector('.timer-bar') timerBar && timerBar.remove(); } //accessibility for screen reader let wp_blocks = document.querySelector('.wp-site-blocks'); if(wp_blocks) { wp_blocks.setAttribute('aria-hidden',false); } } })); Alpine.data("menubar", () => ({ activeNavDropdown: null, trianglePosition: false, triangleColor: false, openSubmenu(navLink) { this.activeNavDropdown = navLink; this.$el.setAttribute('aria-expanded', true); this.trianglePosition = (this.$el.getBoundingClientRect().left + this.$el.getBoundingClientRect().right) / 2; this.triangleColor = (this.$el.dataset.color); const next = this.$el.parentElement.querySelector('.nav-link-dropdown-container') next.querySelector('a').focus() }, closeSubmenu() { this.$el.setAttribute('aria-expanded', false); this.activeNavDropdown = null; }, focusNextItem() { const allMenuItems = [...document.querySelectorAll('.wp-block-nlsn-nav-link > .top-level-nav')]; const currentIndex = allMenuItems.indexOf(document.activeElement); const nextIndex = (currentIndex + 1) % allMenuItems.length; allMenuItems[nextIndex].focus(); }, focusPrevItem() { const allMenuItems = [...document.querySelectorAll('.wp-block-nlsn-nav-link > .top-level-nav')]; const currentIndex = allMenuItems.indexOf(document.activeElement); const prevIndex = (currentIndex - 1 + allMenuItems.length) % allMenuItems.length; allMenuItems[prevIndex].style.display = "inline"; allMenuItems[prevIndex].focus(); }, handleKeyDownSubItem(event) { switch (event.key) { case "ArrowDown": event.preventDefault(); this.focusDownSubItem(); break; case "ArrowUp": event.preventDefault(); this.focusUpSubItem(); break; case "ArrowLeft": event.preventDefault(); this.focusLeftSubItem(); break; case "ArrowRight": event.preventDefault(); this.focusRightSubItem(); break; case "Escape": event.preventDefault(); this.closeSubmenu(); break; default: return null; } }, focusDownSubItem() { const allMenuItems = [...document.querySelectorAll('.nav-link-dropdown-container a')]; const currentIndex = allMenuItems.indexOf(document.activeElement); const nextIndex = (currentIndex + 1) % allMenuItems.length; allMenuItems[nextIndex].focus(); }, focusUpSubItem() { const allMenuItems = [...document.querySelectorAll('.nav-link-dropdown-container a')]; const currentIndex = allMenuItems.indexOf(document.activeElement); const prevIndex = (currentIndex - 1 + allMenuItems.length) % allMenuItems.length; allMenuItems[prevIndex].focus(); }, focusRightSubItem() { const allMenuItems = [...document.querySelectorAll('.wp-block-nlsn-nav-link > .top-level-nav')]; const nextIndex = (this.activeNavDropdown.slice(-1) * 2) % allMenuItems.length; allMenuItems[nextIndex].focus(); }, focusLeftSubItem() { const allMenuItems = [...document.querySelectorAll('.wp-block-nlsn-nav-link > .top-level-nav')]; const prevIndex = (this.activeNavDropdown.slice(-1) * 2 - 1 + allMenuItems.length) % allMenuItems.length; allMenuItems[prevIndex].focus(); }, })) Alpine.data("carousel", () => ({ slideCount: 0, activeIndex: 0, childWidth: 0, gapWidth: 24, init() { this.slideCount = this.$refs.carouselInner.childElementCount; this.childWidth = this.$refs.carouselInner.getElementsByClassName('flex-col')[0].offsetWidth; }, prev(carouselInner) { if (this.activeIndex > 0) { carouselInner.scrollLeft = (this.childWidth + this.gapWidth) * (this.activeIndex - 1); this.activeIndex--; } }, next(carouselInner) { if (this.activeIndex < this.slideCount - 1) { carouselInner.scrollLeft = (this.childWidth + this.gapWidth) * (this.activeIndex + 1); this.activeIndex++; } }, updateIndex(target) { this.activeIndex = Math.round(target.scrollLeft / this.childWidth); }, })); Alpine.data("navSearch", () => ({ mobileMenu: false, search: false, searchText : '' , // it's a reactive prop. searchResults: [], siteURL : "", setSiteURL(siteURL){ this.siteURL = siteURL; }, fetchResults(searchText) { const desktopCursorPointer = document.getElementById('desktop-cursor-pointer'); if(searchText.length == 0){ this.searchResults = []; if (desktopCursorPointer && desktopCursorPointer.getAttribute('is-submit') == 'true') { desktopCursorPointer.setAttribute('is-submit','false'); desktopCursorPointer.setAttribute('x-on:click', 'search = !search; document.getElementById("nav-search").focus();'); } } if(searchText.length >= 3){ window.fetch('/wp-json/wp/v2/search?search='+searchText+'&_fields=title,url&page=1&per_page=5&vip-search-enabled=1') .then(response => response.json()) .then(json => { const words = searchText.split(' ').filter(word => word.trim() !== ''); const regex = new RegExp(`(${words.join('|')})`, 'gi'); this.searchResults = json.map(result => { const underlinedTitle = result.title.replace(regex, match => `${match}`); return { ...result, title: underlinedTitle }; }); if (desktopCursorPointer && desktopCursorPointer.getAttribute('is-submit') == 'false') { desktopCursorPointer.setAttribute('is-submit','true'); desktopCursorPointer.removeAttribute('x-on:click'); } }) .catch(err => console.log(err)) }else{ this.searchResults =[]; } }, addSearchkeyToDataLayer(){ const dataLayer = { 'event': 'search','searchTerm': this.searchText}; window.dataLayer = window.dataLayer || []; window.dataLayer.push(dataLayer); } })); }); jQuery(document).ready(function() { jQuery('#desktop-cursor-pointer').on('click', function() { if (jQuery(this).attr('is-submit') == 'true') { jQuery('.searchform').submit(); } }); jQuery(".client_login").on('click',function(){ const dataLayer = { 'event': 'login_nav_button'}; window.dataLayer = window.dataLayer || []; window.dataLayer.push(dataLayer); }); }); ; /** * what-input - A global utility for tracking the current input method (mouse, keyboard or touch). * @version v5.2.12 * @link https://github.com/ten1seven/what-input * @license MIT */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("whatInput",[],t):"object"==typeof exports?exports.whatInput=t():e.whatInput=t()}(this,function(){return i={},n.m=o=[function(e,t){"use strict";e.exports=function(){if("undefined"==typeof document||"undefined"==typeof window)return{ask:function(){return"initial"},element:function(){return null},ignoreKeys:function(){},specificKeys:function(){},registerOnChange:function(){},unRegisterOnChange:function(){}};var t=document.documentElement,n=null,u="initial",s=u,o=Date.now(),i=!1,d=["button","input","select","textarea"],r=[],c=[16,17,18,91,93],w=[],p={keydown:"keyboard",keyup:"keyboard",mousedown:"mouse",mousemove:"mouse",MSPointerDown:"pointer",MSPointerMove:"pointer",pointerdown:"pointer",pointermove:"pointer",touchstart:"touch",touchend:"touch"},a=!1,f={x:null,y:null},l={2:"touch",3:"touch",4:"mouse"},m=!1;try{var e=Object.defineProperty({},"passive",{get:function(){m=!0}});window.addEventListener("test",null,e)}catch(e){}var h=function(){var e=!m||{passive:!0,capture:!0};document.addEventListener("DOMContentLoaded",v,!0),window.PointerEvent?(window.addEventListener("pointerdown",y,!0),window.addEventListener("pointermove",E,!0)):window.MSPointerEvent?(window.addEventListener("MSPointerDown",y,!0),window.addEventListener("MSPointerMove",E,!0)):(window.addEventListener("mousedown",y,!0),window.addEventListener("mousemove",E,!0),"ontouchstart"in window&&(window.addEventListener("touchstart",y,e),window.addEventListener("touchend",y,!0))),window.addEventListener(O(),E,e),window.addEventListener("keydown",y,!0),window.addEventListener("keyup",y,!0),window.addEventListener("focusin",L,!0),window.addEventListener("focusout",b,!0)},v=function(){if(i=!("false"===t.getAttribute("data-whatpersist")||"false"===document.body.getAttribute("data-whatpersist")))try{window.sessionStorage.getItem("what-input")&&(u=window.sessionStorage.getItem("what-input")),window.sessionStorage.getItem("what-intent")&&(s=window.sessionStorage.getItem("what-intent"))}catch(e){}g("input"),g("intent")},y=function(e){var t=e.which,n=p[e.type];"pointer"===n&&(n=S(e));var o=!w.length&&-1===c.indexOf(t),i=w.length&&-1!==w.indexOf(t),r="keyboard"===n&&t&&(o||i)||"mouse"===n||"touch"===n;if(M(n)&&(r=!1),r&&u!==n&&(x("input",u=n),g("input")),r&&s!==n){var a=document.activeElement;a&&a.nodeName&&(-1===d.indexOf(a.nodeName.toLowerCase())||"button"===a.nodeName.toLowerCase()&&!C(a,"form"))&&(x("intent",s=n),g("intent"))}},g=function(e){t.setAttribute("data-what"+e,"input"===e?u:s),k(e)},E=function(e){var t=p[e.type];"pointer"===t&&(t=S(e)),A(e),(!a&&!M(t)||a&&"wheel"===e.type||"mousewheel"===e.type||"DOMMouseScroll"===e.type)&&s!==t&&(x("intent",s=t),g("intent"))},L=function(e){e.target.nodeName?(n=e.target.nodeName.toLowerCase(),t.setAttribute("data-whatelement",n),e.target.classList&&e.target.classList.length&&t.setAttribute("data-whatclasses",e.target.classList.toString().replace(" ",","))):b()},b=function(){n=null,t.removeAttribute("data-whatelement"),t.removeAttribute("data-whatclasses")},x=function(e,t){if(i)try{window.sessionStorage.setItem("what-"+e,t)}catch(e){}},S=function(e){return"number"==typeof e.pointerType?l[e.pointerType]:"pen"===e.pointerType?"touch":e.pointerType},M=function(e){var t=Date.now(),n="mouse"===e&&"touch"===u&&t-o<200;return o=t,n},O=function(){return"onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll"},k=function(e){for(var t=0,n=r.length;t { let modal_attribute = download_block.getAttribute("@click"); let start_pos = modal_attribute.indexOf('"'); let end_pos = modal_attribute.indexOf('"', start_pos + 1); if (start_pos > -1 && end_pos > -1) { let modal_id = modal_attribute.substring(start_pos + 1, end_pos); let linked_modal = document.getElementById(modal_id); if (linked_modal.querySelectorAll(".nf-form-cont").length < 1) { download_block.parentNode.classList.add("hidden"); } } }); }) ; jQuery(document).ready(function() { document.querySelectorAll('.wp-block-nlsn-card').forEach(card => { // Remove empty
tags const heading = card.querySelector('h5.wp-block-nlsn-card-heading'); if (heading && heading.textContent.trim() === '') { heading.remove(); } }); document.querySelectorAll('a:not([aria-label])').forEach(a => { // add aria label to the empty acnhor tag if (a.innerHTML.trim() === '') { const href = a.getAttribute('href'); if (href) { const label = href.split('/').filter(Boolean).pop(); a.setAttribute('aria-label', label); } } }); });; jQuery(document).ready(function() { document.querySelectorAll('div[role="tablist"]').forEach(tablist => { const tabButtons = document.querySelectorAll('button[role="tab"][aria-controls][data-tab]:not([id])'); tabButtons.forEach(button => { const tabId = button.getAttribute('aria-controls'); if (tabId) { button.setAttribute('id', tabId); } }); }); });; jQuery(document).ready(function ($) { // Use the event "updated_wc_div" to trigger post. this is triggered when cart is updated. jQuery(document.body).on("updated_wc_div", function () { let element_locator = 'custom-cross-sell'; let fixed_cross_sell_div = document.getElementById(element_locator); if (fixed_cross_sell_div === null) { return; } let category_id = fixed_cross_sell_div?.dataset.categoryid; // extract category id from attribute data-categoryid $.ajax({ method: "POST", url: nlsn_custom_cross_sells_ajax_obj.ajax_url, data: { _ajax_nonce: nlsn_custom_cross_sells_ajax_obj.nonce, //nonce action: "refresh_nlsn_custom_cross_sells", //action name : this name must match with the wp_ajax_{action_name} category_id : category_id // pass the category ID }, beforeSend: function(){ let cross_sell_div = document.getElementById(element_locator); if(cross_sell_div !== null){ cross_sell_div.style.opacity = '40%'; } }, complete: function(){ let cross_sell_div = document.getElementById(element_locator); if(cross_sell_div !== null){ cross_sell_div.style.opacity = 'unset'; } }, success: function(response){ const cross_sell_container = document.getElementById(element_locator); if (cross_sell_container !== null && response.success) { cross_sell_container.innerHTML = DOMPurify.sanitize(response.data.html); } } }); }); });; async function spam_check_ajax({firstName:e,lastName:a,email:r,message:n,url:t,userAgent:s,refferer:c}){try{const o=await fetch(nlsn_spam_check_ajax_obj.ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:AbortSignal.timeout(3e3),body:new URLSearchParams({_ajax_nonce:nlsn_spam_check_ajax_obj.nonce,action:"spam_check_akismet",firstName:e,lastName:a,email:r,message:n,url:t,userAgent:s,refferer:c})});return await o.json()}catch(e){return new Error("failed to fetch response")}}; jQuery(document).ready(function ($) { // Use the event "updated_wc_div" to trigger post. this is triggered when cart is updated. jQuery(document.body).on("updated_wc_div", function () { $.ajax({ method: "POST", url: nlsn_cross_sells_ajax_obj.ajax_url, data: { _ajax_nonce: nlsn_cross_sells_ajax_obj.nonce, //nonce action: "refresh_cross_sells", //action }, beforeSend: function(){ let cross_sell_div = document.getElementById("cross-sells-locator"); if(cross_sell_div !== null){ cross_sell_div.style.opacity = '40%'; } }, complete: function(){ let cross_sell_div = document.getElementById("cross-sells-locator"); if(cross_sell_div !== null){ cross_sell_div.style.opacity = 'unset'; } }, success: function(response){ const cross_sell_container = document.getElementById("cross-sells-locator"); if (cross_sell_container !== null && response.success) { cross_sell_container.innerHTML = DOMPurify.sanitize(response.data.html); } } }); }); }); ;