PluginProbe
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management / 1.4.0
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management v1.4.0
1.6.1 1.6.0 1.5.1 1.5.0 1.4.0 1.3.0 trunk 0.0.1 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0
suredonation / assets / build / blocks / phone / frontend.js

frontend.js in SureDonation – Donation Forms, Fundraising Campaigns & Donor Management 1.4.0, at assets/build/blocks/phone/frontend.js

1 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{"use strict";const e=["us","gb","ca","au","in","de","fr"];function t(t=document){"function"==typeof window.intlTelInput&&t.querySelectorAll(".sd-phone-block").forEach(t=>{const n=t.querySelector(".sd-input-phone"),r=t.querySelector(".sd-phone-hidden");if(!n||!r)return;if("true"===n.dataset.sdPhoneInitialized)return;n.dataset.sdPhoneInitialized="true";const d=n.getAttribute("data-default-country"),i=n.getAttribute("data-enable-country-filter"),u=n.getAttribute("data-country-filter-type"),o=n.getAttribute("data-include-countries"),s=n.getAttribute("data-exclude-countries");let a=[],l=[];if("true"===i)try{"include"===u&&o&&(a=JSON.parse(o)),"exclude"===u&&s&&(l=JSON.parse(s))}catch(e){}let c=d||"us";c=function(t,n,r,d=[],i=[]){if(!0!==n&&"true"!==n)return t;const u=Array.isArray(d)?d:[],o=Array.isArray(i)?i:[],s=(t||"").toLowerCase();return"include"===r&&u.length>0?u.includes(s)?s:u[0]:"exclude"===r&&o.length>0?o.includes(s)&&e.find(e=>!o.includes(e))||s:t}(c,i,u,a,l);const h={autoPlaceholder:"off",separateDialCode:!0,countrySearch:!0,initialCountry:c};"true"===i&&("include"===u&&a.length>0?h.onlyCountries=a:"exclude"===u&&l.length>0&&(h.excludeCountries=l));const y=window.intlTelInput(n,h),f=()=>{r.value=y.getNumber()||""},p=()=>{f(),r.dispatchEvent(new Event("blur",{bubbles:!0}))};n.addEventListener("input",f),n.addEventListener("blur",p),n.addEventListener("countrychange",p),n.sdIti=y,n.sdPhoneHandlers={input:f,blur:p,countrychange:p};const b=t.querySelector(".iti__selected-dial-code");b&&b.setAttribute("aria-hidden","true")})}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>t()):t(),window.suredonationInitPhoneFields=t,window.suredonationDestroyPhoneFields=function(e=document){e.querySelectorAll(".sd-input-phone").forEach(e=>{const t=e.sdPhoneHandlers;t&&(e.removeEventListener("input",t.input),e.removeEventListener("blur",t.blur),e.removeEventListener("countrychange",t.countrychange),delete e.sdPhoneHandlers),e.sdIti&&"function"==typeof e.sdIti.destroy&&(e.sdIti.destroy(),delete e.sdIti),delete e.dataset.sdPhoneInitialized})}})();