PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 0.0.10
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v0.0.10
2.12.8 2.12.7 2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 All 98 releases
sureforms / assets / js / minified / blocks / dropdown.min.js

dropdown.min.js in SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz 0.0.10, at assets/js/minified/blocks/dropdown.min.js

1 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 function initializeDropdown(){document.querySelectorAll(".srfm-dropdown-common").forEach(o=>{if(o){let e={};"true"===o.getAttribute("data-multiple")&&(e={maxItems:null,hideSelected:!1});var t={maxOptions:null,hidePlaceholder:!0,plugins:["remove_button","clear_button"],onChange(e){Array.isArray(e)?e.forEach(e=>{wp.a11y.speak(e)}):wp.a11y.speak(e);var t=o.closest(".srfm-dropdown-block").querySelector(".srfm-input-dropdown-hidden");t&&t.setAttribute("value",Array.isArray(e)?e.join(","):e)},onItemAdd(){handleInputState(o)},onItemRemove(){handleInputState(o)},...e="false"===o.getAttribute("data-searchable")?{...e,controlInput:null}:e,render:{option(e,t){return`<div>${e.icon} <span>${t(e.text)}</span></div>`},item(e,t){return`<div>${e.icon} ${t(e.text)}</div>`}}},n=(new TomSelect(o,t),o.closest(".srfm-dropdown-block").querySelector(".ts-control")),r=(n.querySelector(".clear-button").innerHTML='<svg 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>',document.createElement("div"));r.classList.add("ts-dropdown-icon"),r.innerHTML='<svg 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-opacity="0.65" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" /></svg>',n.appendChild(r),null===t.controlInput&&(r=o.closest(".srfm-dropdown-block").querySelector(".srfm-dropdown-placeholder"),(t=document.createElement("span")).classList.add("ts-control-placeholder"),t.textContent=r.textContent,n.prepend(t)),o.disabled=!0}})}function handleInputState(e){var e=e.closest(".srfm-dropdown-block").querySelector(".ts-control"),t=e?.parentElement,e=e?.querySelector("input");e&&(t.classList.contains("full")?e.setAttribute("readonly",""):e.removeAttribute("readonly"))}window.srfmInitializeDropdown=initializeDropdown,document.addEventListener("DOMContentLoaded",initializeDropdown);