1(function($){"use strict" 2window.AEWPFrontEnd={forms:[],validCountry:false,init:function(){var _this=this 3$('.ae-cform-modal-container, .ae-cform-container:not(.-has-modal)').each(function(i,form){var formID=$(form).attr('data-ae-cform-id') 4const hash=$(form).attr('data-hash-selector') 5if(typeof _this.forms[formID]==='undefined'){_this.forms[formID]=[]} 6if(typeof _this.forms[formID]['hashSelectors']==='undefined'){_this.forms[formID]['hashSelectors']={}} 7_this.forms[formID]['hashSelectors'][hash]=[] 8var relatedFields=$(form).find('input[type="checkbox"][data-ae-optin-id][data-ae-optin-related-field]');if(relatedFields.length){$(relatedFields).each(function(index){var customFormId=$(this).data('ae-cform-id');var relatedField=$(this).data('ae-optin-related-field');if(relatedField==='mobilephone'&&_this.forms[formID]['hashSelectors'][hash].telInput===undefined){var dynamicField=$(form).find('#ae-cform-reg-item-'+relatedField+'-'+customFormId) 9_this.forms[formID]['hashSelectors'][hash].telInput=dynamicField.find('input');if(_this.forms[formID]['hashSelectors'][hash].telInput.length>0){const{smsCountries}=intlTelInputData;const formSmsCountries=smsCountries[formID] 10const onlyCountries=!formSmsCountries||formSmsCountries?.length===0||formSmsCountries?.includes("all")?[]:formSmsCountries;_this.forms[formID]['hashSelectors'][hash].iti=window.intlTelInput(_this.forms[formID]['hashSelectors'][hash].telInput[0],{separateDialCode:true,autoPlaceholder:"off",initialCountry:_this.setDefaultCountryCode(),onlyCountries});_this.forms[formID]['hashSelectors'][hash].telInput.addClass('mobilephone-input-initial')} 11if((!window.AEJSWP||!window.AEJSWP['customForms'][formID].smsOptinCountries||!window.AEJSWP['customForms'][formID].smsOptinCountries.includes('all'))&&typeof relatedField!=='undefined'){var dynamic_field_visible=$(dynamicField).data('dynamic-field-visibility')==='visible' 12if(dynamic_field_visible){_this.toggleSmsOptin(false,form)}} 13_this.addEventListeners(form)}});} 14$(form).find('input[type="checkbox"][data-ae-optin-id][data-email]:checked').change(function(){_this.setEmailRequired(form)}) 15_this.setEmailRequired(form)})},setDefaultCountryCode:function(){if(typeof gr_global_vars!=='undefined'){switch(gr_global_vars['siteTerritory']){case'uk':return'gb';case'au':return'au';default:return'';}}else{return'';}},addPaddingTelInput:function(formID,hash){var paddingLeft=this.forms[formID]['hashSelectors'][hash].iti.selectedFlag.offsetWidth+6 16this.forms[formID]['hashSelectors'][hash].iti.a.style.paddingLeft=paddingLeft+'px'},addEventListeners:function(form){var _this=this 17const formID=$(form).data('ae-cform-id');const hash=$(form).data('hash-selector');if(this.forms[formID]['hashSelectors'][hash].iti){$(form).find('a[data-ae-cform-social-button-service-id="email"]').click(function(){_this.addPaddingTelInput(formID,hash)}) 18$(form).on('ae-modal-open',function(){_this.addPaddingTelInput(formID,hash)})} 19$(this.forms[formID]['hashSelectors'][hash].telInput).on('input change',function(){_this.validateInput(this,form)}) 20$(this.forms[formID]['hashSelectors'][hash].telInput).on('change',function(){_this.forms[formID]['hashSelectors'][hash].telInput.removeClass('mobilephone-input-initial')}) 21$(this.forms[formID]['hashSelectors'][hash].telInput).on('focus',function(){_this.forms[formID]['hashSelectors'][hash].telInput.removeClass('mobilephone-input-initial') 22var width=_this.forms[formID]['hashSelectors'][hash].telInput.closest('.iti--separate-dial-code').find('.iti__flag-container').width();if(width>0){width+=10;_this.forms[formID]['hashSelectors'][hash].telInput.css('padding-left',width+'px');}}) 23$(form).find('.ae-cform-input-country').on('change',function(){_this.changeNumberCountry(this,formID,hash) 24_this.validateCountry(this,form) 25_this.validateInput(this,form)}) 26$(form).find('input[type="checkbox"][data-ae-optin-id][data-sms]').on('change',function(){_this.validateInput(this,form)}) 27if(this.forms[formID]['hashSelectors'][hash].telInput&&this.forms[formID]['hashSelectors'][hash].telInput.length>0){this.forms[formID]['hashSelectors'][hash].telInput[0].addEventListener("close:countrydropdown",function(){_this.forms[formID]['hashSelectors'][hash].numberCountryChanged=true 28_this.validateCountry($(form).find('.ae-cform-input-country'),form);_this.validateInput(this,form);});}}
28,validateInput:function(el,form){const formID=$(form).data('ae-cform-id');const hash=$(form).data('hash-selector');var _this=this;var tmpCountryData=this.forms[formID]['hashSelectors'][hash].iti.getSelectedCountryData();var setSelectedCountryCode=tmpCountryData.iso2.toUpperCase();var checkAreaCodeCountryValid=this.isAreaCodeCountrySupported(setSelectedCountryCode,form);var $labelElement=$(el).parents('.iti').parent() 29var $parsleyErrorList=$labelElement.find('.parsley-errors-list-custom') 30var smsCheckboxStatus=false;$(form).find('input[type="checkbox"][data-ae-optin-id][data-sms]').each(function(){var smsStatus=$(this).prop('checked');smsCheckboxStatus=smsStatus;if(true===smsStatus){const parentDiv=this.closest('div');const existingErrorDiv=parentDiv.querySelector('.error-div');if(existingErrorDiv&&_this.validCountry&&checkAreaCodeCountryValid){parentDiv.removeChild(existingErrorDiv);}else if((!_this.validCountry||!checkAreaCodeCountryValid)&&null===existingErrorDiv){const errorDiv=document.createElement('div');errorDiv.className='error-div ae-cform-item';errorDiv.innerHTML='<ul class="parsley-errors-list"><li>SMS updates are available within valid countries only</li></ul>';parentDiv.appendChild(errorDiv);_this.toggleSmsOptin(false,form,true);}}});if($(el).val().length===0&&(!_this.validCountry||!checkAreaCodeCountryValid)){this.toggleSmsOptin(false,form) 31return}else if(this.isCountrySupported(el,form)&&_this.validCountry&&checkAreaCodeCountryValid){this.toggleSmsOptin(true,form,false)} 32if((this.forms[formID]['hashSelectors'][hash].iti.getValidationError() 33!==intlTelInputUtils.validationError.IS_POSSIBLE&&true===smsCheckboxStatus)){var parsleyId=$(el).data('parsley-id') 34var errorMsg=$(el).data('error-msg') 35if($parsleyErrorList.length){$($parsleyErrorList).empty().append(`<li class="parsley-error parsley-custom-error-message">${errorMsg}.</li>`)}else{$labelElement.append(`<ul class="parsley-errors-list parsley-errors-list-custom filled" id="parsley-id-${parsleyId}"><li class="parsley-error parsley-custom-error-message">${errorMsg}.</li></ul>`)}}else{if($parsleyErrorList.length){$parsleyErrorList.remove()}else if(jQuery('.ae-cform-item-mobilephone').find('.parsley-errors-list').length){jQuery('.ae-cform-item-mobilephone').find('.parsley-errors-list').remove();}}},setEmailRequired:function(form){const formID=$(form).data('cform-id');if($(form).find('input[type="checkbox"][data-ae-optin-id][data-email]:checked').length>0){$(form).find(`#ae-cform-input-reg-email-${formID}`).attr('required',true) 36$(form).find(`#ae-cform-input-reg-email-${formID}`).parents('.ae-cform-item').find('label .cform-required-field').removeClass('hidden').find('span:first').removeClass('hidden')}else{$(form).find(`#ae-cform-input-reg-email-${formID}`).attr('required',false) 37$(form).find(`#ae-cform-input-reg-email-1${formID}`).parents('.ae-cform-item').find('label .cform-required-field').addClass('hidden').find('span:first').addClass('hidden')}},toggleSmsOptin:function(enable,form,forceRequired=true){var _this=this 38const formID=$(form).data('ae-cform-id');const hash=$(form).data('hash-selector');$(form).find('input[type="checkbox"][data-ae-optin-id][data-sms]').each(function(){var smsOptin=$(this);if(enable){$(smsOptin).attr('disabled',false) 39$(smsOptin).parent().find('span.ae-cform-optin-label').css('opacity',1) 40if(forceRequired){var inputRequired=$(smsOptin).is(':enabled')&&$(smsOptin).is(':checked') 41$(_this.forms[formID]['hashSelectors'][hash].telInput).attr('required',inputRequired) 42if(inputRequired){$(_this.forms[formID]['hashSelectors'][hash].telInput).parents('.ae-cform-item').find('label .cform-required-field').removeClass('hidden').find('span:first').removeClass('hidden')}}}else{$(smsOptin).attr('disabled',true) 43$(smsOptin).prop('checked',false) 44$(smsOptin).parent().find('span.ae-cform-optin-label').css('opacity',0.6) 45if(forceRequired){$(_this.forms[formID]['hashSelectors'][hash].telInput).attr('required',false) 46$(_this.forms[formID]['hashSelectors'][hash].telInput).parents('.ae-cform-item').find('label .cform-required-field').addClass('hidden').find('span:first').addClass('hidden')}}});},isCountrySupported:function(elem,form){const formID=$(form).data('ae-cform-id');var $selectedCountry=$(elem).val() 47if(($selectedCountry==='UM'&&window.AEJSWP.customForms[formID].smsOptinCountries.includes('US'))||($selectedCountry==='US'&&window.AEJSWP.customForms[formID].smsOptinCountries.includes('UM'))) 48return true 49return!(!window.AEJSWP||!window.AEJSWP.customForms[formID].smsOptinCountries||(!window.AEJSWP.customForms[formID].smsOptinCountries.includes($selectedCountry)&&!window.AEJSWP.customForms[formID].smsOptinCountries.includes('all')));},isAreaCodeCountrySupported:function(areaCodeCountry='',form){const formID=$(form).data('ae-cform-id');if((areaCodeCountry==='UM'&&window.AEJSWP.customForms[formID].smsOptinCountries.includes('US'))||(areaCodeCountry==='US'&&window.AEJSWP.customForms[formID].smsOptinCountries.includes('UM'))) 50return true 51return!(!window.AEJSWP||!window.AEJSWP.customForms[formID].smsOptinCountries||(!window.AEJSWP.customForms[formID].smsOptinCountries.includes(areaCodeCountry)&&!window.AEJSWP.customForms[formID].smsOptinCountries.includes('all')));},validateCountry:function(elem,form){const formID=$(form).data('ae-cform-id');const hash=$(form).data('hash-selector');var _this=this;if(this.isCountrySupported(elem,form)){var $selectedCountry=$(elem).val().toLowerCase() 52if($selectedCountry==='um'&&this.forms[formID]['hashSelectors'][hash].iti.getSelectedCountryData().iso2==='us'){this.toggleSmsOptin(true,form)}else if($(elem).val().toLowerCase()===this.forms[formID]['hashSelectors'][hash].iti.getSelectedCountryData().iso2){this.toggleSmsOptin(true,form)}else{this.toggleSmsOptin(false,form)} 53_this.validCountry=true;}else{this.toggleSmsOptin(false,form) 54_this.validCountry=false;_this.validateInput(this.forms[formID]['hashSelectors'][hash].telInput,form);}},changeNumberCountry:function(elem,formID,hash){if(typeof elem!=='undefined'&&$(elem).val()!==''&&this.forms[formID]['hashSelectors'][hash].numberCountryChanged!==true){this.forms[formID]['hashSelectors'][hash].iti.setCountry($(elem).val())}},} 55$(document).ready(function(){AEWPFrontEnd.init()})})(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.