1// Form Logic: Corporate form utilities 2// Dependencies: helpers.js (swGetCookie, swCountryOptinToggle, swFieldListeners) 3// validation.js (swEmailValidationInit, swPhoneValidationInit) 4// 5// Provides: 6// - isEmailValid â global email-valid state read by swEmailValidationInit() 7// - checkSubmitButton â enables/disables the submit button based on state 8// - sw19_corp_form_button_disable â disables button on native form submit 9// - set_zoriana_cookies â syncs Adobe Launch / UTM cookie values into hidden inputs 10// 11// Submit handling for all form types has moved to signup.js. 12 13// Global state read and written by swEmailValidationInit() in validation.js. 14let isEmailValid = false; 15 16function sw19_corp_form_button_disable() { 17 var form = document.querySelector("form.sw19s-corp-form"); 18 if (!form) return; 19 var button = form.querySelector('.sw19s-btn[type="submit"]'); 20 var ssa_checkbox = 21 form.querySelector(".terms input") || 22 form.querySelector(".terms-text input"); 23 if (!button || !ssa_checkbox) return; 24 25 form.addEventListener("submit", function () { 26 button.disabled = true; 27 }); 28 29 ssa_checkbox.addEventListener("click", checkSubmitButton); 30 checkSubmitButton(); 31} 32 33function set_zoriana_cookies() { 34 const cookieNames = new Map([ 35 ["cookies-RefUrl", "ExternalReferrer"], 36 ["cookies-TrafficType", "TrackingCode"], 37 ["_gcl_aw", "GoogleClickId"], 38 ["_uetmsclkid", "MicrosoftClickId"], 39 ["_ga", "GoogleAnalyticsClientId"], 40 ["SWI_UTM_source_first", "UTMSourceFirst"],
41 ["SWI_UTM_medium_first", "UTMMediumFirst"], 42 ["SWI_UTM_campaign_first", "UTMCampaignFirst"], 43 ["SWI_UTM_term_first", "UTMTermFirst"], 44 ["SWI_UTM_content_first", "UTMContentFirst"], 45 ["SWI_UTM_source_most_recent", "UTMSourceMostRecent"], 46 ["SWI_UTM_medium_most_recent", "UTMMediumMostRecent"], 47 ["SWI_UTM_campaign_most_recent", "UTMCampaignMostRecent"], 48 ["SWI_UTM_term_most_recent", "UTMTermMostRecent"], 49 ["SWI_UTM_content_most_recent", "UTMContentMostRecent"] 50 ]); 51 52 const cookieData = {}; 53 cookieNames.forEach(function (value, name) { 54 cookieData[value] = 55 (typeof _satellite !== "undefined" ? _satellite.getVar(name) : null) || 56 swGetCookie(name) || 57 ""; 58 }); 59 60 const zorianaCookiesInput = document.querySelector( 61 'input[name="sw19_zoriana_cookies_basket"]' 62 ); 63 if (zorianaCookiesInput) { 64 zorianaCookiesInput.value = JSON.stringify(cookieData); 65 } 66} 67 68function checkSubmitButton() { 69 const submitButton = document.querySelector('.sw19s-btn[type="submit"]'); 70 if (!submitButton) return; 71 72 if (typeof _satellite !== "undefined") { 73 const refUrlInput = document.querySelector( 74 'input[name="sw19_cookies-RefUrl"]' 75 ); 76 const trafficInput = document.querySelector( 77 'input[name="sw19_cookies-TrafficType"]' 78 ); 79 if (refUrlInput) refUrlInput.value = _satellite.getVar("cookies-RefUrl"); 80 if (trafficInput) 81 trafficInput.value = _satellite.getVar("cookies-TrafficType"); 82 set_zoriana_cookies(); 83 } 84 85 const ssaCheckbox = 86 document.querySelector(".terms input") || 87 document.querySelector(".terms-text input"); 88 89 if (!ssaCheckbox && isEmailValid) { 90 submitButton.disabled = false; 91 submitButton.classList.remove("disabled"); 92 return; 93 } 94 95 if (ssaCheckbox && ssaCheckbox.checked && isEmailValid) { 96 submitButton.disabled = false; 97 submitButton.classList.remove("disabled"); 98 } 99} 100 101function initCorpForm() { 102 const form = document.querySelector("form.sw19s-corp-form"); 103 if (!form) return; 104 105 sw19_corp_form_button_disable(); 106 107 // Country optin â uses swCountryOptinToggle from helpers.js 108 const countryDrop = form.querySelector("select.country-picker"); 109 if (countryDrop) { 110 swCountryOptinToggle(form); 111 countryDrop.addEventListener("change", function () { 112 swCountryOptinToggle(form); 113 }); 114 } 115 116 // Field UX listeners â uses swFieldListeners from helpers.js 117 swFieldListeners(form); 118 119 // Phone and email validation â uses functions from validation.js 120 swPhoneValidationInit(form); 121 swEmailValidationInit(form); 122} 123 124if (document.readyState === "loading") { 125 document.addEventListener("DOMContentLoaded", initCorpForm); 126} else { 127 initCorpForm(); 128}
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.