1document.addEventListener('DOMContentLoaded', function() { 2 if(typeof gform == "undefined") { 3 return; 4 } 5 gform.utils.addAsyncFilter('gform/ajax/post_ajax_submission', async (data) => { 6 // validation_messages is only set when the submission failed validation. 7 // On a successful submit it is absent, and Object.keys(undefined) threw 8 // here -- rejecting this filter's promise and aborting the rest of GF's 9 // post-submission handling. is_different_email_error() below already 10 // guards the same property the same way. 11 const validation_messages = data?.submissionResult?.data?.validation_messages; 12 const message_keys = validation_messages ? Object.keys(validation_messages) : []; 13 if(message_keys.length > 0) { 14 scroll_to_first_error(message_keys[0]); 15 } 16 /* 17 if(is_different_email_error(data.submissionResult)) { 18 show_confirmation_lightbox(data.submissionResult.data.validation_messages[5]); 19 } 20 */ 21 return data; 22 }); 23}); 24 25 26function scroll_to_first_error(input_id) { 27 const form_field = document.querySelector('[name="input_' + input_id + '"]'); 28 if(form_field) { 29 const wrapper = form_field.closest('.gform-body'); 30 if(wrapper) { 31 wrapper.scrollIntoView({ behavior: 'smooth', block: 'start' }); 32 } 33 } 34} 35 36 37function show_confirmation_lightbox(message) { 38 const lightbox = document.createElement('div'); 39 lightbox.classList.add('sfdora-validation-lightbox'); 40 41 lightbox.innerHTML = ` 42 <div class="lightbox-content"> 43 <p>${message}</p> 44 <button class="update-signature-details button">Update Signature Details</button> 45 <button class="close-lightbox button">Close</button>
46 </div> 47 `; 48 document.body.appendChild(lightbox); 49 document.querySelector('.close-lightbox').addEventListener('click', function() { 50 document.body.removeChild(lightbox); 51 }); 52 document.querySelector('.update-signature-details').addEventListener('click', function() { 53 document.getElementById('input_12_17').value = 'Yes'; 54 document.body.removeChild(lightbox); 55 document.querySelector('.gform_button').click(); 56 }); 57} 58 59function is_different_email_error(submission_result) { 60 if(submission_result.data.validation_messages && submission_result.data.validation_messages.hasOwnProperty(5)) { 61 if(submission_result.data.validation_messages[5].includes('update the details in our records')) { 62 return true; 63 } 64 } 65}
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.