From 1ccd5047dfc79ff633f5db274cef8dbad3b38f64 Mon Sep 17 00:00:00 2001
From: Matthew Wire <mjw@mjwconsult.co.uk>
Date: Sat, 8 Feb 2020 20:02:11 +0000
Subject: [PATCH] Tweak how we scroll to errors on form

---
 js/civicrm_stripe.js     | 23 ++++++++++++++++++-----
 js/civicrm_stripe.min.js |  2 +-
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/js/civicrm_stripe.js b/js/civicrm_stripe.js
index b7b4e174..df142b13 100644
--- a/js/civicrm_stripe.js
+++ b/js/civicrm_stripe.js
@@ -74,7 +74,7 @@ CRM.$(function($) {
       submitButtons[i].removeAttribute('disabled');
     }
     triggerEvent('crmBillingFormNotValid');
-    notifyUser('error', '', result.error.message, '#card-element');
+    notifyUser('error', '', error.message, '#card-element');
   }
 
   function handleCardPayment() {
@@ -342,10 +342,23 @@ CRM.$(function($) {
         return false;
       }
 
+      var cardError = CRM.$('#card-errors').text();
       if (CRM.$('#card-element.StripeElement--empty').length) {
         debugging('card details not entered!');
-        $('div#card-errors').hide();
-        notifyUser('error', '', ts('Please fill in the card details!', '#card-element'));
+        if (!cardError) {
+          cardError = ts('Please fill in your card details!');
+        }
+        notifyUser('error', '', cardError, '#card-element');
+        triggerEvent('crmBillingFormNotValid');
+        return false;
+      }
+
+      if (CRM.$('#card-element.StripeElement--invalid').length) {
+        if (!cardError) {
+          cardError = ts('Please check your card details!');
+        }
+        debugging('card details not valid!');
+        notifyUser('error', '', cardError, '#card-element');
         triggerEvent('crmBillingFormNotValid');
         return false;
       }
@@ -713,7 +726,7 @@ CRM.$(function($) {
    */
   function notifyUser(icon, title, text, scrollToElement) {
     if (typeof Swal === 'function') {
-      swalParams = {
+      var swalParams = {
         icon: icon,
         text: text
       };
@@ -721,7 +734,7 @@ CRM.$(function($) {
         swalParams.title = title;
       }
       if (scrollToElement) {
-        swalParams.onAfterClose = function() { document.querySelector(scrollToElement).scrollIntoView(); window.scrollBy(0, -50); };
+        swalParams.onAfterClose = function() { window.scrollTo($(scrollToElement).position()); };
       }
       Swal.fire(swalParams);
     }
diff --git a/js/civicrm_stripe.min.js b/js/civicrm_stripe.min.js
index 05677296..2e21b4ef 100644
--- a/js/civicrm_stripe.min.js
+++ b/js/civicrm_stripe.min.js
@@ -1 +1 @@
-CRM.$(function(e){h("civicrm_stripe loaded, dom-ready function firing.");if(window.civicrmStripeHandleReload){h("calling existing civicrmStripeHandleReload.");window.civicrmStripeHandleReload();return}var u;var b;var c;var y;var s=false;window.onbeforeunload=null;window.civicrmStripeHandleReload=function(){h("civicrmStripeHandleReload");var F=document.getElementById("card-element");if((typeof F!=="undefined")&&(F)){if(!F.children.length){h("checkAndLoad from document.ready");q()}}d("crmBillingFormReloadComplete")};window.civicrmStripeHandleReload();function z(H,F){h(H+": success - submitting form");var G=document.createElement("input");G.setAttribute("type","hidden");G.setAttribute("name",H);G.setAttribute("value",F.id);c.appendChild(G);c.submit()}function t(){for(i=0;i<y.length;++i){y[i].setAttribute("disabled",true)}return c.submit()}function k(G){h("error: "+G.message);var F=document.getElementById("card-errors");F.style.display="block";F.textContent=G.message;c.dataset.submitted=false;for(i=0;i<y.length;++i){y[i].removeAttribute("disabled")}d("crmBillingFormNotValid");l("error","",result.error.message,"#card-element")}function D(){h("handle card payment");u.createPaymentMethod("card",b).then(function(F){if(F.error){k(F.error)}else{if(j()||a()){z("paymentMethodID",F.paymentMethod)}else{var G=CRM.url("civicrm/stripe/confirm-payment");e.post(G,{payment_method_id:F.paymentMethod.id,amount:v().toFixed(2),currency:CRM.vars.stripe.currency,id:CRM.vars.stripe.id,description:document.title,csrfToken:CRM.vars.stripe.csrfToken}).then(function(H){A(H)})}}})}function A(F){h("handleServerResponse");if(F.error){k(F.error)}else{if(F.requires_action){w(F)}else{z("paymentIntentID",F.paymentIntent)}}}function w(F){u.handleCardAction(F.payment_intent_client_secret).then(function(G){if(G.error){k(G.error)}else{z("paymentIntentID",G.paymentIntent)}})}e(document).ajaxComplete(function(H,I,G){if((G.url.match("civicrm(/|%2F)payment(/|%2F)form")!==null)||(G.url.match("civicrm(/|%2F)contact(/|%2F)view(/|%2F)participant")!==null)){if(typeof CRM.vars.stripe==="undefined"){return}var F=o();if(F!==null){if(F!==parseInt(CRM.vars.stripe.id)){h("payment processor changed to id: "+F);if(F===0){return p()}CRM.api3("PaymentProcessor","getvalue",{"return":"user_name",id:F,payment_processor_type_id:CRM.vars.stripe.paymentProcessorTypeID}).done(function(J){var K=J.result;if(K){h("Setting new stripe key to: "+K);CRM.vars.stripe.publishableKey=K}else{return p()}h("checkAndLoad from ajaxComplete");q()})}}}});function p(){h("New payment processor is not Stripe, clearing CRM.vars.stripe");if((typeof b!=="undefined")&&(b)){h("destroying card element");b.destroy();b=undefined}delete (CRM.vars.stripe)}function q(){if(typeof CRM.vars.stripe==="undefined"){h("CRM.vars.stripe not defined! Not a Stripe processor?");return}if(typeof Stripe==="undefined"){if(s){return}s=true;h("Stripe.js is not loaded!");e.getScript("https://js.stripe.com/v3",function(){h("Script loaded and executed.");s=false;g()})}else{g()}}function g(){h("loadStripeBillingBlock");if(typeof u==="undefined"){u=Stripe(CRM.vars.stripe.publishableKey)}var M=u.elements({locale:CRM.vars.stripe.locale});var J={base:{fontSize:"20px"}};var G=document.getElementById("billing_postal_code-"+CRM.vars.stripe.billingAddressID).value;h("existing postcode: "+G);b=M.create("card",{style:J,value:{postalCode:G}});b.mount("#card-element");h("created new card element",b);if(document.getElementById("billing_postal_code-5").value){document.getElementById("billing_postal_code-5").setAttribute("disabled",true)}else{document.getElementsByClassName("billing_postal_code-"+CRM.vars.stripe.billingAddressID+"-section")[0].setAttribute("hidden",true)}b.addEventListener("change",function(N){m(N)});c=n();if(typeof c.length==="undefined"||c.length===0){h("No billing form!");return}f();y=E();c.dataset.submitdontprocess=false;var F=c.querySelectorAll('[type="submit"][formnovalidate="1"], [type="submit"][formnovalidate="formnovalidate"], [type="submit"].cancel, [type="submit"].webform-previous'),I;for(I=0;I<F.length;++I){F[I].addEventListener("click",L())}function L(){h("adding submitdontprocess");c.dataset.submitdontprocess=true}for(I=0;I<y.length;++I){y[I].addEventListener("click",H)}function H(N){if(c.dataset.submitted===true){return}c.dataset.submitted=true;if(typeof CRM.vars.stripe==="undefined"){return t()}h("clearing submitdontprocess");c.dataset.submitdontprocess=false;return K(N)}for(I=0;I<y.length;++I){y[I].removeAttribute("onclick")}r();if(C()){e("[type=submit]").click(function(){x(this.value)});c.addEventListener("keydown",function(N){if(N.code==="Enter"){x(this.value);K(N)}});e("#billingcheckbox:input").hide();e('label[for="billingcheckbox"]').hide()}function K(P){P.preventDefault();h("submit handler");if(e(c).valid()===false){h("Form not valid");e("div#card-errors").hide();l("error","",ts("Please check and fill in all required fields!"),"#crm-container");d("crmBillingFormNotValid");return false}if(CRM.$("#card-element.StripeElement--empty").length){h("card details not entered!");e("div#card-errors").hide();l("error","",ts("Please fill in the card details!","#card-element"));d("crmBillingFormNotValid");return false}if(!(typeof grecaptcha==="undefined"||(grecaptcha&&grecaptcha.getResponse().length!==0))){h("recaptcha active and not valid");e("div#card-errors").hide();l("error","",ts("Please complete the reCaptcha"),".recaptcha-section");d("crmBillingFormNotValid");return false}if(typeof CRM.vars.stripe==="undefined"){h("Submitting - not a stripe processor");return true}if(c.dataset.submitted===true){h("form already submitted");return false}var R=parseInt(CRM.vars.stripe.id);var O=null;if(C()){if(!e('input[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]').length){O=R}else{O=parseInt(c.querySelector('input[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]:checked').value)}}else{if((c.querySelector(".crm-section.payment_processor-section")!==null)||(c.querySelector(".crm-section.credit_card_info-section")!==null)){R=CRM.vars.stripe.id;if(c.querySelector('input[name="payment_processor_id"]:checked')!==null){O=parseInt(c.querySelector('input[name="payment_processor_id"]:checked').value)}}}if((O===0)||(R===null)||((O===null)&&(R===null))){h("Not a Stripe transaction, or pay-later");return t()}else{h("Stripe is the selected payprocessor")}if(typeof CRM.vars.stripe.publishableKey==="undefined"){h("submit missing stripe-pub-key element or value");return true}if(c.dataset.submitdontprocess===true){h("non-payment submit detected - not submitting payment");return true}if(C()){if(e("#billing-payment-block").is(":hidden")){h("no payment processor on webform");return true}var Q=e('[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]');if(Q.length){if(Q.filter(":checked").val()==="0"||Q.filter(":checked").val()===0){h("no payment processor selected");return true}}}var N=v();if(N===0){h("Total amount is 0");return t()}if(c.dataset.submitted===true){alert("Form already submitted. Please wait.");return false}else{c.dataset.submitted=true}for(I=0;I<y.length;++I){y[I].setAttribute("disabled",true)}D();return true}}function C(){if(c!==null){return c.classList.contains("webform-client-form")||c.classList.contains("webform-submission-form")}return false}function n(){var F=e("div#card-element").closest("form").prop("id");if((typeof F==="undefined")||(!F.length)){F=e("input[name=hidden_processor]").closest("form").prop("id")}return document.getElementById(F)}function E(){var F=null;if(C()){F=c.querySelectorAll('[type="submit"].webform-submit');if(!F){F=c.querySelectorAll('[type="submit"].webform-button--submit')}}else{F=c.querySelectorAll('[type="submit"].validate')}return F}function v(){var F=0;if(a()){F=null}else{if(document.getElementById("totalTaxAmount")!==null){F=parseFloat(B());h("Calculated amount using internal calculateTaxAmount()")}else{if(typeof calculateTotalFee=="function"){F=parseFloat(calculateTotalFee())}else{if(C()){e(".line-item:visible","#wf-crm-billing-items").each(function(){F+=parseFloat(e(this).data("amount"))})}else{if(document.getElementById("total_amount")){F=parseFloat(document.getElementById("total_amount").value)}}}}}h("getTotalAmount: "+F);return F}function B(){var F=0;if(document.getElementById("totalTaxAmount")===null){return F}if(document.getElementById("totalTaxAmount").textContent.length===0){F=document.getElementById("total_amount").value}else{F=document.getElementById("totalTaxAmount").textContent.split(" ").pop()}return F}function j(){var F=false;if(C()){if(e('input[id$="contribution-installments"]').length!==0&&e('input[id$="contribution-installments"]').val()>1){F=true}}if(document.getElementById("is_recur")!==null){if(document.getElementById("is_recur").type=="hidden"){F=(document.getElementById("is_recur").value==1)}else{F=Boolean(document.getElementById("is_recur").checked)}}else{if(e('input[name="auto_renew"]').length!==0){if(e('input[name="auto_renew"]').prop("checked")){F=true}else{if(document.getElementById("auto_renew").type=="hidden"){F=(document.getElementById("auto_renew").value==1)}else{F=Boolean(document.getElementById("auto_renew").checked)}}}}h("isRecur is "+F);return F}function m(G){if(G.empty){e("div#card-errors").hide()}else{if(G.error){k(G.error)}else{if(G.complete){e("div#card-errors").hide();var F=document.getElementById("billing_postal_code-"+CRM.vars.stripe.billingAddressID);if(F){F.value=G.value.postalCode}}}}}function r(){cividiscountElements=c.querySelectorAll("input#discountcode");var F=function(G){if(G.code==="Enter"){G.preventDefault();h("adding submitdontprocess");c.dataset.submitdontprocess=true}};for(i=0;i<cividiscountElements.length;++i){cividiscountElements[i].addEventListener("keydown",F)}}function f(){e("div.label span.crm-marker").each(function(){e(this).closest("div").next("div").find("input").addClass("required")});var F=e(c).validate();F.settings.errorClass="error alert-danger";F.settings.ignore=".select2-offscreen, [readonly], :hidden:not(.crm-select2)"}function a(){if((document.getElementById("additional_participants")!==null)&&(document.getElementById("additional_participants").value.length!==0)){h("We don't know the final price - registering additional participants");return true}return false}function x(G){var F=null;if(document.getElementById("action")!==null){F=document.getElementById("action")}else{F=document.createElement("input")}F.setAttribute("type","hidden");F.setAttribute("name","op");F.setAttribute("id","action");F.setAttribute("value",G);c.appendChild(F)}function o(){if((typeof c==="undefined")||(!c)){c=n();if(!c){return null}}var F=c.querySelector('input[name="payment_processor_id"]:checked');if(F!==null){return parseInt(F.value)}return null}function h(F){if((typeof(CRM.vars.stripe)==="undefined")||(Boolean(CRM.vars.stripe.jsDebug)===true)){console.log(new Date().toISOString()+" civicrm_stripe.js: "+F)}}function d(F){h("Firing Event: "+F);e(c).trigger(F)}function l(G,I,H,F){if(typeof Swal==="function"){swalParams={icon:G,text:H};if(I){swalParams.title=I}if(F){swalParams.onAfterClose=function(){document.querySelector(F).scrollIntoView();window.scrollBy(0,-50)}}Swal.fire(swalParams)}}});
\ No newline at end of file
+CRM.$(function(e){h("civicrm_stripe loaded, dom-ready function firing.");if(window.civicrmStripeHandleReload){h("calling existing civicrmStripeHandleReload.");window.civicrmStripeHandleReload();return}var u;var b;var c;var y;var s=false;window.onbeforeunload=null;window.civicrmStripeHandleReload=function(){h("civicrmStripeHandleReload");var F=document.getElementById("card-element");if((typeof F!=="undefined")&&(F)){if(!F.children.length){h("checkAndLoad from document.ready");q()}}d("crmBillingFormReloadComplete")};window.civicrmStripeHandleReload();function z(H,F){h(H+": success - submitting form");var G=document.createElement("input");G.setAttribute("type","hidden");G.setAttribute("name",H);G.setAttribute("value",F.id);c.appendChild(G);c.submit()}function t(){for(i=0;i<y.length;++i){y[i].setAttribute("disabled",true)}return c.submit()}function k(G){h("error: "+G.message);var F=document.getElementById("card-errors");F.style.display="block";F.textContent=G.message;c.dataset.submitted=false;for(i=0;i<y.length;++i){y[i].removeAttribute("disabled")}d("crmBillingFormNotValid");l("error","",G.message,"#card-element")}function D(){h("handle card payment");u.createPaymentMethod("card",b).then(function(F){if(F.error){k(F.error)}else{if(j()||a()){z("paymentMethodID",F.paymentMethod)}else{var G=CRM.url("civicrm/stripe/confirm-payment");e.post(G,{payment_method_id:F.paymentMethod.id,amount:v().toFixed(2),currency:CRM.vars.stripe.currency,id:CRM.vars.stripe.id,description:document.title,csrfToken:CRM.vars.stripe.csrfToken}).then(function(H){A(H)})}}})}function A(F){h("handleServerResponse");if(F.error){k(F.error)}else{if(F.requires_action){w(F)}else{z("paymentIntentID",F.paymentIntent)}}}function w(F){u.handleCardAction(F.payment_intent_client_secret).then(function(G){if(G.error){k(G.error)}else{z("paymentIntentID",G.paymentIntent)}})}e(document).ajaxComplete(function(H,I,G){if((G.url.match("civicrm(/|%2F)payment(/|%2F)form")!==null)||(G.url.match("civicrm(/|%2F)contact(/|%2F)view(/|%2F)participant")!==null)){if(typeof CRM.vars.stripe==="undefined"){return}var F=o();if(F!==null){if(F!==parseInt(CRM.vars.stripe.id)){h("payment processor changed to id: "+F);if(F===0){return p()}CRM.api3("PaymentProcessor","getvalue",{"return":"user_name",id:F,payment_processor_type_id:CRM.vars.stripe.paymentProcessorTypeID}).done(function(J){var K=J.result;if(K){h("Setting new stripe key to: "+K);CRM.vars.stripe.publishableKey=K}else{return p()}h("checkAndLoad from ajaxComplete");q()})}}}});function p(){h("New payment processor is not Stripe, clearing CRM.vars.stripe");if((typeof b!=="undefined")&&(b)){h("destroying card element");b.destroy();b=undefined}delete (CRM.vars.stripe)}function q(){if(typeof CRM.vars.stripe==="undefined"){h("CRM.vars.stripe not defined! Not a Stripe processor?");return}if(typeof Stripe==="undefined"){if(s){return}s=true;h("Stripe.js is not loaded!");e.getScript("https://js.stripe.com/v3",function(){h("Script loaded and executed.");s=false;g()})}else{g()}}function g(){h("loadStripeBillingBlock");if(typeof u==="undefined"){u=Stripe(CRM.vars.stripe.publishableKey)}var M=u.elements({locale:CRM.vars.stripe.locale});var J={base:{fontSize:"20px"}};var G=document.getElementById("billing_postal_code-"+CRM.vars.stripe.billingAddressID).value;h("existing postcode: "+G);b=M.create("card",{style:J,value:{postalCode:G}});b.mount("#card-element");h("created new card element",b);if(document.getElementById("billing_postal_code-5").value){document.getElementById("billing_postal_code-5").setAttribute("disabled",true)}else{document.getElementsByClassName("billing_postal_code-"+CRM.vars.stripe.billingAddressID+"-section")[0].setAttribute("hidden",true)}b.addEventListener("change",function(N){m(N)});c=n();if(typeof c.length==="undefined"||c.length===0){h("No billing form!");return}f();y=E();c.dataset.submitdontprocess=false;var F=c.querySelectorAll('[type="submit"][formnovalidate="1"], [type="submit"][formnovalidate="formnovalidate"], [type="submit"].cancel, [type="submit"].webform-previous'),I;for(I=0;I<F.length;++I){F[I].addEventListener("click",L())}function L(){h("adding submitdontprocess");c.dataset.submitdontprocess=true}for(I=0;I<y.length;++I){y[I].addEventListener("click",H)}function H(N){if(c.dataset.submitted===true){return}c.dataset.submitted=true;if(typeof CRM.vars.stripe==="undefined"){return t()}h("clearing submitdontprocess");c.dataset.submitdontprocess=false;return K(N)}for(I=0;I<y.length;++I){y[I].removeAttribute("onclick")}r();if(C()){e("[type=submit]").click(function(){x(this.value)});c.addEventListener("keydown",function(N){if(N.code==="Enter"){x(this.value);K(N)}});e("#billingcheckbox:input").hide();e('label[for="billingcheckbox"]').hide()}function K(P){P.preventDefault();h("submit handler");if(e(c).valid()===false){h("Form not valid");e("div#card-errors").hide();l("error","",ts("Please check and fill in all required fields!"),"#crm-container");d("crmBillingFormNotValid");return false}var Q=CRM.$("#card-errors").text();if(CRM.$("#card-element.StripeElement--empty").length){h("card details not entered!");if(!Q){Q=ts("Please fill in your card details!")}l("error","",Q,"#card-element");d("crmBillingFormNotValid");return false}if(CRM.$("#card-element.StripeElement--invalid").length){if(!Q){Q=ts("Please check your card details!")}h("card details not valid!");l("error","",Q,"#card-element");d("crmBillingFormNotValid");return false}if(!(typeof grecaptcha==="undefined"||(grecaptcha&&grecaptcha.getResponse().length!==0))){h("recaptcha active and not valid");e("div#card-errors").hide();l("error","",ts("Please complete the reCaptcha"),".recaptcha-section");d("crmBillingFormNotValid");return false}if(typeof CRM.vars.stripe==="undefined"){h("Submitting - not a stripe processor");return true}if(c.dataset.submitted===true){h("form already submitted");return false}var S=parseInt(CRM.vars.stripe.id);var O=null;if(C()){if(!e('input[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]').length){O=S}else{O=parseInt(c.querySelector('input[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]:checked').value)}}else{if((c.querySelector(".crm-section.payment_processor-section")!==null)||(c.querySelector(".crm-section.credit_card_info-section")!==null)){S=CRM.vars.stripe.id;if(c.querySelector('input[name="payment_processor_id"]:checked')!==null){O=parseInt(c.querySelector('input[name="payment_processor_id"]:checked').value)}}}if((O===0)||(S===null)||((O===null)&&(S===null))){h("Not a Stripe transaction, or pay-later");return t()}else{h("Stripe is the selected payprocessor")}if(typeof CRM.vars.stripe.publishableKey==="undefined"){h("submit missing stripe-pub-key element or value");return true}if(c.dataset.submitdontprocess===true){h("non-payment submit detected - not submitting payment");return true}if(C()){if(e("#billing-payment-block").is(":hidden")){h("no payment processor on webform");return true}var R=e('[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]');if(R.length){if(R.filter(":checked").val()==="0"||R.filter(":checked").val()===0){h("no payment processor selected");return true}}}var N=v();if(N===0){h("Total amount is 0");return t()}if(c.dataset.submitted===true){alert("Form already submitted. Please wait.");return false}else{c.dataset.submitted=true}for(I=0;I<y.length;++I){y[I].setAttribute("disabled",true)}D();return true}}function C(){if(c!==null){return c.classList.contains("webform-client-form")||c.classList.contains("webform-submission-form")}return false}function n(){var F=e("div#card-element").closest("form").prop("id");if((typeof F==="undefined")||(!F.length)){F=e("input[name=hidden_processor]").closest("form").prop("id")}return document.getElementById(F)}function E(){var F=null;if(C()){F=c.querySelectorAll('[type="submit"].webform-submit');if(!F){F=c.querySelectorAll('[type="submit"].webform-button--submit')}}else{F=c.querySelectorAll('[type="submit"].validate')}return F}function v(){var F=0;if(a()){F=null}else{if(document.getElementById("totalTaxAmount")!==null){F=parseFloat(B());h("Calculated amount using internal calculateTaxAmount()")}else{if(typeof calculateTotalFee=="function"){F=parseFloat(calculateTotalFee())}else{if(C()){e(".line-item:visible","#wf-crm-billing-items").each(function(){F+=parseFloat(e(this).data("amount"))})}else{if(document.getElementById("total_amount")){F=parseFloat(document.getElementById("total_amount").value)}}}}}h("getTotalAmount: "+F);return F}function B(){var F=0;if(document.getElementById("totalTaxAmount")===null){return F}if(document.getElementById("totalTaxAmount").textContent.length===0){F=document.getElementById("total_amount").value}else{F=document.getElementById("totalTaxAmount").textContent.split(" ").pop()}return F}function j(){var F=false;if(C()){if(e('input[id$="contribution-installments"]').length!==0&&e('input[id$="contribution-installments"]').val()>1){F=true}}if(document.getElementById("is_recur")!==null){if(document.getElementById("is_recur").type=="hidden"){F=(document.getElementById("is_recur").value==1)}else{F=Boolean(document.getElementById("is_recur").checked)}}else{if(e('input[name="auto_renew"]').length!==0){if(e('input[name="auto_renew"]').prop("checked")){F=true}else{if(document.getElementById("auto_renew").type=="hidden"){F=(document.getElementById("auto_renew").value==1)}else{F=Boolean(document.getElementById("auto_renew").checked)}}}}h("isRecur is "+F);return F}function m(G){if(G.empty){e("div#card-errors").hide()}else{if(G.error){k(G.error)}else{if(G.complete){e("div#card-errors").hide();var F=document.getElementById("billing_postal_code-"+CRM.vars.stripe.billingAddressID);if(F){F.value=G.value.postalCode}}}}}function r(){cividiscountElements=c.querySelectorAll("input#discountcode");var F=function(G){if(G.code==="Enter"){G.preventDefault();h("adding submitdontprocess");c.dataset.submitdontprocess=true}};for(i=0;i<cividiscountElements.length;++i){cividiscountElements[i].addEventListener("keydown",F)}}function f(){e("div.label span.crm-marker").each(function(){e(this).closest("div").next("div").find("input").addClass("required")});var F=e(c).validate();F.settings.errorClass="error alert-danger";F.settings.ignore=".select2-offscreen, [readonly], :hidden:not(.crm-select2)"}function a(){if((document.getElementById("additional_participants")!==null)&&(document.getElementById("additional_participants").value.length!==0)){h("We don't know the final price - registering additional participants");return true}return false}function x(G){var F=null;if(document.getElementById("action")!==null){F=document.getElementById("action")}else{F=document.createElement("input")}F.setAttribute("type","hidden");F.setAttribute("name","op");F.setAttribute("id","action");F.setAttribute("value",G);c.appendChild(F)}function o(){if((typeof c==="undefined")||(!c)){c=n();if(!c){return null}}var F=c.querySelector('input[name="payment_processor_id"]:checked');if(F!==null){return parseInt(F.value)}return null}function h(F){if((typeof(CRM.vars.stripe)==="undefined")||(Boolean(CRM.vars.stripe.jsDebug)===true)){console.log(new Date().toISOString()+" civicrm_stripe.js: "+F)}}function d(F){h("Firing Event: "+F);e(c).trigger(F)}function l(H,J,I,G){if(typeof Swal==="function"){var F={icon:H,text:I};if(J){F.title=J}if(G){F.onAfterClose=function(){window.scrollTo(e(G).position())}}Swal.fire(F)}}});
\ No newline at end of file
-- 
GitLab