File manager - Edit - /home/palg2351/public_html/wp-content/plugins/jetformbuilder/assets/build/frontend/conditional.block.js
Back
(()=>{"use strict";function t(){}t.prototype.isSupported=function(t){return!1},t.prototype.observe=function(){},t.prototype.setOptions=function(t){},t.prototype.isPassed=function(){throw new Error("You must provide ConditionItem::isPassed function")},t.prototype.setList=function(t){this.list=t};const e=t,{CalculatedFormula:o}=JetFormBuilderAbstract;function i(){e.call(this),this.isSupported=function(t){return!!t?.field?.length},this.observe=function(){var t;const e=this.getInput();this.list._fields=null!==(t=this.list._fields)&&void 0!==t?t:[],e&&!this.list._fields.includes(this.field)&&(this.list._fields.push(this.field),e.watch((()=>this.list.onChangeRelated())))},this.getInput=function(){return this.list.root.getInput(this.field)},this.isPassed=function(){const t=this.getInput();return!!t&&t.checker.check(this,t)},this.setOptions=function(t){this.field=t.field,this.operator=t.operator,this.render_state=t.render_state,this.use_preset=t.use_preset;let e=t?.value;if(Array.isArray(e)||(e=e.split(",").map((t=>t.trim()))),this.use_preset)this.value=e;else{this.value={};for(const[t,i]of Object.entries(e)){const e=new o(this.list.root);e.observe(i),e.setResult=()=>{this.value[t]=""+e.calculate(),this.list.onChangeRelated()},e.setResult()}this.value=Object.values(this.value)}}}i.prototype=Object.create(e.prototype),i.prototype.field=null,i.prototype.value=null,i.prototype.operator=null,i.prototype.use_preset=null;const s=i;function n(){e.call(this),this.isSupported=function(t){var e;return null!==(e=t.or_operator)&&void 0!==e&&e}}n.prototype=Object.create(e.prototype);const r=n;function l(t,e){this.root=e,this.setConditions(t)}l.prototype={root:null,conditions:[],invalid:[],groups:[],onChangeRelated(){this.getResult()&&this.onMatchConditions()},onMatchConditions(){},observe(){for(const t of this.getConditions())t.observe()},setConditions(t){"string"==typeof t&&(t=JSON.parse(t)),this.conditions=t.map((t=>function(t,e){P.length||(P=A());for(const o of P){const i=new o;if(i.isSupported(t))return i.setList(e),i.setOptions(t),i}}(t,this))).filter((t=>t));const e={};let o=0;for(const t of this.getConditions()){var i;t instanceof r?o++:(e[o]=null!==(i=e[o])&&void 0!==i?i:[],e[o].push(t))}this.groups=Object.values(e)},getResult(){if(this.invalid=[],!this.groups.length)return!0;for(const t of this.groups)if(this.isValidGroup(t))return!0;return!1},isValidGroup(t){for(const e of t)if(!e.isPassed())return this.invalid.push(e),!1;return!0},getConditions(){return this.conditions}};const c=l;function u(t,e){c.call(this,t,e)}u.prototype=Object.create(c.prototype),u.prototype.block=null;const a=u,{doAction:h}=JetPlugins.hooks,{ReactiveVar:d}=JetFormBuilderAbstract,{validateInputsAll:p}=JetFormBuilderFunctions;function f(t,e){this.node=t,t.jfbConditional=this,this.root=e,this.isObserved=!1,this.list=null,this.function=null,this.settings=null,this.page=null,this.multistep=null,this.comment=null,this.inputs=[],this.isRight=new d(null),this.isRight.make(),this.setConditions(),this.setInputs(),this.setFunction(),window?.JetFormBuilderSettings?.devmode||(delete this.node.dataset.jfbConditional,delete this.node.dataset.jfbFunc),h("jet.fb.conditional.init",this)}f.prototype={setConditions(){const{jfbConditional:t}=this.node.dataset;this.list=new a(t,this.root),this.list.block=this,this.list.onChangeRelated=()=>{this.isRight.current=this.list.getResult()}},setInputs(){this.inputs=Array.from(this.node.querySelectorAll("[data-jfb-sync]")).map((t=>t.jfbSync)).filter((t=>t))},insertComment(){this.settings?.dom&&(this.comment=document.createComment(""),this.node.parentElement.insertBefore(this.comment,this.node.nextSibling))},observe(){this.isObserved||(this.isObserved=!0,this.insertComment(),this.isRight.watch((()=>this.runFunction())),this.isRight.watch((()=>this.validateInputs())),this.list.observe())},runFunction(){const t=this.isRight.current;switch(this.function){case"show":this.showBlock(t);break;case"hide":this.showBlock(!t);break;case"disable":this.disableBlock(t);break;default:h("jet.fb.conditional.block.runFunction",this.function,t,this)}},validateInputs(){setTimeout((()=>{p(this.inputs,!0).then((()=>{})).catch((()=>{}))}))},showBlock(t){if(this.node.classList.remove("jet-form-builder--hidden"),this.settings?.dom){this.showBlockDom(t);const e=new CustomEvent("jet-form-builder/conditional-block/block-toggle-hidden-dom",{detail:{block:this.node,result:t}});document.dispatchEvent(e)}else this.node.style.display=t?"block":"none"},showBlockDom(t){const e=this.root.dataInputs;if(!t)return this.node.remove(),void Object.keys(e).forEach((t=>{e[t].formula&&e[t].reCalculateFormula()}));this.comment.parentElement.insertBefore(this.node,this.comment),Object.keys(e).forEach((t=>{e[t].formula&&e[t].reCalculateFormula()}))},disableBlock(t){this.node.disabled=t},setFunction(){let t;this.function=this.node.dataset.jfbFunc;try{t=JSON.parse(this.function)}catch(t){return}const[[e,o]]=Object.entries(t);this.function=e,this.settings=o}};const m=f,{isEmpty:b}=JetFormBuilderFunctions;function g(){this.operators=this.getOperators()}g.prototype={isSupported:()=>!0,operators:{},getOperators:()=>({equal:(t,e)=>t===e[0],empty:t=>b(t),greater:(t,e)=>+t>+e[0],greater_or_eq:(t,e)=>+t>=+e[0],less:(t,e)=>+t<+e[0],less_or_eq:(t,e)=>+t<=+e[0],between:(t,e)=>!(!e?.length||null===t)&&e[0]<=+t&&+t<=e[1],one_of:(t,e)=>!!e?.length&&0<=e.indexOf(t),contain:(t,e)=>!!t&&0<=t.indexOf(e[0])}),check(t,e){const o=e.value.current,i=t.value;return this.checkRaw(t.operator,o,i)},checkRaw(t,e,o){if(this.operators.hasOwnProperty(t))return this.operators[t](e,o);if(0!==t.indexOf("not_"))return!1;const i=t.slice(4);return!!this.operators.hasOwnProperty(i)&&!this.operators[i](e,o)}};const v=g;function y(){v.call(this),this.operators.one_of=(t,e)=>!(!e?.length||!t?.length)&&t.some((t=>-1!==e.indexOf(t))),this.operators.contain=(t,e)=>!!t?.length&&t.some((t=>-1!==t.indexOf(e[0]))),this.isSupported=function(t){return t.isArray()}}y.prototype=Object.create(v.prototype);const k=y,{getTimestamp:j}=JetFormBuilderFunctions,{Min_In_Sec:C,Milli_In_Sec:w}=JetFormBuilderConst,O=(new Date).getTimezoneOffset();function _(){v.call(this),this.isSupported=function(t){const[e]=t.nodes;return["date","time","datetime-local"].includes(e.type)},this.check=function(t,e){const{time:o}=j(e.value.current),i=t.value.map((e=>{const{time:o,type:i}=j(e);return"number"===i&&t.use_preset?o*w+O*C:o}));return this.checkRaw(t.operator,o,i)}}_.prototype=Object.create(v.prototype);const F=_;function R(){e.call(this),this.isSupported=function(t){return"render_state"===t?.operator},this.getInput=function(){return this.list.root.getInput("_jfb_current_render_states")},this.observe=function(){this.getInput().watch((()=>this.list.onChangeRelated()))},this.setOptions=function(t){var e;this.render_state=null!==(e=t.render_state)&&void 0!==e?e:[]},this.isPassed=function(){const{value:t}=this.getInput();return!!t.current?.length&&this.render_state.some((e=>t.current.includes(e)))}}R.prototype=Object.create(e.prototype),R.prototype.render_state=[];const B=R;function S(){v.call(this),this.isSupported=function(t){return"calculated"===t.inputType},this.check=function(t,e){const o=e.calcValue,i=t.value;return this.checkRaw(t.operator,o,i)}}S.prototype=Object.create(v.prototype);const I=S,{applyFilters:J}=JetPlugins.hooks,A=()=>J("jet.fb.conditional.types",[B,r,s]);let P=[],E=[];function x(t,e){if(t.hasOwnProperty("jfbConditional"))return t.jfbConditional;const o=new m(t,e);return o.observe(),o.list.onChangeRelated(),o}function q(t){E.length||(E=J("jet.fb.conditional.checkers",[k,F,I,v]));for(const e of E){const o=new e;if(o.isSupported(t))return o}return null}var L;const{addAction:N}=JetPlugins.hooks;N("jet.fb.observe.after","jet-form-builder/conditional-block",(function(t){for(const e of t.rootNode.querySelectorAll("[data-jfb-conditional]"))x(e,t)}),20),N("jet.fb.input.makeReactive","jet-form-builder/conditional-block",(function(t){t.checker=q(t)})),N("jet.fb.conditional.block.runFunction","jet-form-builder/conditional-block",(function(t,e,o){"setCssClass"===t&&o.settings?.className&&o.node.classList.toggle(o.settings.className,e)})),window.JetFormBuilderAbstract={...null!==(L=window.JetFormBuilderAbstract)&&void 0!==L?L:{},ConditionItem:e,ConditionalBlock:m,createConditionalBlock:x,createChecker:q,ConditionsList:c}})();
| ver. 1.4 |
Github
|
.
| PHP 8.3.30 | Generation time: 0.07 |
proxy
|
phpinfo
|
Settings