PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.10.0
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.10.0
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
bit-form / assets / submit-form.min.js

submit-form.min.js in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.10.0, at assets/submit-form.min.js

2 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var submit_form=function(){"use strict";function e(e,t){const o=new URL(e?.ajaxURL),n=e?.entryId?"bitforms_update_form_entry":"bitforms_submit_form";return o.searchParams.append("action",n),e?.entryId&&(o.searchParams.append("_ajax_nonce",e.nonce||""),o.searchParams.append("entryID",e.entryId),o.searchParams.append("formID",e.formId)),fetch(o,{method:"POST",body:t})}function t(e,t,n){e.then((e=>new Promise(((o,n)=>{if(e.staus>400){const o=new CustomEvent("bf-form-submit-error",{detail:{formId:t,errors:result.data}});bfSelect(`#form-${t}`).dispatchEvent(o),500===e.staus?n(new Error("Mayebe Internal Server Error")):n(e.json())}else o(e.json())})))).then((e=>{const a=new CustomEvent("bf-form-submit-success",{detail:{formId:t,entryId:e.entryId,formData:n}});bfSelect(`#form-${t}`).dispatchEvent(a);let r=null,s=null,c="",d=1e3;const i=window.bf_globals[t];if(void 0!==e&&e.success){const o=bfSelect(`#form-${t}`);bfReset(t),"object"==typeof e.data?(o&&e?.data?.hidden_fields?.map((e=>{setHiddenFld(e,o)})),r=e.data.redirectPage,e.data.cron&&(s=e.data.cron),e.data.cronNotOk&&(s=e.data.cronNotOk),e.data.new_nonce&&(c=e.data.new_nonce),setBFMsg({contentId:t,msgId:e.data.msg_id,msg:e.data.message,duration:e.data.msg_duration,show:!0,type:"success",error:!1}),d=Number(e.data.msg_duration||1e3)):setBFMsg({contentId:t,msg:e.data,type:"success",show:!0,error:!1}),localStorage.removeItem(`bitform-partial-form-${i.formId}`);const n=bfSelect('input[name="entryID"]',o);n&&n.remove(),delete i.entryId}else{const o=new CustomEvent("bf-form-submit-error",{detail:{formId:t,errors:e.data}});bfSelect(`#form-${t}`).dispatchEvent(o),bfValidationErrMsg(e,t)}if(function(e,t,o){const n=window.bf_globals[o];if(e)if("string"==typeof e){const t=new URL(e);t.protocol!==window.location.protocol&&(t.protocol=window.location.protocol),fetch(t)}else{const o=new URL(n.ajaxURL);o.searchParams.append("action","bitforms_trigger_workflow");const a={cronNotOk:e,token:t||n.nonce,id:n.appID};fetch(o,{method:"POST",body:JSON.stringify(a),headers:{"Content-Type":"application/json"}}).then((e=>e.json()))}}(s,c,t),r){const e=setTimeout((()=>{window.location=decodeURI(r),e&&clearTimeout(e)}),d)}o(t,!1)})).catch((e=>{const n=e?.message?e.message:"Unknown Error";setBFMsg({contentId:t,msg:n,show:!0,type:"error",error:!0}),o(t,!1)}))}function o(e,t){const o=bfSelect('button[type="submit"]',bfSelect(`#form-${e}`));o&&(o.disabled=t);const n=bfSelect('button[type="submit"] span',bfSelect(`#form-${e}`));n&&n.classList.toggle("d-none")}return function(n=null){(n?[n]:Object.keys(window.bf_globals)).forEach((n=>{const a=bfSelect(`#form-${n}`);a&&(a.addEventListener("submit",(n=>{!function(n){n.preventDefault();const a=n.target.id.slice(n.target.id.indexOf("-")+1);if("undefined"!=typeof validateForm&&!validateForm({form:a})){const e=new CustomEvent("bf-form-validation-error",{detail:{formId:a,fieldId:"",error:""}});return void n.target.dispatchEvent(e)}o(a,!0);let r=new FormData(n.target);const s=window.bf_globals[a];"undefined"!=typeof advancedFileHandle&&(r=advancedFileHandle(s,r)),"undefined"!=typeof decisionFldHandle&&(r=decisionFldHandle(s,r)),s.GCLID&&r.set("GCLID",s.GCLID);const c=[];Object.entries(s?.fields||{}).forEach((e=>{e[1]?.valid?.hide&&c.push(e[0])})),c.length&&r.append("hidden_fields",c),"v3"===s?.gRecaptchaVersion&&s?.gRecaptchaSiteKey?grecaptcha.ready((()=>{grecaptcha.execute(s.gRecaptchaSiteKey,{action:"submit"}).then((o=>{r.append("g-recaptcha-response",o),t(e(s,r),a,r)}))})):t(e(s,r),a,r)}(n)})),bfSelect('button[type="reset"]',a)?.addEventListener("click",(()=>bfReset(a.id.replace("form-",""),!0))))})),document.querySelectorAll(".msg-backdrop,.bf-msg-close").forEach((e=>{e.addEventListener("click",(t=>{t.target===e&&(t.stopPropagation(),bfSelect(`#${e.dataset.contentid} .msg-container-${e.dataset.msgid}`).classList.replace("active","deactive"))}))})),localStorage.setItem("bf-entry-id","")}}();
2