diff --git a/assets/js/frontend/ajax-submission.js b/assets/js/frontend/ajax-submission.js index 94f886a55..a5daef466 100644 --- a/assets/js/frontend/ajax-submission.js +++ b/assets/js/frontend/ajax-submission.js @@ -16,7 +16,13 @@ jQuery( function( $ ) { } if (formTuple.find( ".everest-forms-gateway[data-gateway='stripe']").hasClass('StripeElement--empty') && $(".evf-field-credit-card ").is(':visible') ){ - $( '#card-errors' ).html( 'This field is required' ).show(); + $(document).ready(function() { + $('#card-errors').html('This field is required').show(); + $('.evf-submit').text('Submit'); + $('.evf-submit').attr('disabled', false); + + }); + formTuple.trigger( 'focusout' ).trigger( 'change' ).trigger( 'submit' ); return false; } @@ -47,7 +53,7 @@ jQuery( function( $ ) { const authorizeNetAjaxSubmitHandlerPromise = new Promise(function (resolve, reject) { window.EverestFormsAuthorizeNet.authorizeNetAjaxSubmitHandler(v).then(resolve).catch(reject); }); - + try { const response = await authorizeNetAjaxSubmitHandlerPromise; @@ -60,7 +66,7 @@ jQuery( function( $ ) { } catch (error) { return; } - + } if (errors.length < 1) { diff --git a/assets/js/frontend/ajax-submission.min.js b/assets/js/frontend/ajax-submission.min.js index 9fec63c37..431b50f89 100644 --- a/assets/js/frontend/ajax-submission.min.js +++ b/assets/js/frontend/ajax-submission.min.js @@ -1 +1 @@ -jQuery(function(n){"use strict";n('form[data-ajax_submission="1"]').each(function(e,o){n(document).ready(function(){var i=n(o),d=i.find(".evf-submit");i.find("[data-gateway='razorpay']");d.on("click",async function(e){var a=i.find(".everest-forms-stripe-gateways-tabs .evf-tab").has("a.active").data("gateway");if(undefined===a&&i.find(".everest-forms-gateway[data-gateway='stripe']").data("gateway"),i.find(".everest-forms-gateway[data-gateway='stripe']").hasClass("StripeElement--empty")&&n(".evf-field-credit-card ").is(":visible"))return n("#card-errors").html("This field is required").show(),!1;"undefined"!=typeof tinyMCE&&tinyMCE.triggerSave();a=d.get(0).recaptchaID;if(0===a)return grecaptcha.execute(a),!1;a=i.serializeArray(),e.preventDefault(),i.trigger("focusout").trigger("change").trigger("submit"),e=i.find(".evf-error:visible");if(n(".everest-forms-authorize_net[data-gateway='authorize-net']").length){var t=window.EverestFormsAuthorizeNet.getCardData(i);if(!Object.values(t).some(e=>!e)){t=new Promise(function(e,a){window.EverestFormsAuthorizeNet.authorizeNetAjaxSubmitHandler(o).then(e)["catch"](a)});try{var r=await t;"Ok"===r.messages.resultCode&&a.push({name:"everest_forms[authorize_net][opaque_data][descriptor]",value:r.opaqueData.dataDescriptor},{name:"everest_forms[authorize_net][opaque_data][value]",value:r.opaqueData.dataValue})}catch(s){return}}e.length<1&&(e=i.parents("div.everest-forms").find(".everest-forms-notice.everest-forms-notice--error .evf-error"))}0'+t.data.pdf_download_message+""),1==t.data.quiz_result_shown&&(a=t.data.quiz_reporting);var r=i.find(".everest-forms-stripe-gateways-tabs .evf-tab").has("a.active").data("gateway");"stripe"===(r=undefined===r?"ideal"===(r=i.find(".everest-forms-gateway[data-gateway='ideal']").data("gateway"))?"ideal":i.find(".everest-forms-gateway[data-gateway='stripe']").data("gateway"):r)&&"none"!==i.find(".everest-forms-gateway[data-gateway='stripe']").closest(".evf-field").css("display")?i.trigger("everest_forms_frontend_before_ajax_complete_success_message",t.data):"ideal"===(r=undefined===r?i.find(".everest-forms-gateway[data-gateway='ideal']").data("gateway"):r)&&"none"!==i.find(".everest-forms-gateway[data-gateway='ideal']").closest(".evf-field").css("display")?i.trigger("evf_process_payment",t.data):(i.trigger("reset"),i.closest(".everest-forms").html('"+a).focus(),localStorage.removeItem(i.attr("id")),r=new CustomEvent("everest_forms_ajax_submission_success",{detail:{formId:"evf-form-"+t.data.form_id}}),document.dispatchEvent(r))}else{var o=i.data("formid"),t=JSON.parse(a.responseText),a=(r="undefined"!=typeof t.data[o]?t.data[o].header:everest_forms_ajax_submission_params.error,t.data.error);"string"==typeof t.data.message&&(r=t.data.message),i.closest(".everest-forms").find(".everest-forms-notice").remove(),i.closest(".everest-forms").prepend('").focus(),n(a).each(function(e,a){var r,t=Object.values(a)[0],s=Object.keys(a)[0],a=!0,i="evf"-+o+"-field_"+s+"-container";n("#"+i).hasClass("evf-field-signature")?r=n("#"+("evf-signature-img-input-"+s)):n("#"+i).hasClass("evf-field-likert")?(a=!1,(r=n('[id^="'+("everest_forms-"+o+"-field_"+s+"_")+'"]')).each(function(e,a){var a=n(a).closest("tr.evf-"+o+"-field_"+s).find("th"),t="everest_forms[form_fields]["+s+"]["+(parseInt(a.closest("tr").index())+1)+"]";a.children().is("label")?a.children().find("#"+t).show():(a.parents("span.input-wrapper").length?a.parents("span.input-wrapper"):a).append('")})):n("#"+i).hasClass("evf-field-address")?(r=n('[id^="'+("evf-"+o+"-field_"+s)+'"]')).each(function(e,a){var t=String(n(a).attr("id"));(t.includes("-container")||t.includes("-address2")||void 0!==n(a).val())&&r.splice(e,1)}):r=n("#"+("evf-"+o+"-field_"+s)),r.addClass("evf-error"),r.attr("aria-invalid",!0),r.first().closest(".evf-field").addClass("everest-forms-invalid evf-has-error"),!0!==a||r.is("label")||(r.parents("span.input-wrapper").length?r.parents("span.input-wrapper"):r).after('").show()}),d.attr("disabled",!1).html(everest_forms_ajax_submission_params.submit)}}).fail(function(){d.attr("disabled",!1).html(everest_forms_ajax_submission_params.submit),i.trigger("focusout").trigger("change"),i.closest(".everest-forms").find(".everest-forms-notice").remove(),i.closest(".everest-forms").prepend('").focus()}).always(function(e){!(e.data&&e.data.redirect_url?e.data.redirect_url:"")&&n(".everest-forms-notice").length&&n([document.documentElement,document.body]).animate({scrollTop:n(".everest-forms-notice").offset().top},800)}))})})})}); \ No newline at end of file +jQuery(function(n){"use strict";n('form[data-ajax_submission="1"]').each(function(e,o){n(document).ready(function(){var i=n(o),d=i.find(".evf-submit");i.find("[data-gateway='razorpay']");d.on("click",async function(e){var a=i.find(".everest-forms-stripe-gateways-tabs .evf-tab").has("a.active").data("gateway");if(undefined===a&&i.find(".everest-forms-gateway[data-gateway='stripe']").data("gateway"),i.find(".everest-forms-gateway[data-gateway='stripe']").hasClass("StripeElement--empty")&&n(".evf-field-credit-card ").is(":visible"))return n(document).ready(function(){n("#card-errors").html("This field is required").show(),n(".evf-submit").text("Submit"),n(".evf-submit").attr("disabled",!1)}),i.trigger("focusout").trigger("change").trigger("submit"),!1;"undefined"!=typeof tinyMCE&&tinyMCE.triggerSave();a=d.get(0).recaptchaID;if(0===a)return grecaptcha.execute(a),!1;a=i.serializeArray(),e.preventDefault(),i.trigger("focusout").trigger("change").trigger("submit"),e=i.find(".evf-error:visible");if(n(".everest-forms-authorize_net[data-gateway='authorize-net']").length){var t=window.EverestFormsAuthorizeNet.getCardData(i);if(!Object.values(t).some(e=>!e)){t=new Promise(function(e,a){window.EverestFormsAuthorizeNet.authorizeNetAjaxSubmitHandler(o).then(e)["catch"](a)});try{var r=await t;"Ok"===r.messages.resultCode&&a.push({name:"everest_forms[authorize_net][opaque_data][descriptor]",value:r.opaqueData.dataDescriptor},{name:"everest_forms[authorize_net][opaque_data][value]",value:r.opaqueData.dataValue})}catch(s){return}}e.length<1&&(e=i.parents("div.everest-forms").find(".everest-forms-notice.everest-forms-notice--error .evf-error"))}0'+t.data.pdf_download_message+""),1==t.data.quiz_result_shown&&(a=t.data.quiz_reporting);var r=i.find(".everest-forms-stripe-gateways-tabs .evf-tab").has("a.active").data("gateway");"stripe"===(r=undefined===r?"ideal"===(r=i.find(".everest-forms-gateway[data-gateway='ideal']").data("gateway"))?"ideal":i.find(".everest-forms-gateway[data-gateway='stripe']").data("gateway"):r)&&"none"!==i.find(".everest-forms-gateway[data-gateway='stripe']").closest(".evf-field").css("display")?i.trigger("everest_forms_frontend_before_ajax_complete_success_message",t.data):"ideal"===(r=undefined===r?i.find(".everest-forms-gateway[data-gateway='ideal']").data("gateway"):r)&&"none"!==i.find(".everest-forms-gateway[data-gateway='ideal']").closest(".evf-field").css("display")?i.trigger("evf_process_payment",t.data):(i.trigger("reset"),i.closest(".everest-forms").html('"+a).focus(),localStorage.removeItem(i.attr("id")),r=new CustomEvent("everest_forms_ajax_submission_success",{detail:{formId:"evf-form-"+t.data.form_id}}),document.dispatchEvent(r))}else{var o=i.data("formid"),t=JSON.parse(a.responseText),a=(r="undefined"!=typeof t.data[o]?t.data[o].header:everest_forms_ajax_submission_params.error,t.data.error);"string"==typeof t.data.message&&(r=t.data.message),i.closest(".everest-forms").find(".everest-forms-notice").remove(),i.closest(".everest-forms").prepend('").focus(),n(a).each(function(e,a){var r,t=Object.values(a)[0],s=Object.keys(a)[0],a=!0,i="evf"-+o+"-field_"+s+"-container";n("#"+i).hasClass("evf-field-signature")?r=n("#"+("evf-signature-img-input-"+s)):n("#"+i).hasClass("evf-field-likert")?(a=!1,(r=n('[id^="'+("everest_forms-"+o+"-field_"+s+"_")+'"]')).each(function(e,a){var a=n(a).closest("tr.evf-"+o+"-field_"+s).find("th"),t="everest_forms[form_fields]["+s+"]["+(parseInt(a.closest("tr").index())+1)+"]";a.children().is("label")?a.children().find("#"+t).show():(a.parents("span.input-wrapper").length?a.parents("span.input-wrapper"):a).append('")})):n("#"+i).hasClass("evf-field-address")?(r=n('[id^="'+("evf-"+o+"-field_"+s)+'"]')).each(function(e,a){var t=String(n(a).attr("id"));(t.includes("-container")||t.includes("-address2")||void 0!==n(a).val())&&r.splice(e,1)}):r=n("#"+("evf-"+o+"-field_"+s)),r.addClass("evf-error"),r.attr("aria-invalid",!0),r.first().closest(".evf-field").addClass("everest-forms-invalid evf-has-error"),!0!==a||r.is("label")||(r.parents("span.input-wrapper").length?r.parents("span.input-wrapper"):r).after('").show()}),d.attr("disabled",!1).html(everest_forms_ajax_submission_params.submit)}}).fail(function(){d.attr("disabled",!1).html(everest_forms_ajax_submission_params.submit),i.trigger("focusout").trigger("change"),i.closest(".everest-forms").find(".everest-forms-notice").remove(),i.closest(".everest-forms").prepend('").focus()}).always(function(e){!(e.data&&e.data.redirect_url?e.data.redirect_url:"")&&n(".everest-forms-notice").length&&n([document.documentElement,document.body]).animate({scrollTop:n(".everest-forms-notice").offset().top},800)}))})})})}); \ No newline at end of file diff --git a/languages/everest-forms.pot b/languages/everest-forms.pot index ef6efda2e..6b2547dda 100644 --- a/languages/everest-forms.pot +++ b/languages/everest-forms.pot @@ -9,7 +9,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2023-08-17T12:37:49+02:00\n" +"POT-Creation-Date: 2023-08-18T12:29:10+02:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.8.1\n" "X-Domain: everest-forms\n" @@ -1093,7 +1093,7 @@ msgid "Enter the subject of the email. Learn msgstr "" #: includes/admin/builder/class-evf-builder-settings.php:567 -msgid "Enable email prompt" +msgid "Enable Email Prompt" msgstr "" #: includes/admin/builder/class-evf-builder-settings.php:581 @@ -1102,8 +1102,7 @@ msgstr "" #. translators: %1$s - general settings docs url #: includes/admin/builder/class-evf-builder-settings.php:586 -#: includes/admin/builder/class-evf-builder-settings.php:608 -msgid "Enter the message of the email. Learn More" +msgid "Enter the email message prompt. Learn More" msgstr "" #: includes/admin/builder/class-evf-builder-settings.php:604 @@ -1114,6 +1113,11 @@ msgstr "" msgid "{all_fields}" msgstr "" +#. translators: %1$s - general settings docs url +#: includes/admin/builder/class-evf-builder-settings.php:608 +msgid "Enter the message of the email. Learn More" +msgstr "" + #. translators: %s - all fields smart tag. #: includes/admin/builder/class-evf-builder-settings.php:616 msgid "To display all form fields, use the %s Smart Tag."