lib
2 years ago
advanced.reporting.js
2 years ago
calculated.field.js
3 years ago
checkbox.field.js
2 years ago
conditional.block.js
3 years ago
custom.options.restrictions.js
2 years ago
dynamic.value.js
2 years ago
main.js
2 years ago
media.field.js
3 years ago
media.field.restrictions.js
2 years ago
multi.step.js
2 years ago
radio.field.js
2 years ago
repeater.field.js
2 years ago
calculated.field.js
1 lines
| 1 | (()=>{"use strict";function t(t){return t.closest(".jet-form-builder__calculated-field")}function e(e){var r,n;return!(null===(r=null===(n=t(e))||void 0===n||null===(n=n.dataset)||void 0===n||null===(n=n.formula)||void 0===n?void 0:n.length)||void 0===r||!r)}var r,n,i=window.JetFormBuilderAbstract,u=i.InputData,l=i.CalculatedFormula,o=JetPlugins.hooks.applyFilters,a=(null!==(r=null===(n=window)||void 0===n||null===(n=n.JetFormBuilderMain)||void 0===n?void 0:n.filters)&&void 0!==r?r:{}).applyFilters,s=void 0!==a&&a;function c(){u.call(this),this.formula="",this.precision=0,this.sepDecimal="",this.sepThousands="",this.visibleValNode=null,this.valueTypeProp="number",this.isSupported=function(t){return e(t)},this.setValue=function(){var t=this,e=new l(this,{forceFunction:!0});e.observe(this.formula),e.setResult=function(){t.value.current=e.calculate()},e.relatedCallback=function(e){var r=o("jet.fb.calculated.callback",!1,e,t);if(!1!==r)return r;var n="number"===t.valueTypeProp?e.calcValue:e.value.current;if(!1===s)return n;var i=s("forms/calculated-field-value",e.value.current,jQuery(e.nodes[0]));return i===e.value.current?n:i},e.emptyValue=function(){return"number"===t.valueTypeProp?0:""},e.setResult(),this.value.current=this.value.applySanitizers(this.value.current),this.beforeSubmit((function(r){t.value.silence(),t.value.current=null,t.value.silence(),e.setResult(),r()}),this)},this.setNode=function(e){u.prototype.setNode.call(this,e);var r=t(e).dataset,n=r.formula,i=r.precision,l=r.sepDecimal,o=r.valueType,a=r.sepThousands;this.formula=n,this.precision=+i,this.sepDecimal=null!=l?l:"",this.sepThousands=null!=a?a:"",this.visibleValNode=e.nextElementSibling,this.valueTypeProp=o,this.inputType="calculated"},this.addListeners=function(){},this.report=function(){}}c.prototype=Object.create(u.prototype);const p=c;function f(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,u,l,o=[],a=!0,s=!1;try{if(u=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=u.call(r)).done)&&(o.push(n.value),o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{if(!a&&null!=r.return&&(l=r.return(),Object(l)!==l))return}finally{if(s)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return h(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?h(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var d=window.JetFormBuilderAbstract.BaseSignal;function v(){d.call(this),this.isSupported=function(t,r){return e(t)},this.baseSignal=function(){var t=f(this.input.nodes,1)[0],e="number"===this.input.valueTypeProp;this.input.calcValue=e?this.withPrecision():this.input.value.current,this.input.value.silence(),this.input.value.current=e?this.convertValue():this.input.value.current,this.input.value.silence(),this.input.visibleValNode.textContent=this.input.value.current,t.value=this.input.calcValue},this.runSignal=function(){this.baseSignal();var t=f(this.input.nodes,1)[0];this.triggerJQuery(t)}}v.prototype=Object.create(d.prototype),v.prototype.convertValue=function(){var t=this.input.value.current;if(Number.isNaN(Number(t)))return 0;var e=this.withPrecision().toString().split(".");return this.input.sepThousands&&(e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,this.input.sepThousands)),e.join(this.input.sepDecimal)},v.prototype.withPrecision=function(){return Number(this.input.value.current).toFixed(this.input.precision)};const y=v;function b(t){return function(t){if(Array.isArray(t))return m(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return m(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var g=JetPlugins.hooks.addFilter;g("jet.fb.inputs","jet-form-builder/calculated-field",(function(t){return[p].concat(b(t))})),g("jet.fb.signals","jet-form-builder/calculated-field",(function(t){return[y].concat(b(t))}))})(); |