1(function($){ 2function wpJS() { } 3function openNewTab(url, target = '_blank') { console.log('Opening in new tab.');const link = document.createElement('a'); link.href = url; link.target = target; link.rel = 'noopener noreferrer'; document.body.appendChild(link);link.click(); document.body.removeChild(link);} 4function scrollTo(th) { if(window.formScrolling==false) { window.formScrolling = true; var el = tar = tarTop = hdrPad = undefined, form = th.closest('form'); if($('#header').hasClass('scrolled') || $('#header-sticky').hasClass('header-sticky')) { var hdrID = 'sticky'; } else { var hdrID = 'container'; } var hdrPad = $('#header-'+hdrID).height() + 75; if($('html').hasClass('mobile')) { hdrPad = hdrPad - 50; } scrollTo($('html,body'),hdrPad,$('div.error.active')); if(th.parents('.modal').length) { var mdl = th.parents('.modal'); var mdlB = mdl.find('.modal-body'); var mdlD = mdl.find('.modal-dialog'), mdlE = mdl.find('div.error.active').first(); hdrPad = 0; var el = mdlD; if(mdlE.length>0) { var tar = mdlE; } else { var tar = form; } var tarTop = tar.offset().top - mdlB.offset().top; tar = undefined; } else { if($('#header').hasClass('scrolled') || $('#header-sticky').hasClass('header-sticky')) { var hdrID = 'sticky'; } else { var hdrID = 'container'; } var hdrPad = $('#header-'+hdrID).height() + 75; if($('html').hasClass('mobile')) { hdrPad = hdrPad - 50; } var el = $('html,body'); } if(tar == undefined) { var tar = th.closest('form').find('fieldset.active'); } if(tar != undefined && tar.length > 0 && tarTop == undefined) { var tarTop = tar.offset().top; if(el != undefined && tar != undefined && hdrPad != undefined) { el.animate({ scrollTop: tarTop - hdrPad }, 1000,function(){ window.formScrolling = false; }); } } } } window.formScrolling = false; 5function validateEmail(email) { const re = /^(([^<>()[\]\.,;:\s@"]+(\.[^<>()[\]\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(String(email).toLowerCase()); } 6 7function agentaAjaxFormValidation(th) 8{ 9 // console.log('agentaAjaxFormValidation'); 10 // console.log('th',th); console.log('th.find(fieldset)',th.find('fieldset')); 11 if(th.hasClass('fieldset-previous') || th.hasClass('fieldset-next')) { var form = th.closest('fieldset'); } else { var form = th.find('fieldset'); } 12 // WP-3341: was form.find('error') - no dot, so it selected an <error> element that does 13 // not exist and the reset never ran. Every field branch below sets .active in both 14 // directions, so the pass still converged; what did not clear was any .active raised 15 // from outside this function, notably the 'Invalid Email Address' that js/neverBounce.js 16 // writes on nb:result. A field corrected after that verdict kept the stale message until 17 // the next verdict landed. Scope is the fieldset, matching where the branches write. 18 form.find('.error').removeClass('active'); var formErr = 0; // console.log('form',form); 19 // console.log('th.find(input#oic)',th.find('input#oic').prop('checked')); 20 if(th.find('input#oic').prop('checked')==true) { th.find('input.form-submit').data('oic',1); /* th.find('input#oic').removeClass('error'); */ } 21 else { th.find('input.form-submit').data('oic',0); /* th.find('input#oic').addClass('error'); formErr++; */ } 22 // console.log('th.find(input.form-submit).data()',th.find('input.form-submit').data()); 23 form.find("input[type='text']:not(.search-bar),input[type='tel'],input[type='email'],input[type='radio'],input[type='checkbox'],input[type='hidden'],select,textarea").each(function(){ 24 var f = $(this), n = f.attr('name'); 25 // console.log('f',f); 26 // console.log('n',n); 27 if(f.is("input[type='text'],input[type='tel'],input[type='email'],input[type='hidden'],textarea:not(.g-recaptcha-response),select")) 28 { 29 if(f.hasClass('req')) 30 { 31 if(f.val().length==0) { f.closest('.form-field').find('.error').addClass('active'); formErr++; } 32 else { f.closest('.form-field').find('.error').removeClass('active'); } 33 } 34 } 35 else if(f.is("input[type='radio'],input[type='checkbox']")) 36 { 37 if(f.closest('.form-field').hasClass('req')) 38 { 39 if($('input[name="'+n+'"]:checked').length==0) { f.closest('.form-field').find('.error').addClass('active'); formErr++; } 40 else { f.closest('.form-field').find('.error').removeClass('active'); } 41 } 42 } 43 if(f.hasClass('phone-field') && f.hasClass('req')) 44 { 45 if(f.val().length<14) { f.closest('.form-field').find('.error').addClass('active'); formErr++; } 46 else { f.closest('.form-field').find('.error').removeClass('active'); } 47 } 48 if(n.indexOf('emailAddress') >0) 49 { 50 // One decision per email field, and exactly one writer to the .error div. 51 // Before this, the NeverBounce arm set .active for a rejected address and the regex 52 // arm below then cleared it again for anything syntactically valid, so an address 53 // NeverBounce had rejected blocked the submit with no message, no scroll cue and no 54 // request -- the form simply looked dead. Precedence is now: syntax, then the 55 // NeverBounce verdict, then 'still checking', then clear. 56 var ed = f.closest('.form-field').find('.error'); 57 // Stash the per-form authored copy ('Enter a valid email.') the first time we touch 58 // this div, so a NeverBounce message can be undone rather than lost for good.
59 if(ed.data('msg0')==undefined) { ed.data('msg0',ed.html()); } 60 // nb-r is written only by js/neverBounce.js. true = accepted, false = rejected, 61 // 'pending' = request in flight, undefined = the widget has never checked this value. 62 var nbOn = (f.data('nb')!=undefined && f.val().length>0), nbR = f.data('nb-r'); 63 if(f.hasClass('req') && !validateEmail(f.val())) 64 { 65 ed.html(ed.data('msg0')).addClass('active'); formErr++; 66 } 67 else if(nbOn && nbR===false) 68 { 69 ed.html('Invalid Email Address').addClass('active'); formErr++; 70 } 71 else if(nbOn && nbR!==true) 72 { 73 // Fail closed instead of skipping the check. nb:result lands ~500ms of 74 // debounce plus an API round trip after typing stops, and never lands at all on a 75 // browser-autofilled field that fired no input event, so the old 76 // 'nb-r!=undefined' guard let unverified addresses straight through. Block, force 77 // a check, and let the nb:result handler in js/neverBounce.js replay this submit. 78 ed.html('Checking email address…').addClass('active'); formErr++; 79 // Remember what to re-click, not just that we are waiting: on a multi-fieldset 80 // form th is the .fieldset-next button, and resuming on the final submit instead 81 // would skip the remaining steps. For a single-step form th is the form itself, 82 // whose submit input is the thing carrying the click handler. 83 var nbTrg = th.hasClass('fieldset-next') ? th : th.closest('form').find('input.form-submit').first(); 84 var nbForm = th.closest('form'); nbForm.data('nb-await',nbTrg); 85 // Bound the wait. Fail closed must not mean fail forever: a blocked CDN, a 86 // NeverBounce outage, or the widget re-dispatching its stale boolean-false 87 // response all end with no verdict ever arriving. Release the submit after 88 // 6s and treat the unresolved fields as accepted, which is the same call we 89 // make for an outright API error in js/neverBounce.js. nbResume() clears this. 90 if(nbForm.data('nb-timer')==undefined) 91 { 92 nbForm.data('nb-timer',setTimeout(function(){ 93 nbForm.removeData('nb-timer'); 94 var trg = nbForm.data('nb-await'); if(trg==undefined) { return; } 95 nbForm.removeData('nb-await'); 96 nbForm.find('[data-nb]').each(function(){ if($(this).data('nb-r')!==false) { $(this).data('nb-r',true); } }); 97 trg.trigger('click'); 98 },6000)); 99 } 100 if(f[0] && f[0].app && typeof f[0].app.forceUpdate === 'function') { f[0].app.forceUpdate(); } 101 } 102 else 103 { 104 ed.html(ed.data('msg0')).removeClass('active'); 105 } 106 } 107 }); 108 /* 109 if(formErr > 0) { 110 var hdrPad = 0; if($('html').hasClass('mobile')) { hdrPad = hdrPad - 15; } else { hdrPad = $('#header-container').outerHeight(); } 111 if(th.parents('.modal').length) { 112 var mdl = th.parents('.modal'); var mdlB = mdl.find('.modal-body'); 113 var mdlD = mdl.find('.modal-dialog'), mdlE = mdl.find('div.error.active').first(); 114 mdlD.animate({ scrollTop: mdlE.offset().top - mdlB.offset().top + hdrPad }, 1000); 115 } else { 116 if($('#header').hasClass('scrolled') || $('#header-sticky').hasClass('header-sticky')) { var hdrID = 'sticky'; } else { var hdrID = 'container'; } 117 var hdrPad = $('#header-'+hdrID).height() + 75; if($('html').hasClass('mobile')) { hdrPad = hdrPad - 50; } 118 $('html,body').animate({ scrollTop: $('div.error.active').offset().top - hdrPad - 50 }, 1000); 119 } 120 } 121 // console.log('formErr: '+formErr); 122 */ 123 window.formErr = formErr; 124 if(formErr > 0) { scrollTo(th); } 125 return formErr; 126} 127window.agentaAjaxFormValidation = agentaAjaxFormValidation; 128 129$("input[type='text'],input[type='tel'],input[type='email'],input[type='radio'],input[type='checkbox'],input[type='hidden'],select,textarea").off('keyup change'); 130$("input[type='text'],input[type='tel'],input[type='email'],input[type='radio'],input[type='checkbox'],input[type='hidden'],select,textarea").on('keyup change',function(e){ 131 if(e.keyCode!=9) { 132 if($(this).data('cls') != undefined) 133 { 134 var th = $(this), cls = th.data('cls'); 135 if(th.data('cls').length > 0) 136 { 137 var cls = th.data('cls'); 138 if(th.data('typ')=='eq') 139 { 140 if(th.is('input[type="checkbox"]')) // This validation includes ALL checkboxes 141 { 142 var chkV = []; th.closest('.form-field').find('input[type="checkbox"]:checked').each(function(){ chkV.push($(this).val()); }); chkV = chkV.join('|'); 143 if(th.prop('checked')==true && th.data('act')=='shw' && chkV == th.data('eq')) { $('.'+cls).removeClass('hide'); } 144 else if(th.prop('checked')==true && th.data('act')=='shw' && chkV != th.data('eq')) { $('.'+cls).addClass('hide'); } 145 else if(th.prop('checked')==false && th.data('act')=='shw' && chkV == th.data('eq')) { $('.'+cls).removeClass('hide'); } 146 else if(th.prop('checked')==false && th.data('act')=='shw' && chkV != th.data('eq')) { $('.'+cls).addClass('hide'); } 147 else if(th.prop('checked')==true && th.data('act')=='hid' && chkV == th.data('eq')) { $('.'+cls).addClass('hide'); } 148 else if(th.prop('checked')==true && th.data('act')=='hid' && chkV != th.data('eq')) { $('.'+cls).removeClass('hide'); } 149 else if(th.prop('checked')==false && th.data('act')=='hid' && chkV == th.data('eq')) { $('.'+cls).addClass('hide'); } 150 else if(th.prop('checked')==false && th.data('act')=='hid' && chkV != th.data('eq')) { $('.'+cls).removeClass('hide'); } 151 chkV = undefined; 152 } else { 153 if(th.data('act')=='shw' && th.val() == th.data('eq')) { $('.'+cls).removeClass('hide'); } 154 else if(th.data('act')=='shw' && th.val() != th.data('eq')) { $('.'+cls).addClass('hide'); } 155 if(th.data('act')=='hid' && th.val() == th.data('eq')) { $('.'+cls).addClass('hide'); } 156 else if(th.data('act')=='hid' && th.val() != th.data('eq')) { $('.'+cls).removeClass('hide'); } 157 } 158 } 159 else if(th.data('typ')=='inc') 160 { 161 if(th.is('input[type="checkbox"]')) 162 { 163 // console.log('checked: '+th.is(':checked')); console.log('act: '+th.data('act'));console.log('eq: '+th.data('eq')); 164 if(th.is(':checked')==true && th.data('act')=='shw' && th.val().includes(th.data('eq'))==true) { $('.'+cls).removeClass('hide'); } 165 else if(th.is(':checked')==false && th.data('act')=='shw' && th.val().includes(th.data('eq'))==true) { $('.'+cls).addClass('hide'); } 166 // else if(th.is(':checked')==true && th.data('act')=='shw' && th.val().includes(th.data('eq'))==false) { $('.'+cls).addClass('hide'); } 167 // else if(th.is(':checked')==false && th.data('act')=='shw' && th.val().includes(th.data('eq'))==false) { $('.'+cls).removeClass('hide'); } 168 169 if(th.is(':checked')==true && th.data('act')=='hid' && th.val().includes(th.data('eq'))==true) { $('.'+cls).addClass('hide'); } 170 else if(th.is(':checked')==false && th.data('act')=='hid' && th.val().includes(th.data('eq'))==true) { $('.'+cls).removeClass('hide'); } 171 // else if(th.is(':checked')==true && th.data('act')=='hid' && th.val().includes(th.data('eq'))==true) { $('.'+cls).addClass('hide'); } 172 // else if(th.is(':checked')==false && th.data('act')=='hid' && th.val().includes(th.data('eq'))==false) { $('.'+cls).removeClass('hide'); } 173 } else { 174 if(th.data('act')=='shw' && th.val().includes(th.data('eq'))==true) { $('.'+cls).removeClass('hide'); } 175 else if(th.data('act')=='shw' && th.val().includes(th.data('eq'))==false) { $('.'+cls).addClass('hide'); } 176 if(th.data('act')=='hid' && th.val().includes(th.data('eq'))==true) { $('.'+cls).addClass('hide'); } 177 else if(th.data('act')=='hid' && th.val().includes(th.data('eq'))==false) { $('.'+cls).removeClass('hide'); } 178 } 179 } 180 } 181 } 182 if(e.keyCode!=8) 183 { 184 var f = $(this), n = f.attr('name'); 185 if(f.is("input[type='text'],input[type='tel'],input[type='email'],input[type='hidden'],textarea:not(.g-recaptcha-response),select")) 186 { 187 if(f.hasClass('req')) 188 { 189 if(f.val().length!=0) { f.closest('.form-field').find('.error').removeClass('active'); } 190 } 191 if(f.is('select')) 192 { 193 $(this).removeClass('placeholder'); 194 $(this).removeClass('selectable-option'); 195 $(this).addClass($(this).find(':selected').attr('class')); 196 } 197 } 198 else if(f.is("input[type='radio'],input[type='checkbox']")) 199 { 200 if(f.closest('.form-field').hasClass('req')) 201 { 202 if($('input[name="'+n+'"]:checked').length!=0) { f.closest('.form-field').find('.error').removeClass('active'); } 203 } 204 } 205 if(f.is("input[type='tel']") && f.val().length > 1) 206 { 207 var num = $(this).val().replace(/\D/g,''); 208 if(num.substring(0,1)=='1') { $(this).val(num.substring(0,1)+' ('+num.substring(1,4)+') '+num.substring(4,7)+'-'+num.substring(7,11)); } 209 else { $(this).val('('+num.substring(0,3)+') '+num.substring(3,6)+'-'+num.substring(6,10)); } 210 //$(this).val(num.substring(0,1)+'('+num.substring(1,4)+') '+num.substring(4,7)+'-'+num.substring(7,11)); 211 } 212 } 213 } 214}); 215 216 217 218function agentaAjaxFormInit(form) 219{ 220 // console.log('agentaAjaxFormInit',form); 221 form.find("input[type='text'],input[type='tel'],input[type='email'],input[type='radio'],input[type='checkbox'],input[type='hidden'],select,textarea").each(function(i){ 222 if($(this).data() && $.isEmptyObject($(this).data()) == false) 223 { 224 var th = $(this), cls = th.data('cls'); 225 if(cls != undefined && cls.length > 0) 226 { 227 if($('.'+cls).length > 0 228 || $('.'+cls+' input[type=radio]').length > 0 229 || $('.'+cls+' select').length > 0 230 ) 231 { 232 // if(th.data('act')=='shw' && th.val() == th.data('eq')) { $('.'+cls).removeClass('hide'); } 233 // else if(th.data('act')=='shw' && th.val() != th.data('eq')) { $('.'+cls).addClass('hide'); } 234 // if(th.data('act')=='hid' && th.val() == th.data('eq')) { $('.'+cls).addClass('hide'); } 235 // else if(th.data('act')=='hid' && th.val() != th.data('eq')) { $('.'+cls).removeClass('hide'); } 236 } 237 } 238 } 239 }); 240 241 $.each(['utm_landing'],function(i,v){ 242 if(Cookies.get(v)!=undefined) 243 { 244 form.prepend('<input type="hidden" id="'+v+'" class="form-cookies" name="cookies['+v+']" value="'+Cookie
244s.get(v)+'">'); 245 } 246 }); 247 form.find('input[type=hidden].form-cookies').each(function(i){ 248 var f = $(this).attr('id'); var v = Cookies.get(f); 249 if(v != undefined && v.length > 0) { $(this).val(Cookies.get(f)); } 250 }); 251 // console.log('form',form); 252 form.find('fieldset .fieldset-previous, fieldset .fieldset-next').off('click'); 253 form.find('fieldset .fieldset-previous, fieldset .fieldset-next').on('click',function(){ 254 var th = $(this), d = th.data(); 255 // console.log('th',th); console.log('d',d); 256 var formErr = agentaAjaxFormValidation(th); window.formErr = formErr; // console.log('formErr',formErr); 257 var hdrPad = 0; if($('html').hasClass('mobile')) { hdrPad = hdrPad - 15; } else { hdrPad = $('#header-container').outerHeight(); } 258 if(th.hasClass('fieldset-next') && window.formErr==0 || th.hasClass('fieldset-previous')) 259 { 260 var form = th.closest('form'), dur = 250; 261 form.find('fieldset.active').removeClass('active',dur).addClass('inactive',0); 262 form.find('fieldset#fieldset-'+d.ts).removeClass('inactive',0).addClass('active',dur); 263 setTimeout(function(){ scrollTo(th); },dur+dur); 264 if(th.parents('.modal').length) { 265 var mdl = th.parents('.modal'); var mdlB = mdl.find('.modal-body'), mdlD = mdl.find('.modal-dialog'); 266 mdlD.animate({ scrollTop: form.offset().top - mdlB.offset().top + hdrPad }, 1000); 267 } else { 268 // console.log('hdrPad: '+hdrPad);console.log('form.offset().top: '+form.offset().top); 269 $('html,body').animate({ scrollTop: form.offset().top - hdrPad - 50 }, 1000); 270 } 271 } else { 272 if($('#header').hasClass('scrolled') || $('#header-sticky').hasClass('header-sticky')) { var hdrID = 'sticky'; } else { var hdrID = 'container'; } 273 var hdrPad = $('#header-'+hdrID).height() + 75; if($('html').hasClass('mobile')) { hdrPad = hdrPad - 50; } 274 $('html,body').animate({ scrollTop: $('div.error.active').offset().top - hdrPad }, 1000); 275 } 276 }); 277} 278window.agentaAjaxFormInit = agentaAjaxFormInit; 279 280 281 282function agentaAjaxFormEV(th,formData) 283{ 284 // console.log('agentaAjaxFormEV',formData); 285 var ev, f = $('form#'+formData.uid); 286 if(window.formErr==0) { 287 if(th.hasClass('evs-zb')) { 288 // console.log('zeroBounce loaded',formData); 289 var apiKey = 'c1590b69550f4b06b77cce7772c6cb27'; 290 $('form#'+formData.uid+ ' input.emailAddress-field').each(function(i,o) { var eA = $(this).val(); 291 $.ajax({'method':'GET','url':'https://api.zerobounce.net/v2/validate?api_key='+apiKey+'&email='+eA+'&ip_address=','dataType':'json'}).done(function(zbr) { 292 // console.log('zerobounce response'); console.log(zbr); 293 if(zbr.status == 'valid') { window.formErr = 0; agentaAjaxFormProcess(th,formData); } 294 else { 295 // console.log('zeroBounce invalid',zbr); 296 window.formErr++; f.parent().find('.mail-success').hide(); 297 f.closest('.form-field').find('.error').addClass('active'); 298 f.parent().find('.mail-fail').html('Invalid email address. Please verify your email address').show(); 299 f.find('input.form-submit').removeAttr('disabled'); return false; //form.trigger('submitFail'); 300 } 301 }); 302 }); 303 } 304 else { 305 agentaAjaxFormProcess(th,formData); 306 } 307 } 308 // if(eA != undefined) { return eA; } 309 // return ev; 310} 311 312 313function agentaAjaxFormData(th) 314{ 315 // console.log('agentaAjaxFormData',th); 316 var r ='', rd = 1, dur = 1500; 317 var formData = th.data(); 318 var f = $('form#'+formData.uid); 319 var submitBtn = f.find('input.form-submit'); 320 submitBtn.attr('disabled','disabled'); var sbData = submitBtn.data(); 321 formData.action = 'formBox'; // console.log('sbData',sbData); 322 if(sbData.r != undefined) { var r = formData.r = sbData.r; } else { var r = ''; } 323 if(sbData.rd != undefined) { rd = formData.rd = sbData.rd; } 324 if(sbData.rt != undefined) { rt = formData.rt = sbData.rt; } else { rt = '_self'; } 325 if(r == undefined) { formData.rd = undefined; formData.rt = undefined; } 326 f.find("input[type='text']:not(.search-bar),input[type='tel'],input[type='email'],input[type='hidden'],input[type='radio']:checked,input[type='checkbox']:checked,select,textarea").each(function(){ 327 var v = ''; 328 var t = $(this); // console.log('t',t); 329 // Check when t is a select with the multiple attribute 330 if (t.is('select[multiple]')) { 331 // console.log('select[multiple]'); 332 v = t.val(); // console.log('v [multiple]: ',v); 333 // If the value is null, set it to an empty string 334 if (v == null) { v = ''; } 335 } else { 336 v = t.val().trim(); // console.log('v',v); console.log('v.length',v.length); 337 } 338 var k = t.attr('name'); // console.log('k',k); 339 if(v.length > 0 && k.indexOf('[]') >= 0) 340 { 341 var an = k.substring(0,k.length-2); 342 if(typeof formData[an] == 'undefined' || !(formData[an] instanceof Array)) { formData[an] = []; } 343 formData[an].push(v); 344 } 345 else 346 { 347 formData[k] = v; 348 } 349 }); 350 // console.log('formData-jsFormData',formData); 351 return formData; 352} 353 354 355function agentaAjaxResend(formData,uid) 356{ 357 var f = $('form#'+uid); formData.a = 'resend'; formData.agenta2fa =''; 358 f.find('fieldset.auth-box div.mail-auth-container input#agenta2fa').val(''); 359 console.log('agentaAjaxResend uid',uid); console.log('agentaAjaxResend formData',formData); 360 $.ajax({'url':wpAJX.ajaxurl,'method':'post','dataType':'json','data':formData}).done(function(j) { 361 window[uid+'_reset'](); formData.a = 'auth'; console.log('agentaAjaxResend j',j); 362 }); 363} 364 365function agentaAjaxFormProcess(th,formData) 366{ 367 // console.log('agentaAjaxFormProcess:',formData); 368 $.ajax({'url':wpAJX.ajaxurl,'method':'post','dataType':'json','data':formData}).done(function(j) { 369 var f = $('form#'+formData.uid); var rd = 1, dur = 1500; 370 if(formData.r != undefined) { var r = formData.r;} else { var r = ''; } 371 if(formData.rd != undefined) { rd = formData.rd; } 372 if(formData.rt != undefined) { rt = formData.rt; } else { rt = '_self'; } 373 // console.log('j:',j);
373 console.log(f); console.log(f.find('fieldset.auth-box').length); 374 if(f.find('fieldset.auth-box').length == 1 && j.success=='auth') 375 { 376 window[formData.uid+'_reset'](); 377 // console.log(f.find('fieldset.active')); 378 f.find('fieldset:not(.auth-box).active').removeClass('active',dur).addClass('inactive',0); 379 f.find('fieldset.auth-box div.mail-auth-container .verif').html(j.message).show(); 380 f.find('fieldset.auth-box').removeClass('inactive'); 381 f.find('fieldset.auth-box div.mail-auth-container input#sms2fa').attr('type','text'); 382 f.find('fieldset.auth-box div.mail-auth-container input#agenta2fa').attr('type','text'); 383 f.find('fieldset.auth-box div.mail-auth-container .submsg').html(j.submsg).show(); 384 f.find('fieldset.auth-box div.mail-auth-container').show(); 385 f.find('fieldset.auth-box input.form-submit').removeAttr('disabled'); 386 f.find('fieldset.auth-box input.form-submit').val('Submit'); 387 f.find('fieldset.auth-box').addClass('active'); 388 var resend = f.find('fieldset.auth-box a.resend'); resend.off('click'); 389 resend.on('click',function(){ agentaAjaxResend(formData,formData.uid); return false; }); 390 f.find('fieldset.auth-box').addClass('active'); 391 } 392 else if(j.success==false) 393 { 394 f.parent().find('.mail-success').hide(); 395 f.parent().find('.mail-fail').html(j.message).show(); 396 f.find('input.form-submit').removeAttr('disabled'); 397 //form.trigger('submitFail'); 398 } 399 else if(j.success==true) 400 { 401 var form = th.closest('form'); 402 form.find('.mail-fail').hide(); 403 form.find('.mail-success').html(j.message).show(); 404 // form.find('input[type='text'],input[type='tel'],input[type='hidden']:not(.overrides),select,textarea').val(''); 405 form.find('input[type=text],input[type=tel],input[type=email],select,textarea').val(''); 406 form.find('input[type=radio],input[type=checkbox]').prop('checked',false); 407 fieldsets = form.find('fieldset'); 408 if(fieldsets.length>0) 409 { 410 form.find('fieldset.active').removeClass('active',dur).addClass('inactive',0); 411 fieldsets.first().removeClass('inactive',0).addClass('active',dur); 412 } 413 if(form.closest('.modal').hasClass('show')) 414 { 415 setTimeout(function(){ 416 form.closest('.modal').modal('hide'); 417 $('.modal-backdrop').each(function(){ $(this).remove(); }); 418 //form.closest('.modal').find('span.icon-close').trigger('click'); 419 },2000); 420 } 421 form.trigger('submitSuccess'); // 422 // console.log('th',th);console.log('formData',formData); 423 if(window.dataLayer == undefined) { window.dataLayer = []; } 424 if(form.closest('div.modal.agenta-modal') != undefined) { 425 var mdl = form.closest('div.modal.agenta-modal'); 426 var fcv = mdl.data('frmcomp'); 427 if(fcv != undefined) { 428 document.cookie = fcv+"-form-complete=true;expires=36500; path=/"; 429 } 430 } 431 if(f.closest('div.modal') != undefined && f.closest('div.modal').data('frequency')=='UC') { document.cookie = f.closest('div.modal').attr('id')+"=true;expires=36500; path=/"; } 432 if(window[formData.uid+'_pushEvent'] != undefined) { window.dataLayer.push({'event': window[formData.uid+'_pushEvent']}); /* console.log('Event: '+window[formData.uid+'_pushEvent']); */ } 433 if(window[formData.uid+'_resetAdTrack'] != undefined && window[formData.uid+'_resetAdTrack'] == true) { Cookies.set('ad-gate', 'false', { expires: 30 }); Cookies.set('ad-goal-passed', 'true', { expires: 30 }); Cookies.set('ad-track', false, { expires: 30 }); /* console.log('Ad Tracking Reset'); */ } 434 } 435 if(j.success==true && r != undefined && r.length>0) { 436 // console.log('r',r);console.log('rd',rd);console.log('rt',rt); 437 if($('html').hasClass('ios') && $('html').hasClass('safari')) { 438 // $('form#'+formData.uid+' .submit').append('<a class="hid" href="'+r+'" target="'+rt+'">.</a>'); 439 // setTimeout(function(){ $('form#'+formData.uid+' .submit a').trigger('click'); },rd); 440 // if(rt != undefined) { setTimeout(function(){ window.open(r,rt); },rd); } 441 if(rt != undefined) { 442 setTimeout(function(){ 443 const newTab = window.open(r, rt); 444 // If the new tab is blocked, newTab's value will be null or undefined. It will be blocked if the browser is set to block popups. 445 if (newTab === null || newTab === undefined) { 446 console.log('New tab was blocked, using window.location as fallback.'); 447 window.location = r; // Fallback: redirect in the same tab 448 } 449 },rd); 450 } else { 451 setTimeout(function(){ 452 window.location=r; 453 },rd); 454 } 455 } else { 456 if(rt != undefined) { setTimeout(function(){ openNewTab(r,rt); },rd); } 457 else { setTimeout(function(){ window.location=r; },rd); } 458 } 459 } 460 f.find('input.form-submit').removeAttr('disabled'); 461 }); 462} 463 464 465function agentaAjaxFormSubmit(th) 466{ 467 // console.log(th); 468 // console.log('agentaAjaxFormSubmit'); 469 var formData = agentaAjaxFormData(th); 470 var rd = 1, dur = 1500; formData = th.data(); 471 formData.action = 'formBox'; var f = $('form#'+formData.uid); 472 if(formData.r != undefined) { var r = formData.r; } else { var r = ''; } 473 if(formData.rd != undefined) { rd = formData.rd; } 474 if(formData.rt != undefined) { rt = formData.rt; } else { rt = '_self'; } 475 // console.log('window.formErr:',window.formErr); 476 if(window.formErr==0) { agentaAjaxFormEV(th,formData); } 477} 478window.agentaAjaxFormSubmit = agentaAjaxFormSubmit; 479 480})(jQuery);
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.