1jQuery(document).ready(function($) { 2 const freq = msp_ajax.frequency; 3 4 function setCookie(name, value, days) { 5 const date = new Date(); 6 date.setTime(date.getTime() + (days*24*60*60*1000)); 7 document.cookie = `${name}=${value};expires=${date.toUTCString()};path=/`; 8 } 9 10 function getCookie(name) { 11 const value = `; ${document.cookie}`; 12 const parts = value.split(`; ${name}=`); 13 if (parts.length === 2) return parts.pop().split(';').shift(); 14 } 15 16 // Check if popup should be shown based on frequency setting 17 let showPopup = true; 18 if (freq === 'session' && sessionStorage.getItem('msp_popup_shown')) { 19 showPopup = false; 20 } 21 if (freq === 'day' && getCookie('msp_popup_shown')) { 22 showPopup = false; 23 } 24 25 // Display popup if conditions are met (with 10 second delay) 26if (showPopup) { 27 setTimeout(function() { 28 $('#msp-popup-overlay').fadeIn(); 29 if (freq === 'session') { 30 sessionStorage.setItem('msp_popup_shown', 'yes'); 31 } 32 if (freq === 'day') { 33 setCookie('msp_popup_shown', 'yes', 1); 34 } 35 }, 12000); // 12000 milliseconds = 12seconds 36} 37 38 // Move from Step 1 to Step 2 39 $('#msp-next-btn').on('click', function() { 40 $('.msp-step-1').removeClass('active'); 41 $('.msp-step-2').addClass('active'); 42 }); 43 44 // Close popup 45 $('.msp-close-btn').on('click', function() { 46 $('#msp-popup-overlay').fadeOut(); 47 }); 48 49 // Close popup when clicking outside the box 50 $('#msp-popup-overlay').on('click', function(e) { 51 if ($(e.target).is('#msp-popup-overlay')) { 52 $('#msp-popup-overlay').fadeOut(); 53 } 54 }); 55 56 // Handle form submission 57 $('#msp-form').on('submit', function(e) { 58 e.preventDefault(); 59 60 // Hide previous messages 61 $('.msp-success').hide(); 62 $('.msp-error').hide(); 63 64 // Disable submit button to prevent double submission 65 const $submitBtn = $(this).find('button[type="submit"]'); 66 const originalText = $submitBtn.text(); 67 $submitBtn.prop('disabled', true).text('Sending...'); 68 69 const data = $(this).serialize(); 70 71 $.post(msp_ajax.ajax_url, { 72 action: 'msp_send_pdf', 73 ...Object.fromEntries(new URLSearchParams(data)) 74 }, function(response) { 75 // Re-enable submit button 76 $submitBtn.prop('disabled', false).text(originalText); 77 78 if (response.success) { 79 // Hide form and show success message 80 $('#msp-form').hide(); 81 $('.msp-success').fadeIn(); 82 83 // Optional: Close popup after 5 seconds 84 setTimeout(function() { 85 $('#msp-popup-overlay').fadeOut(); 86 }, 5000); 87 88 } else { 89 // Show error message 90 $('.msp-error').text(response.data || 'An error occurred. Please try again.').fadeIn(); 91 } 92 }).fail(function() { 93 // Handle AJAX failure 94 $submitBtn.prop('disabled', false).text(originalText); 95 $('.msp-error').text('Network error. Please check your connection and try again.').fadeIn(); 96 }); 97 }); 98 99 // NEW: Trigger popup when clicking button with specific class 100 $(document).on('click', '.trigger-newsletter-popup', function(e) { 101 e.preventDefault(); // Prevent default link behavior 102 $('#msp-popup-overlay').fadeIn(); // Show the popup 103 }); 104});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.