1jQuery(document).ready(function($) 2{ 3(function() { 4 5 document.addEventListener('click', function(e) { 6 var tab = e.target.closest('.dnw-tab'); 7 8 if (!tab) { 9 return; 10 } 11 12 var widget = tab.closest('.deal-notification-widget'); 13 14 if (!widget) { 15 return; 16 } 17 18 var targetTab = tab.getAttribute('data-tab'); 19 var tabs = widget.querySelectorAll('.dnw-tab'); 20 var forms = widget.querySelectorAll('.dnw-filter-form'); 21 22 tabs.forEach(function(t) { 23 t.classList.remove('active'); 24 }); 25 tab.classList.add('active'); 26 27 forms.forEach(function(form) { 28 var formTab = form.getAttribute('data-tab'); 29 30 if (formTab === targetTab) { 31 form.style.display = 'block'; 32 form.classList.add('active'); 33 } else { 34 form.style.display = 'none'; 35 form.classList.remove('active'); 36 } 37 }); 38 }); 39 40 document.addEventListener('click', function(e) { 41 var button = e.target.closest('.dnw-subscribe-button'); 42 43 if (!button) { 44 return; 45 } 46 47 var widget = button.closest('.deal-notification-widget'); 48 49 if (!widget) { 50 return; 51 } 52 53 var emailInput = widget.querySelector('.dnw-email-input'); 54 var rulesCheckbox = widget.querySelector('.dnw-rules-checkbox'); 55 var emailError = widget.querySelector('.dnw-email-error'); 56 var rulesError = widget.querySelector('.dnw-rules-error'); 57 var brandsError = widget.querySelector('.dnw-brands-error'); 58 var selectedBrands = []; 59 60 emailError.textContent = ''; 61 emailError.style.display = 'none'; 62 emailInput.classList.remove('dnw-error'); 63 rulesError.textContent = ''; 64 rulesError.style.display = 'none'; 65 rulesCheckbox.classList.remove('dnw-error'); 66 brandsError.textContent = ''; 67 brandsError.style.display = 'none'; 68 69 widget.querySelectorAll('.dnw-brand-checkbox:checked').forEach(function(checkbox) { 70 selectedBrands.push({ 71 category: checkbox.getAttribute('data-category'), 72 brand: checkbox.getAttribute('data-brand') 73 }); 74 }); 75 76 var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; 77 if (!emailInput.value || !emailRegex.test(emailInput.value)) { 78 emailError.textContent = getTranslate('accountWrongEmailError'); 79 emailError.style.display = 'block'; 80 emailInput.classList.add('dnw-error'); 81 emailInput.focus(); 82 return; 83 } 84 85 if (selectedBrands.length === 0) { 86 brandsError.textContent = getTranslate('notificationProductTooltipBrandError'); 87 brandsError.style.display = 'block'; 88 return; 89 } 90 91 var smartNotifications = widget.closest('.smart-notifications'); 92 if (smartNotifications) { 93 var popupContent = smartNotifications.querySelector('.popup_content'); 94 var popupSuccess = smartNotifications.querySelector('.popup_success_message'); 95 96 if (popupContent) { 97 popupContent.classList.add('hide'); 98 } 99 if (popupSuccess) { 100 popupSuccess.classList.add('active'); 101 } 102 } 103 104 elementorProFrontend.modules.popup.closePopup({}, e); 105 106 toasterMessage = getTranslate('notificationToasterHeadingSuccess'); 107 108 const successHtml = ` 109 <div class="notification-toaster-success"> 110 <div class="notification-toaster-first-child"> 111 <div class="notification-toaster-icon"></div> 112 </div> 113 <div class="notification-toaster-second-child"> 114 <div class="notification-toaster-heading"> 115 <p>${toasterMessage}</p> 116 </div> 117 </div> 118 </div>`; 119 120 let $container = $('.notification-toaster-container'); 121 if ($container.length === 0) {
122 $container = $('<div class="notification-toaster-container"></div>'); 123 $('body').append($container); 124 } 125 126 const $toast = $(successHtml); 127 $container.append($toast); 128 129 setTimeout(() => { 130 $toast.fadeOut(300, () => $toast.remove()); 131 }, 5000); 132 133 134 135 if(jQuery('.dnw-rules-checkbox').is(':checked')) 136 { 137 newsletter = 1; 138 } 139 else 140 { 141 newsletter = 0; 142 } 143 144 data = { 145 filters: selectedBrands, 146 email: emailInput.value, 147 newsletter 148 } 149 150 $.ajax({ 151 url: ajax_object.ajax_url, 152 method: 'POST', 153 data: { 154 action: 'classtrucks_auth_action', 155 auth_action: 'save_notification_preset_not_loggedin_new', 156 user_action_data: data 157 }, 158 success: function (response) { 159 if (response.success && response.data.response) { 160 161 162 } 163 }}); 164 165 emailInput.value = ''; 166 rulesCheckbox.checked = false; 167 widget.querySelectorAll('.dnw-brand-checkbox').forEach(function(cb) { 168 cb.checked = false; 169 }); 170 }); 171 172 document.addEventListener('input', function(e) { 173 if (e.target.classList.contains('dnw-email-input')) { 174 var widget = e.target.closest('.deal-notification-widget'); 175 var emailError = widget.querySelector('.dnw-email-error'); 176 e.target.classList.remove('dnw-error'); 177 emailError.textContent = ''; 178 emailError.style.display = 'none'; 179 } 180 }); 181 182 document.addEventListener('change', function(e) { 183 if (e.target.classList.contains('dnw-rules-checkbox')) { 184 var widget = e.target.closest('.deal-notification-widget'); 185 var rulesError = widget.querySelector('.dnw-rules-error'); 186 e.target.classList.remove('dnw-error'); 187 rulesError.textContent = ''; 188 rulesError.style.display = 'none'; 189 } 190 }); 191})(); 192});
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.