Add/remove tight container class on window resize

[MAILPOET-2740]
This commit is contained in:
Pavel Dohnal
2020-04-13 11:08:09 +02:00
committed by Veljko V
parent 94b3842c58
commit 68c4f96966

View File

@@ -92,6 +92,19 @@ jQuery(($) => {
showForm(formDiv, showOverlay);
});
$(window).resize(() => {
$('.mailpoet_form').each((index, element) => {
// Detect form is placed in tight container
const formDiv = $(element);
const form = formDiv.find('form');
if (form.width() < 500) {
form.addClass('mailpoet_form_tight_container');
} else {
form.removeClass('mailpoet_form_tight_container');
}
});
});
// setup form validation
$('form.mailpoet_form').each((index, element) => {
const form = $(element);