芝麻web文件管理V1.00
编辑当前文件:/home/ephorei/www/wp-content/plugins/sureforms/assets/js/minified/blocks/phone.min.js
function initializePhoneField(){document.querySelectorAll(".srfm-phone-block").forEach(e=>{const i=e.querySelector(".srfm-input-phone"),n=e.querySelector(".srfm-error-message");var t=i.getAttribute("auto-country");const r=i.getAttribute("name");var o={autoPlaceholder:"off",separateDialCode:!0,hiddenInput:()=>({phone:r}),countrySearch:!0,initialCountry:"us"};"true"===t&&(o.initialCountry="auto",o.geoIpLookup=function(t){fetch("https://ipapi.co/json").then(function(e){return e.json()}).then(function(e){t(e.country_code)}).catch(function(){t("us")})});const s=window.intlTelInput(i,o),a=s?.countryList.querySelectorAll(".iti__country");t=e.querySelector(".iti__selected-country-primary"),srfm_submit?.is_rtl?t.style.paddingLeft="0":t.style.paddingRight="0",o=()=>{var e=i?.value?i?.value.trim():"",t=i.closest(".srfm-block");e&&!s._utilsIsValidNumber(s.getNumber())?(t.classList.add("srfm-phone-error"),window?.srfm?.toggleErrorState(t,!0),n.textContent=window?.srfm_submit?.messages?.srfm_valid_phone_number,s.hiddenInput.value=s.telInput.value):(t.classList.remove("srfm-phone-error"),window?.srfm?.toggleErrorState(t,!1),s.hiddenInput.value=s.getNumber())},t=s.telInput.getAttribute("data-unique");t&&s.hiddenInput.setAttribute("data-unique",""+t),i&&(i.addEventListener("change",o),i.addEventListener("countrychange",o),i.addEventListener("open:countrydropdown",()=>{var e=s.getSelectedCountryData();e&&(a.forEach(e=>{e.classList.contains("iti__active")&&e.classList.remove("iti__active")}),e=s?.countryList.querySelector(`.iti__country[data-country-code="${e.iso2}"]`))&&(e.classList.add("iti__active"),e.scrollIntoView({block:"nearest",behavior:"instant"}))})),itiContainerClass(e)})}function isMobileDevice(){return window.innerWidth<=768}function itiContainerClass(e){if(isMobileDevice()){const t=e.closest("form").getAttribute("form-id");e.querySelector(".iti__selected-country").addEventListener("click",()=>{document.querySelector(".iti--container")?.classList.add("srfm-form-container-"+t)})}}window.srfmInitializePhoneField=initializePhoneField,document.addEventListener("DOMContentLoaded",initializePhoneField);