Commit a80712b8 authored by mattwire's avatar mattwire
Browse files

Add to CRM.payment.

parent 83140433
......@@ -108,6 +108,24 @@
return document.getElementById(billingFormID);
},
getBillingSubmit: function() {
var submit = null;
if (CRM.payment.getIsDrupalWebform()) {
submit = this.form.querySelectorAll('[type="submit"].webform-submit');
if (!submit) {
// drupal 8 webform
submit = this.form.querySelectorAll('[type="submit"].webform-button--submit');
}
}
else {
submit = this.form.querySelectorAll('[type="submit"].validate');
}
if (submit.length === 0) {
this.debugging(this.scriptName, 'No submit button found!');
}
return submit;
},
/**
* Are we creating a recurring contribution?
* @returns {boolean}
......@@ -181,8 +199,21 @@
}
document.addEventListener('DOMContentLoaded', function() {
CRM.payment.debugging(CRM.payment.scriptName, 'loaded via DOMContentLoaded');
CRM.payment.form = CRM.payment.getBillingForm();
});
// Re-prep form when we've loaded a new payproc via ajax or via webform
$(document).ajaxComplete(function(event, xhr, settings) {
// /civicrm/payment/form? occurs when a payproc is selected on page
// /civicrm/contact/view/participant occurs when payproc is first loaded on event credit card payment
// On wordpress these are urlencoded
if ((settings.url.match("civicrm(\/|%2F)payment(\/|%2F)form") !== null) ||
(settings.url.match("civicrm(\/|\%2F)contact(\/|\%2F)view(\/|\%2F)participant") !== null)) {
CRM.payment.debugging(CRM.payment.scriptName, 'triggered via ajax');
CRM.payment.form = CRM.payment.getBillingForm();
}
});
}(CRM.$));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment