| 1 |
(()=>{function e(e){e&&window.wp?.a11y?.speak&&window.wp.a11y.speak(String(e))}function t(e){const t=e.closest(".sd-block-single")?.querySelector(".ts-control"),o=t?.querySelector("input");o&&(t.parentElement?.classList.contains("full")?o.setAttribute("readonly",""):o.removeAttribute("readonly"))}function o(){const o=window.TomSelect;"function"==typeof o&&document.querySelectorAll(".sd-dropdown-common").forEach(n=>{if(n.classList.contains("tomselected")||"true"===n.dataset.sdDropdownInitialized)return;n.dataset.sdDropdownInitialized="true";const r="true"===n.dataset.multiple,i="true"===n.dataset.searchable,s=n.dataset.placeholder||"",d=parseInt(n.dataset.maxSelection,10)||0,l=n.closest(".sd-block-single"),a=l?.querySelector(".sd-dropdown-hidden"),c=l?.querySelector(".sd-error")?.id||"",u={placeholder:s,allowEmptyOption:!1,hidePlaceholder:!0,maxOptions:null,plugins:["remove_button","clear_button"],maxItems:r?d||null:1,onFocus(){c&&this.control_input&&this.control_input.setAttribute("aria-describedby",c),this.items?.length&&e(this.items.join(", "))},onChange(t){e(Array.isArray(t)?t.join(", "):t),(e=>{if(r&&a)return a.value=Array.isArray(e)?e.join("|"):e||"",void a.dispatchEvent(new Event("blur",{bubbles:!0}));n.dispatchEvent(new Event("blur",{bubbles:!0}))})(t)},onItemAdd(){t(n),this.setTextboxValue(""),this.lastQuery=null,this.refreshOptions(!1)},onItemRemove(){t(n)},onDropdownOpen(){this.dropdown_content?.querySelectorAll('.option[role="option"]').forEach(e=>e.setAttribute("role","menuitem"))}};r&&(u.hideSelected=!1),i||(u.controlInput=null);const p=new o(n,u);p.wrapper&&p.wrapper.classList.remove("sd-input-common","sd-dropdown-input");const w=n.getAttribute("aria-required");p.control_input&&w&&p.control_input.setAttribute("aria-required",w);const h=p.control?.querySelector(".clear-button");h&&(h.innerHTML='<svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 4L4 12" stroke="currentColor" stroke-opacity="0.65" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/><path d="M4 4L12 12" stroke="currentColor" stroke-opacity="0.65" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/></svg>',h.setAttribute("tabindex","0"),h.setAttribute("role","button"),h.addEventListener("keydown",e=>{" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),e.stopPropagation(),p.clear())}));const m=p.control;if(m&&!m.querySelector(".ts-dropdown-icon")){const e=document.createElement("div");e.className="ts-dropdown-icon",e.innerHTML='<svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 6L8 10L12 6" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" /></svg>',m.appendChild(e)}t(n);const y=l?.querySelector(".sd-dropdown-placeholder");y&&y.remove()})}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",o):o(),window.suredonationInitDropdowns=o,window.suredonationDestroyDropdowns=function(e=document){e.querySelectorAll(".sd-dropdown-common").forEach(e=>{e.tomselect&&e.tomselect.destroy(),delete e.dataset.sdDropdownInitialized})}})(); |