Make the event namespaced to prevent conflicts
[MAILPOET-3057]
This commit is contained in:
@@ -3,6 +3,8 @@ import jQuery from 'jquery';
|
|||||||
import Cookies from 'js-cookie';
|
import Cookies from 'js-cookie';
|
||||||
import 'parsleyjs';
|
import 'parsleyjs';
|
||||||
|
|
||||||
|
const exitIntentEvent = 'mouseleave.mailpoet.form-exit-intent';
|
||||||
|
|
||||||
jQuery(($) => {
|
jQuery(($) => {
|
||||||
window.reCaptchaCallback = function reCaptchaCallback() {
|
window.reCaptchaCallback = function reCaptchaCallback() {
|
||||||
$('.mailpoet_recaptcha').each((index, element) => {
|
$('.mailpoet_recaptcha').each((index, element) => {
|
||||||
@@ -91,16 +93,16 @@ jQuery(($) => {
|
|||||||
delay = 0;
|
delay = 0;
|
||||||
}
|
}
|
||||||
const timeout = setTimeout(() => {
|
const timeout = setTimeout(() => {
|
||||||
$(document).off('mouseleave');
|
$(document).off(exitIntentEvent);
|
||||||
doDisplayForm(formDiv, showOverlay);
|
doDisplayForm(formDiv, showOverlay);
|
||||||
}, delay * 1000);
|
}, delay * 1000);
|
||||||
|
|
||||||
const exitIntentEnabled = form.data('exit-intent-enabled');
|
const exitIntentEnabled = form.data('exit-intent-enabled');
|
||||||
if (exitIntentEnabled) {
|
if (exitIntentEnabled) {
|
||||||
$(document).on('mouseleave', () => {
|
$(document).on(exitIntentEvent, () => {
|
||||||
doDisplayForm(formDiv, showOverlay);
|
$(document).off(exitIntentEvent);
|
||||||
$(document).off('mouseleave');
|
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
|
doDisplayForm(formDiv, showOverlay);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user