FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
sureforms
/
assets
/
js
/
minified
/
blocks
Edit File: multi-choice.min.js
function initializeMultichoice(){var e=document.querySelectorAll(".srfm-multi-choice-block");e&&e.forEach(c=>{let r=[];(()=>{var e=c.querySelector(".srfm-input-multi-choice-hidden"),i=c.querySelectorAll(".srfm-input-multi-choice-single:checked");if(e&&0!==i.length)if(c.classList.contains("srfm-radio-mode")){var l=i[0].closest(".srfm-multi-choice-single").querySelector("label");l&&(e.setAttribute("value",l.getAttribute("data-option-text")||l.innerText),e.dispatchEvent(new Event("change",{bubbles:!0})))}else if(c.classList.contains("srfm-checkbox-mode")){let t=[];i.forEach(e=>{e=e.closest(".srfm-multi-choice-single").querySelector("label");e&&t.push(e.getAttribute("data-option-text")||e.innerText)}),r=[...t];l=window.srfm.srfmUtility.prepareValue(t);e.setAttribute("value",l),e.dispatchEvent(new Event("change",{bubbles:!0}))}})();c.querySelectorAll(".srfm-multi-choice-single")?.forEach(i=>{i.addEventListener("click",e=>{var t;e.target.matches("label")||(t=i.querySelector(".srfm-input-multi-choice-single"))&&(t.click(),e.stopPropagation())})});var e=c.querySelectorAll(".srfm-input-multi-choice-single");let l;e?.forEach(e=>{e.addEventListener("click",t=>{t.stopPropagation();var i=t.target.closest(".srfm-multi-choice-single").querySelector("label"),i=(l=i?i.getAttribute("data-option-text")||i.innerText:"",c.querySelector(".srfm-input-multi-choice-hidden"));if(i&&l){let e=null;c.classList.contains("srfm-radio-mode")?t.target.checked&&(e=l):c.classList.contains("srfm-checkbox-mode")&&(r=t.target.checked?[...r,l]:r.filter(e=>e!==l),e=window.srfm.srfmUtility.prepareValue(r)),null!==e&&i.setAttribute("value",e),i.dispatchEvent(new Event("change",{bubbles:!0}))}})})})}document.addEventListener("DOMContentLoaded",initializeMultichoice);
Save
Back