|
|
|
|
@ -21,43 +21,48 @@ $(document).ready(function () { |
|
|
|
|
Cookies.remove(EMAIL_CAPTURED_COOKIE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$('.js-popup-capture-email .js-popup-close').on('click', function(e){ |
|
|
|
|
e.preventDefault(); |
|
|
|
|
hidePopup().then(() => { |
|
|
|
|
popup = prevPopup; |
|
|
|
|
}); |
|
|
|
|
$('.modal-video').remove(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const captureEmail = (callback) => { |
|
|
|
|
prevPopup = popup; |
|
|
|
|
popup = $('.js-popup-capture-email'); |
|
|
|
|
const $modalVideo = $('.modal-video'); |
|
|
|
|
const $email = popup.find('.capture-email__email'); |
|
|
|
|
const $error = popup.find('.capture-email__error'); |
|
|
|
|
$modalVideo.css('opacity', 0); |
|
|
|
|
$email.val(''); |
|
|
|
|
$error.text(''); |
|
|
|
|
popup.css('z-index', 1000001); |
|
|
|
|
showPopup(); |
|
|
|
|
popup.find('.capture-email__btn').unbind('click').click(e => { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
const email = $email.val(); |
|
|
|
|
if(! email){ |
|
|
|
|
$error.text('Пожалуйста, укажите почту'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if(! emailValid(email)){ |
|
|
|
|
$error.text('Пожалуйста, укажите коректную почту'); |
|
|
|
|
return; |
|
|
|
|
const captureEmail = show => { |
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
prevPopup = popup; |
|
|
|
|
popup = $('.js-popup-capture-email'); |
|
|
|
|
const $email = popup.find('.capture-email__email'); |
|
|
|
|
const $error = popup.find('.capture-email__error'); |
|
|
|
|
$email.val(''); |
|
|
|
|
$error.text(''); |
|
|
|
|
popup.css('z-index', 1000001); |
|
|
|
|
if(show){ |
|
|
|
|
showPopup(); |
|
|
|
|
} |
|
|
|
|
api.captureEmail(email); |
|
|
|
|
hidePopup().then(() => { |
|
|
|
|
popup = prevPopup; |
|
|
|
|
$('.js-popup-capture-email .js-popup-close').unbind('click').on('click', e => { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
hidePopup().then(() => { |
|
|
|
|
popup = prevPopup; |
|
|
|
|
reject(); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
popup.find('.capture-email__btn').unbind('click').click(e => { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
const email = $email.val(); |
|
|
|
|
if(! email){ |
|
|
|
|
$error.text('Пожалуйста, укажите почту'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if(! emailValid(email)){ |
|
|
|
|
$error.text('Пожалуйста, укажите коректную почту'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
const $loader = popup.find('.loading-loader'); |
|
|
|
|
const $btn = popup.find('.capture-email__btn'); |
|
|
|
|
$loader.show(); |
|
|
|
|
$btn.prop('disabled', true); |
|
|
|
|
api.captureEmail(email).then(resolve).catch(reject).finally(() => { |
|
|
|
|
$btn.prop('disabled', false); |
|
|
|
|
$loader.hide(); |
|
|
|
|
hidePopup().then(() => { |
|
|
|
|
popup = prevPopup; |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
$modalVideo.css('opacity', 1); |
|
|
|
|
Cookies.set(EMAIL_CAPTURED_COOKIE, 1); |
|
|
|
|
callback(); |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
@ -94,27 +99,42 @@ $(document).ready(function () { |
|
|
|
|
if(window.LIL_STORE.user.id || ! $(e.target).data('trialLesson') || Cookies.get(EMAIL_CAPTURED_COOKIE)){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
let stopVideo = () => {}; |
|
|
|
|
let playVideo = () => {}; |
|
|
|
|
const channel = $(e.target).data('channel'); |
|
|
|
|
const $iframe = $('.modal-video-movie-wrap iframe'); |
|
|
|
|
const player = e.detail.player; |
|
|
|
|
let timeout = null; |
|
|
|
|
const interval = 1000 * 10;// 60 * 2; // 2 min
|
|
|
|
|
if(channel == 'youtube'){ |
|
|
|
|
const pauseVideo = () => { |
|
|
|
|
const pauseVideo = () => { |
|
|
|
|
timeout = setTimeout(() => { |
|
|
|
|
clearTimeout(timeout); |
|
|
|
|
if(! $('.modal-video').length){ |
|
|
|
|
const $modalVideo = $('.modal-video'); |
|
|
|
|
if(! $modalVideo.length){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
player.pauseVideo(); |
|
|
|
|
captureEmail(() => { |
|
|
|
|
player.playVideo(); |
|
|
|
|
if(channel == 'youtube'){ |
|
|
|
|
player.pauseVideo(); |
|
|
|
|
} |
|
|
|
|
else if(channel == 'vimeo'){ |
|
|
|
|
player.pause(); |
|
|
|
|
} |
|
|
|
|
$modalVideo.css('opacity', 0); |
|
|
|
|
captureEmail(true).then(() => { |
|
|
|
|
$modalVideo.css('opacity', 1); |
|
|
|
|
Cookies.set(EMAIL_CAPTURED_COOKIE, 1); |
|
|
|
|
if(channel == 'youtube'){ |
|
|
|
|
player.playVideo(); |
|
|
|
|
} |
|
|
|
|
else if(channel == 'vimeo'){ |
|
|
|
|
player.play(); |
|
|
|
|
} |
|
|
|
|
}).catch(() => { |
|
|
|
|
$('.modal-video').remove(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, interval); |
|
|
|
|
} |
|
|
|
|
if(channel == 'youtube'){ |
|
|
|
|
window.onYTPlayerStateChange = (event) => { |
|
|
|
|
if(event.data == YT.PlayerState.PLAYING && ! timeout){ |
|
|
|
|
timeout = setTimeout(pauseVideo, interval); |
|
|
|
|
pauseVideo(); |
|
|
|
|
} |
|
|
|
|
if(event.data == YT.PlayerState.ENDED && timeout){ |
|
|
|
|
clearTimeout(timeout); |
|
|
|
|
@ -123,19 +143,9 @@ $(document).ready(function () { |
|
|
|
|
player.addEventListener('onStateChange', 'onYTPlayerStateChange'); |
|
|
|
|
} |
|
|
|
|
else if (channel == 'vimeo'){ |
|
|
|
|
const pauseVideo = () => { |
|
|
|
|
clearTimeout(timeout); |
|
|
|
|
if(! $('.modal-video').length){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
player.pause(); |
|
|
|
|
captureEmail(() => { |
|
|
|
|
player.play(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
player.on('play', () => { |
|
|
|
|
if(! timeout){ |
|
|
|
|
timeout = setTimeout(pauseVideo, interval); |
|
|
|
|
pauseVideo(); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
player.on('ended', () => { |
|
|
|
|
@ -156,7 +166,6 @@ $(document).ready(function () { |
|
|
|
|
e.stopPropagation(); |
|
|
|
|
|
|
|
|
|
popup = $(data); |
|
|
|
|
showPopup(); |
|
|
|
|
|
|
|
|
|
if(data === '.js-popup-buy') { |
|
|
|
|
popup.data('date-start', $this.data('date-start') || ''); |
|
|
|
|
@ -260,6 +269,8 @@ $(document).ready(function () { |
|
|
|
|
window.location.href = `/gift-certificate/${code}/get`; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
showPopup(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('.js-popup-close').on('click', function(e){ |
|
|
|
|
|