PageSourceSearch

https://www.creapure.com/static/creapure/assets/flexible-form-conditions-Bmc-NsSC.js

js creapure.com collected 2026-10-02 11:46:46 UTC 2,949 bytes, 1 lines download raw bytes

1var m=Object.defineProperty;var p=(c,a,e)=>a in c?m(c,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[a]=e;var f=(c,a,e)=>p(c,typeof a!="symbol"?a+"":a,e);import{B as C}from"./creapure-BlvyVjU-.js";const l=class l extends C{constructor(){super(...arguments);f(this,"HANDLERS",{inputChange:this.onInputChange.bind(this)});f(this,"form");f(this,"conditionContainers");f(this,"mappedConditionContainers",[])}run(){this.bind(),this.setRequiredAttributes(),this.initConditions()}bind(){this.form=this.element.querySelector("form"),this.conditionContainers=Array.from(this.element.querySelectorAll(`[data-${l.SELECTORS.conditionAttribute}]`))}setRequiredAttributes(){this.conditionContainers.forEach(e=>{Array.from(e.querySelectorAll("[name]")).forEach(o=>{o.required&&(o.isRequired=!0)})})}initConditions(){this.conditionContainers.forEach(e=>{let t=e.dataset[l.SELECTORS.conditionAttribute];t&&(t=this.prepareConditions(t),e.conditions=t,t.forEach(o=>{const i=o.name,s=i+"[]";let n=Array.from(this.element.querySelectorAll(`[name="${s}"]`));n.length||(n=Array.from(this.element.querySelectorAll(`[name="${i}"]`))),n.forEach(r=>{r.addEventListener("change",this.HANDLERS.inputChange)}),this.mappedConditionContainers[i]=this.mappedConditionContainers[i]||[],this.mappedConditionContainers[i].push(e),this.checkConditions(e)}))})}prepareConditions(e){return e=JSON.parse(e),e.forEach(t=>{t.values&&typeof t.values=="object"&&(t.values=t.values.join().split(","))}),e}onInputChange(e){const t=e.target,o=this.getInputName(t),i=this.mappedConditionContainers[o];i&&i.forEach(s=>{this.checkConditions(s)})}getInputName(e){return e.getAttribute("name").replace("[]","")}checkConditions(e){let t=!0;e.conditions.forEach(i=>{let s=this.getFormDataValue(i.name);const n=i.operator,r=i.values;if(n==="isTrue")s||(t=!1);else if(n==="isFalse")s&&(t=!1);else if(s){if(r)if(n==="contains"||n==="containsNot"){let d=!1;s&&typeof s!="object"&&(s=[s]),s.length&&s.forEach(h=>{r.indexOf(h)!==-1&&(d=!0)}),(n==="contains"&&!d||n==="containsNot"&&d)&&(t=!1)}else n==="eq"?typeof s=="object"?JSON.stringify(r)!==JSON.stringify(s)&&(t=!1):r.indexOf(s)===-1&&(t=!1):n==="neq"&&(typeof s=="object"?JSON.stringify(r)===JSON.stringify(s)&&(t=!1):r.indexOf(s)!==-1&&(t=!1))}else t=!1}),this.toggleConditionContainer(e,t)}toggleConditionContainer(e,t){t?e.classList.remove(l.CLASSES.conditionDisabled):e.classList.add(l.CLASSES.conditionDisabled),Array.from(e.querySelectorAll("[name]")).forEach(i=>{i.isRequired&&(t?i.setAttribute("required","required"):i.removeAttribute("required")),t||this.setInputEmpty(i)})}getFormDataValue(e){const t=new FormData(this.form),o=e+"[]";let i=t.getAll(o);return i.length?i:t.get(e)}setInputEmpty(e){const t=e.getAttribute("type");t==="radio"||t==="checkbox"?e.checked=!1:e.value=""}};f(l,"SELECTORS",{conditionAttribute:"condition"}),f(l,"CLASSES",{conditionDisabled:"flexible-form--condition-disabled"});let u=l;export{u as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.