1jQuery(document).ready(function ($) { 2 function handleLogin() { 3 const loginForm$ = $('.ghm-login-form'); 4 const email$ = loginForm$.find('#ghm_login_email'); 5 const password$ = loginForm$.find('#ghm_login_password'); 6 const submitBtn$ = loginForm$.find('.ghm-submit-btn'); 7 const errorMessage$ = loginForm$.find('.error-message'); 8 9 let isValid = false; 10 11 email$.on('input', function () { 12 const value = $(this).val().toLowerCase(); 13 const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; 14 15 if (value === '' || !emailPattern.test(value)) { 16 isValid = false; 17 $(this).attr('aria-invalid', 'true'); 18 errorMessage$.filter('#email-error').text('Not a valid email address.').attr('hidden', false); 19 } else { 20 isValid = true; 21 $(this).attr('aria-invalid', 'false'); 22 errorMessage$.filter('#email-error').text('').attr('hidden', true); 23 } 24 25 submitBtn$.prop('disabled', !isValid); 26 }); 27 28 password$.on('input', function () { 29 const value = $(this).val(); 30 31 if (value === '') { 32 isValid = false; 33 $(this).attr('aria-invalid', 'true'); 34 errorMessage$.filter('#password-error').text('Password is required.').attr('hidden', false); 35 36 } else { 37 isValid = true; 38 $(this).attr('aria-invalid', 'false'); 39 errorMessage$.filter('#password-error').text('').attr('hidden', true); 40 } 41 42 submitBtn$.prop('disabled', !isValid); 43 }); 44 45 $('.eye, .eye-slash').on('click', function (e) { 46 e.preventDefault(); 47 48 const isPasswordVisible = password$.attr('type') === 'text'; 49 50 if (isPasswordVisible) { 51 $('.eye').show(); 52 $('.eye-slash').hide(); 53 password$.attr('type', 'password'); 54 } else { 55 $('.eye').hide(); 56 $('.eye-slash').show(); 57 password$.attr('type', 'text'); 58 } 59 }); 60 61 if (isValid) { 62 submitBtn$.prop('disabled', false); 63 } 64 65 loginForm$.on('submit', function (e) { 66 e.preventDefault(); 67 const formData = $(this).serialize(); 68 $.ajax({ 69 type: 'POST', 70 url: GHM.ajax_url, 71 data: { 72 action: GHM.actions.login, 73 data: formData, 74 }, 75 beforeSend: function (response) { 76 submitBtn$.prop('disabled', true); 77 loginForm$.find('.ghm-submit-text').hide(); 78 loginForm$.find('.ghm-spinner').show(); 79 }, 80 complete: function (response) { 81 submitBtn$.prop('disabled', false); 82 loginForm$.find('.ghm-submit-text').show(); 83 loginForm$.find('.ghm-spinner').hide(); 84 turnstile && turnstile.reset(); 85 }, 86 success: function (response) { 87 if (response.success === true) { 88 window.dataLayer = window.dataLayer || []; 89 window.dataLayer.push({ 90 account: { 91 id: response.data.id || '', 92 }, 93 brand: loginForm$.data('brand'), 94 eventType: 'loginSuccess', 95 module: 'BrandedSite', 96 page: window.location.href, 97 visitorID: Cookies.get('GAID') || '', 98 timestamp: new Date().toISOString(), 99 event: 'loginSuccess', 100 loginSource: response.data.source || '', 101 }); 102 $('#ghm-login-message').text('We are redirecting you to your page.'); 103 window.location.replace(response.data.redirect_to); 104 } else { 105 $('#ghm-login-message').text('There was an error logging in. Please try again.'); 106 } 107 }, 108 error: function (error) { 109 $('#ghm-login-message').text(error); 110 } 111 }); 112 }); 113 } 114 115 handleLogin(); 116 117 jQuery(document).on('elementor/popup/show', function (event, id, instance) { 118 $('[name="redirect_to"]').val(window.location.href); 119 handleLogin(); 120 }); 121});
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.