Fix public.js to follow eslint rules
[MAILPOET-1567]
This commit is contained in:
@@ -62,49 +62,51 @@ function ( // eslint-disable-line func-names
|
|||||||
endpoint: 'subscribers',
|
endpoint: 'subscribers',
|
||||||
action: 'subscribe',
|
action: 'subscribe',
|
||||||
data: formData.data
|
data: formData.data
|
||||||
}).fail(function (response) { // eslint-disable-line func-names
|
})
|
||||||
form.find('.mailpoet_validate_error').html(
|
.fail(function handleFailedPost(response) {
|
||||||
response.errors.map(function (error) { // eslint-disable-line func-names
|
form.find('.mailpoet_validate_error').html(
|
||||||
return error.message;
|
response.errors.map(function buildErrorMessage(error) {
|
||||||
}).join('<br />')
|
return error.message;
|
||||||
).show();
|
}).join('<br />')
|
||||||
}).done(function (response) { // eslint-disable-line func-names
|
).show();
|
||||||
if (window.grecaptcha && formData.recaptcha) {
|
})
|
||||||
window.grecaptcha.reset(formData.recaptcha);
|
.done(function handleRecaptcha(response) {
|
||||||
}
|
if (window.grecaptcha && formData.recaptcha) {
|
||||||
return response;
|
window.grecaptcha.reset(formData.recaptcha);
|
||||||
}).done(function (response) { // eslint-disable-line func-names
|
}
|
||||||
// successfully subscribed
|
return response;
|
||||||
if (
|
})
|
||||||
response.meta !== undefined
|
.done(function handleSuccess(response) {
|
||||||
|
// successfully subscribed
|
||||||
|
if (
|
||||||
|
response.meta !== undefined
|
||||||
&& response.meta.redirect_url !== undefined
|
&& response.meta.redirect_url !== undefined
|
||||||
) {
|
) {
|
||||||
// go to page
|
// go to page
|
||||||
window.location.href = response.meta.redirect_url;
|
window.location.href = response.meta.redirect_url;
|
||||||
} else {
|
} else {
|
||||||
// display success message
|
// display success message
|
||||||
form.find('.mailpoet_validate_success').show();
|
form.find('.mailpoet_validate_success').show();
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset form
|
// reset form
|
||||||
form.trigger('reset');
|
form.trigger('reset');
|
||||||
// reset validation
|
// reset validation
|
||||||
parsley.reset();
|
parsley.reset();
|
||||||
// reset captcha
|
// reset captcha
|
||||||
if (window.grecaptcha && formData.recaptcha) {
|
if (window.grecaptcha && formData.recaptcha) {
|
||||||
window.grecaptcha.reset(formData.recaptcha);
|
window.grecaptcha.reset(formData.recaptcha);
|
||||||
}
|
}
|
||||||
|
|
||||||
// resize iframe
|
// resize iframe
|
||||||
if (
|
if (
|
||||||
window.frameElement !== null
|
window.frameElement !== null
|
||||||
&& MailPoet !== undefined
|
&& MailPoet !== undefined
|
||||||
&& MailPoet.Iframe
|
&& MailPoet.Iframe
|
||||||
) {
|
) {
|
||||||
MailPoet.Iframe.autoSize(window.frameElement);
|
MailPoet.Iframe.autoSize(window.frameElement);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user