auto-update.asset.php
2 months ago
auto-update.css
3 months ago
auto-update.js
2 months ago
checkbox.asset.php
2 months ago
checkbox.css
2 years ago
checkbox.js
2 months ago
custom.options.restrictions.asset.php
2 months ago
custom.options.restrictions.js
2 months ago
editor.asset.php
2 months ago
editor.css
3 months ago
editor.js
2 months ago
radio.asset.php
2 months ago
radio.css
2 years ago
radio.js
2 months ago
select.asset.php
2 months ago
select.css
2 years ago
select.js
2 months ago
radio.js
1 lines
| 1 | (()=>{var t={554(){const{CalculatedFormula:t}=JetFormBuilderAbstract,{addAction:e}=JetPlugins.hooks,r="__JFB_OPTION_FIELD_DEFAULT_VALUE_OBSERVER__";function n(t){if("string"!=typeof t||t.length<2)return t;const e=t.charAt(0),r=t.charAt(t.length-1);return"'"===e&&"'"===r||'"'===e&&'"'===r?t.slice(1,-1):t}function s(t){return Array.isArray(t)?t.some(s):"string"==typeof t&&t.includes("%")}function i(t){return!(""===t||null===t||Array.isArray(t)&&!t.length)}function o(e,r){const o=Array.isArray(r)?r:[r],a=[],u=new Array(o.length);o.forEach((c,l)=>{const d=new t(e);d.observe(function(t){if("string"!=typeof t)return t;const e=t.trim();return!s(e)||function(t){if("string"!=typeof t||t.length<2)return!1;const e=t.charAt(0),r=t.charAt(t.length-1);return"'"===e&&"'"===r||'"'===e&&'"'===r}(e)?e:`'${e.replace(/'/g,"\\'")}'`}(c)),d.setResult=()=>{const t=d.calculate();i(t)&&(u[l]=t,Object.keys(u).length===o.length&&u.every(i)&&(function(t,e){if(Array.isArray(e))return void t.value.setIfEmpty(e.map(t=>n(""+t)));const r=n(""+e);if(!t.isArray())return function(t){if(t.isArray()||"select"!==t.inputType)return!1;const[e]=t.nodes;if(!e||"select-one"!==e.type||e.multiple||!e.options?.length)return!1;const r=Array.from(e.options),[n]=r;return!!n&&!r.some(t=>""===t.value)&&!r.some(t=>t.defaultSelected)&&0===e.selectedIndex&&e.value===n.value}(t)?void(t.value.current=r):void t.value.setIfEmpty(r);const s=function(t){if("string"!=typeof t)return t;const e=t.trim();try{const r=JSON.parse(e);return Array.isArray(r)?r:t}catch(r){if(e.startsWith("[")&&e.endsWith("]")&&e.includes("'"))try{const r=e.replace(/'((?:\\'|[^'])*)'/g,(t,e)=>`"${e.replace(/"/g,'\\"')}"`),n=JSON.parse(r);return Array.isArray(n)?n:t}catch(e){return t}return t}}(r);t.value.setIfEmpty(Array.isArray(s)?s.map(t=>n(""+t)):[r])}(e,Array.isArray(r)?u:u[0]),a.forEach(t=>t.clearWatchers())))},d.setResult(),a.push(d)})}function a(t){var e,r,n;const[i]=t.nodes,a=null!==(e=t.wrapper)&&void 0!==e?e:i,u=null!==(r=null!==(n=a?.dataset?.defaultVal)&&void 0!==n?n:i?.dataset?.defaultVal)&&void 0!==r?r:"",c=function(t){if("string"!=typeof t)return t;const e=t.trim();try{const t=JSON.parse(e);return Array.isArray(t)?t:e}catch(t){if(e.startsWith("[")&&e.endsWith("]")&&e.includes("'"))try{const t=e.replace(/'((?:\\'|[^'])*)'/g,(t,e)=>`"${e.replace(/"/g,'\\"')}"`),r=JSON.parse(t);return Array.isArray(r)?r:e}catch(t){return e}return e}}(u);(function(t,e){if(Array.isArray(e))return e.length>0;if("string"!=typeof t)return s(e);const r=t.trim();return s(e)||r.startsWith("[")&&r.endsWith("]")})(u,c)&&o(t,c)}window[r]||(window[r]=!0,e("jet.fb.observe.after","jet-form-builder/option-field-default-value",function(t){for(const e of t.getInputs()){const[t]=e.nodes;t&&["select","radio","checkbox"].includes(e.inputType)&&a(e)}}))}},e={};function r(n){var s=e[n];if(void 0!==s)return s.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}(()=>{"use strict";const{strict_mode:t=!1}=window?.JetFormBuilderSettings,e=Boolean(t),{InputData:n,ReactiveHook:s}=JetFormBuilderAbstract,{getParsedName:i}=JetFormBuilderFunctions;function o(){n.call(this),this.wrapper=null}o.prototype=Object.create(n.prototype),o.prototype.wrapper=null,o.prototype.isSupported=function(t){return t.classList.contains("checkradio-wrap")&&t.querySelector(".radio-wrap")},o.prototype.addListeners=function(){this.enterKey=new s,this.wrapper.addEventListener("change",this.onChangeValue.bind(this)),this.wrapper.addEventListener("keydown",this.handleEnterKey.bind(this));const t=this.getCustomInput();this.wrapper.addEventListener("focusout",e=>{[...this.nodes].includes(e?.relatedTarget)||[e.relatedTarget,e.target].includes(t)||this.reportOnBlur()}),t?.addEventListener?.("blur",t=>{const e=this.value.current;this.setValue(),e===this.value.current&&this.onChange(e)}),!e&&jQuery(this.wrapper).on("change",t=>{this.value.current==t.target.value||t.target?.dataset?.custom||(this.callable.lockTrigger(),this.setValue(),this.callable.unlockTrigger())})},o.prototype.setValue=function(){this.value.current=this.getActiveValue()},o.prototype.onChangeValue=function(t){t.target.dataset.custom?this.toggleCustomOption():this.setValue()},o.prototype.toggleCustomOption=function(){const t=this.lastNode(),e=this.getCustomInput();e.disabled===t.checked&&(e.disabled=!t.checked),t.checked&&e.focus()},o.prototype.getActiveValue=function(){for(const t of this.nodes)if(!t.dataset.custom&&t.checked)return t.value;return this.hasCustom?this.getCustomInput().value:""},o.prototype.setNode=function(t){t.jfbSync=this,this.nodes=t.getElementsByClassName("jet-form-builder__field radio-field"),this.rawName=this.nodes[0].name,this.name=i(this.rawName),this.inputType="radio",this.wrapper=t,this.hasCustom=!!this.lastNode()?.dataset?.custom},o.prototype.lastNode=function(){return this.nodes[this.nodes.length-1]},o.prototype.getCustomInput=function(){const t=this.lastNode().closest(".custom-option");return t?.querySelector?.("input.text-field")};const a=o,{BaseSignal:u}=JetFormBuilderAbstract;function c(){u.call(this),this.isSupported=function(t,e){return"radio"===t.type},this.runSignal=function(){this.input.calcValue=0;const t=this.input.value.current;let e=!1;for(const n of this.input.nodes){var r;if(!n.dataset.custom&&(n.checked=""+t===n.value,n.checked)){e=!0,this.input.calcValue+=parseFloat(null!==(r=n.dataset?.calculate)&&void 0!==r?r:n.value),this.triggerJQuery(n);break}}if(!this.input.hasCustom)return;const n=this.input.lastNode(),s=this.input.getCustomInput(),i=!e&&""!==t&&null!=t;n.checked=i,s.disabled===n.checked&&(s.disabled=!n.checked);const o=""+t;n.checked&&s.value!==o&&(s.value=o)}}c.prototype=Object.create(u.prototype);const l=c;r(554);const{addFilter:d}=JetPlugins.hooks;window.JetFormBuilderAbstract={...window.JetFormBuilderAbstract,RadioData:a,SignalRadio:l},d("jet.fb.inputs","jet-form-builder/radio-field",function(t){return[a,...t]}),d("jet.fb.signals","jet-form-builder/radio-field",function(t){return[l,...t]})})()})(); |