Skip to content
Snippets Groups Projects
Commit 1ccd5047 authored by mattwire's avatar mattwire
Browse files

Tweak how we scroll to errors on form

parent 4d0dee49
No related branches found
No related tags found
1 merge request!1096.4
......@@ -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);
}
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment