PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / V-3.3.0
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder vV-3.3.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 V-3.3.0, at assets/submit-form.min.js

2 lines 5.1 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 a=new URL(e?.ajaxURL),o=e?.entryId?"bitforms_update_form_entry":"bitforms_submit_form";return a.searchParams.append("action",o),e?.entryId&&(a.searchParams.append("_ajax_nonce",e.nonce||""),a.searchParams.append("entryID",e.entryId),a.searchParams.append("formID",e.formId),a.searchParams.append("entryToken",e.entryToken||"")),fetch(a,{method:"POST",body:t})}const t=[403,406];function a(e){const t=window.bf_globals?.[e],a={contentId:e,message:t?.wafBlockMsg||"Your submission was blocked by the site's security firewall."};return bfSelect(`#form-${e}`)?.dispatchEvent(new CustomEvent("bf-form-waf-blocked",{bubbles:!0,detail:a})),a.message}function o(e,o,r){e.then(e=>e.text().then(n=>{let r=null;try{r=JSON.parse(n)}catch(e){r=null}if(null===r){const n=t.includes(e.status),r=new Error(n?"waf-blocked":"Invalid response");throw r.wafBlocked=n,r.data={data:n?a(o):"Invalid server response. Check the browser console for more details."},r}if(e.status>=400){const e=new Error(r?.data||"Request failed");throw e.data=r,e}return r})).then(e=>{let t=null,a=null,s="",d=1e3;const c=window.bf_globals[o];if(void 0!==e&&e.success){const n=new CustomEvent("bf-form-submit-success",{detail:{formId:o,entryId:e.data?.entry_id,formData:r}});bfSelect(`#form-${o}`).dispatchEvent(n);const i=bfSelect(`#form-${o}`),l="object"==typeof e.data&&e.data.afterSubmit?e.data.afterSubmit:"reset";if("keep"!==l&&bfReset(o),"hide"===l&&i&&i.remove(),"object"==typeof e.data){i&&"hide"!==l&&e?.data?.hidden_fields?.map(e=>{setHiddenFld(e,i)}),t=e.data.redirectPage,e.data.cron&&(a=e.data.cron),e.data.cronNotOk&&(a=e.data.cronNotOk),e.data.new_nonce&&(s=e.data.new_nonce,c.nonce=s);let n=!1;!e.data.suppressConfirmation&&e.data.message&&(n=!0,setBFMsg({contentId:o,msgId:e.data.msg_id,msg:e.data.message,duration:e.data.msg_duration,show:!0,type:"success",error:!1})),d=n?Number(e.data.msg_duration||1e3):0}else setBFMsg({contentId:o,msg:e.data,type:"success",show:!0,error:!1});if(localStorage.removeItem(`bitform-partial-form-${c.formId}`),"hide"!==l){const e=bfSelect('input[name="entryID"]',i);e&&e.remove()}delete c.entryId}else{const t=new CustomEvent("bf-form-submit-error",{detail:{formId:o,errors:e.data}});bfSelect(`#form-${o}`).dispatchEvent(t),bfValidationErrMsg(e,o)}if(function(e,t,a){const o=window.bf_globals[a];if(e)if("string"==typeof e){const t=new URL(e);t.protocol!==window.location.protocol&&(t.protocol=window.location.protocol),fetch(t,{keepalive:!0}).catch(()=>{})}else{const a=new URL(o.ajaxURL);a.searchParams.append("action","bitforms_trigger_workflow");const n={cronNotOk:e,token:t||o.nonce,id:o.appID},r=()=>fetch(a,{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json"},keepalive:!0});r().catch(()=>{setTimeout(()=>{r().catch(()=>{})},2e3)})}}(a,s,o),t){const e=setTimeout(()=>{window.location=decodeURI(t),e&&clearTimeout(e)},d)}n(o,!1)}).catch(e=>{if(e&&"object"==typeof e&&"data"in e){const t=e.data,a=new CustomEvent("bf-form-submit-error",{detail:{formId:o,errors:t?.data??t}});if(bfSelect(`#form-${o}`)?.dispatchEvent(a),"undefined"!=typeof bfValidationErrMsg)bfValidationErrMsg(t??{data:e.message},o);else{const a=t&&"string"==typeof t.data?t.data:e?.message||"Validation failed";setBFMsg({contentId:o,msg:a,show:!0,type:"error",error:!0})}}else{const t=e?.message?e.message:"Unknown Error";setBFMsg({contentId:o,msg:t,show:!0,type:"error",error:!0})}n(o,!1)})}function n(e,t){const a=bfSelect('button[type="submit"]',bfSelect(`#form-${e}`));a&&(a.disabled=t);const o=bfSelect('button[type="submit"] span',bfSelect(`#form-${e}`));o&&o.classList.toggle("d-none")}return function(t=null){(t?[t]:Object.keys(window.bf_globals||{})).forEach(t=>{const a=bfSelect(`#form-${t}`);a&&(a.addEventListener("submit",t=>{!function(t){t.preventDefault();const a=t.target.id.slice(t.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 t.target.dispatchEvent(e)}n(a,!0);let r=new FormData(t.target);const s=window.bf_globals[a];"undefined"!=typeof advancedFileHandle&&(r=advancedFileHandle(s,r)),"undefined"!=typeof decisionFldHandle&&(r=decisionFldHandle(s,r)),"undefined"!=typeof hideChildFldHandle&&(r=hideChildFldHandle(s,r)),s.GCLID&&r.set("GCLID",s.GCLID);const d=[];Object.entries(s?.fields||{}).forEach(e=>{e[1]?.valid?.hide&&d.push(e[0])}),d.length&&r.append("hidden_fields",d),"v3"===s?.gRecaptchaVersion&&s?.gRecaptchaSiteKey?grecaptcha.ready(()=>{grecaptcha.execute(s.gRecaptchaSiteKey,{action:"submit"}).then(t=>{r.append("g-recaptcha-response",t),o(e(s,r),a,r)}).catch(()=>{n(a,!1),setBFMsg({contentId:a,msg:"reCAPTCHA verification failed. Please try again.",show:!0,type:"error",error:!0})})}):o(e(s,r),a,r)}(t)}),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