field.js
1 lines
| 1 | (()=>{"use strict";const{InputData:t}=JetFormBuilderAbstract;function e(){t.call(this),this.isSupported=function(){return!0},this.addListeners=function(){t.prototype.addListeners.call(this);const[e]=this.nodes,i=this.getWrapperNode()?.querySelector?.(".jfb-eye-icon");i&&(i.addEventListener("click",function(){i.classList.toggle("seen");const t="true"===this.getAttribute("aria-pressed");this.setAttribute("aria-pressed",!t),e.type=i.classList.contains("seen")?"password":"text"}),i.addEventListener("keydown",function(t){" "!==t.key&&"Enter"!==t.key||(t.preventDefault(),this.click())}),i.addEventListener("keyup",function(t){" "===t.key&&t.preventDefault()}))}}e.prototype=Object.create(t.prototype);const i=e,{BaseSignal:n}=JetFormBuilderAbstract,{toDate:r,toDateTime:s,toTime:u}=JetFormBuilderFunctions;function a(){n.call(this),this.isSupported=function(){return!0},this.runSignal=function(){this.input.calcValue=Number.isNaN(Number(this.input.calcValue))?this.input.calcValue:parseFloat(this.input.calcValue);const[t]=this.input.nodes,e=["date","time","datetime-local"].includes(t.type)?function(t,e){if(""===e||null==e)return"";if(Number.isNaN(Number(e)))return e;const i=new Date(Number(e));return"date"===t.type?r(i):"time"===t.type?u(i):"datetime-local"===t.type?s(i):e}(t,this.input.value.current):this.input.value.current;t.value!==e&&(t.value=e,this.triggerJQuery(t))}}a.prototype=Object.create(n.prototype);const o=a,{addFilter:c}=JetPlugins.hooks;c("jet.fb.inputs","jet-form-builder/text-field",function(t){return t.push(i),t},999),c("jet.fb.signals","jet-form-builder/text-field",function(t){return t.push(o),t},999)})(); |