1const HSFormModule = (() => { 2 const handleFormReady = (event) => { 3 if (event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormReady') { 4 const inputsTel = document.querySelectorAll('input[type="tel"]'); 5 const selectFields = document.querySelectorAll('select.hs-input:not(.select2-hidden-accessible)'); 6 const btnsSubmit = document.querySelectorAll('.hs-form input[type=submit]'); 7 8 if (btnsSubmit.length > 0) { 9 btnsSubmit.forEach(button => { 10 button.addEventListener("click", () => disableButton(button)); 11 }); 12 } 13 14 if (selectFields.length > 0) { 15 selectFields.forEach(selectItem => { 16 if (typeof jQuery !== 'undefined') { 17 const selectParent = selectItem.closest('.modal') || document.body; 18 19 jQuery(selectItem).select2({ 20 dropdownParent: jQuery(selectParent) 21 }); 22 23 selectItem.parentElement.addEventListener("click", () => { 24 const searchField = document.querySelector('.select2-search__field'); 25 if (searchField) { 26 searchField.focus(); 27 } 28 }); 29 } else { 30 console.warn("jQuery is required for select2 plugin to function."); 31 } 32 }); 33 } 34 35 if (inputsTel.length > 0) { 36 const maskOptions = { 37 mask: '(000)000-0000' 38 }; 39 40 inputsTel.forEach(elem => IMask(elem, maskOptions)); 41 } 42 } 43 }; 44 45 const disableButton = (button) => { 46 const parent = button.closest('.actions'); 47 48 setTimeout(() => { 49 button.disabled = true; 50 parent.classList.add('is-disabled'); 51 }, 50); 52 53 setTimeout(() => { 54 button.disabled = false; 55 parent.classList.remove('is-disabled'); 56 }, 2500); 57 }; 58 59 const handleFormSubmitted = (event) => { 60 if (event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmitted') { 61 const refresh = `${window.location.protocol}//${window.location.host}${window.location.pathname}#success/${window.location.search}`; 62 window.history.pushState({ path: refresh }, '', refresh); 63 64 setTimeout(() => { 65 location.reload(); 66 }, 3000); 67 } 68 }; 69 70 const init = () => { 71 window.addEventListener('message', (event) => { 72 handleFormReady(event); 73 handleFormSubmitted(event); 74 }); 75 }; 76 77 return { init }; 78})(); 79 80// Initialize the module 81document.addEventListener('DOMContentLoaded', () => { 82 HSFormModule.init(); 83});
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.