1/* Form submission functions for the Mailchimp Widget */ 2(function ($) { 3 function mc_beforeForm() { 4 // Disable the submit button 5 $('.mc_signup_submit_button').attr('disabled', 'disabled'); 6 } 7 8 function mc_success(data, status, xhr, submittedForm) { 9 let form = $(submittedForm); 10 if (!submittedForm || !form) { 11 form = $('.mc_signup_form'); 12 } 13 14 // Re-enable the submit button 15 $('.mc_signup_submit_button').removeAttr('disabled'); 16 17 // Put the response in the message div 18 form.find('.mc_message_wrapper').html(data); 19 20 // See if we're successful, if so, wipe the fields 21 const reg = /class=(["'])mc_success_msg\1/i; 22 23 if (reg.test(data)) { 24 $(form).each(function () { 25 this.reset(); 26 }); 27 28 $('.mc_submit_type').val('js'); 29 } 30 31 window.scrollTo({ 32 top: parseInt(form.offset().top, 10) - 28, 33 behavior: 'smooth', 34 }); 35 } 36 37 $(function ($) { 38 // Change our submit type from HTML (default) to JS 39 $('.mc_submit_type').val('js'); 40 41 // Remove the no JS field. 42 $('.mailchimp_sf_no_js').remove(); 43 44 // Attach our form submitter action 45 $('.mc_signup_form').ajaxForm({ 46 url: window.mailchimpSF.ajax_url, 47 type: 'POST', 48 dataType: 'text', 49 beforeSubmit: mc_beforeForm, 50 success: mc_success, 51 }); 52 }); 53})(window.jQuery); 54 55/* Datepicker functions for the Mailchimp Widget */ 56(function ($) { 57 if ($('.date-pick').length > 0) { 58 // Datepicker for the date-pick class 59 $('.date-pick').each(function () { 60 let format = $(this).data('format') || 'mm/dd/yyyy'; 61 format = format.replace(/yyyy/i, 'yy'); 62 $(this).datepicker({ 63 autoFocusNextInput: true, 64 constrainInput: false, 65 changeMonth: true, 66 changeYear: true, 67 // eslint-disable-next-line no-unused-vars 68 beforeShow(input, inst) { 69 $('#ui-datepicker-div').addClass('show'); 70 }, 71 dateFormat: format.toLowerCase(), 72 }); 73 }); 74 } 75 76 if ($('.birthdate-pick').length > 0) { 77 const d = new Date(); 78 $('.birthdate-pick').each(function () { 79 let format = $(this).data('format') || 'mm/dd'; 80 format = format.replace(/yyyy/i, 'yy'); 81 $(this).datepicker({ 82 autoFocusNextInput: true, 83 constrainInput: false, 84 changeMonth: true, 85 changeYear: false, 86 minDate: new Date(d.getFullYear(), 1 - 1, 1), 87 maxDate: new Date(d.getFullYear(), 12 - 1, 31), 88 // eslint-disable-next-line no-unused-vars 89 beforeShow(input, inst) { 90 $('#ui-datepicker-div').removeClass('show'); 91 }, 92 dateFormat: format.toLowerCase(), 93 }); 94 }); 95 } 96 97 // Phone validation custom error message. 98 if ($('.mailchimp-sf-phone').length > 0) { 99 $('.mailchimp-sf-phone').each(function () { 100 $(this) 101 .on('input', function () { 102 this.setCustomValidity(''); 103 }) 104 .on('invalid', function () { 105 if (!this.validity.valid) { 106 this.setCustomValidity(window.mailchimpSF.phone_validation_error); 107 } 108 }); 109 }); 110 } 111})(window.jQuery); 112 113/* Form view tracking for analytics */ 114(function () { 115 if (!window.mailchimpSF || !window.mailchimpSF.analytics_ajax_url) { 116 return; 117 } 118 119 const forms = document.querySelectorAll('.mc_signup_form[data-list-id]'); 120 const tracked = {}; 121 122 for (let i = 0; i < forms.length; i++) { 123 const listId = forms[i].getAttribute('data-list-id'); 124 if (listId && !tracked[listId]) { 125 tracked[listId] = true; 126 127 const formData = new FormData(); 128 formData.append('action', 'mailchimp_sf_track_form_view'); 129 formData.append('list_id', listId); 130 formData.append('mailchimp_sf_nonce', window.mailchimpSF.analytics_nonce); 131 132 fetch(window.mailchimpSF.analytics_ajax_url, { 133 method: 'POST', 134 body: formData, 135 credentials: 'same-origin', 136 }).catch(() => {}); 137 } 138 } 139})();
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.