1
0
mirror of https://github.com/ipdb/website.git synced 2024-11-12 00:04:48 +01:00
website/_src/_assets/js/_newsletter.js

37 lines
1018 B
JavaScript
Raw Normal View History

/* global jQuery */
/* eslint-disable spaced-comment */
//=include ajaxchimp/jquery.ajaxchimp.js
/* eslint-enable spaced-comment */
jQuery(($) => {
const form = $('.form--newsletter')
const formInput = form.find('.form__control')
const formLabel = form.find('.form__label')
form.ajaxChimp({
callback: formCallback
})
function formCallback(resp) {
if (resp.result === 'success') {
form.find('.input-group').css('display', 'none')
form.find('.form__help').css('display', 'none')
}
if (resp.result === 'error') {
form.find('.button')
.removeClass('disabled')
.text('Subscribe')
}
}
form.on('change', formInput, () => {
if (formInput.hasClass('error')) {
formInput.keypress(() => {
$(this).removeClass('error')
formLabel.removeClass('error').text('Your Email')
})
}
})
}); // eslint-disable-line semi