|
|
|
|
@ -1,11 +1,66 @@ |
|
|
|
|
import $ from 'jquery'; |
|
|
|
|
import moment from 'moment'; |
|
|
|
|
import {api} from './api'; |
|
|
|
|
import "modal-video/js/jquery-modal-video.js"; |
|
|
|
|
import "modal-video/css/modal-video.min.css"; |
|
|
|
|
import {email as emailValid} from 'vuelidate/lib/validators'; |
|
|
|
|
import Cookies from 'js-cookie' |
|
|
|
|
|
|
|
|
|
moment.locale('ru'); |
|
|
|
|
|
|
|
|
|
var selectedWeekdays = {}; |
|
|
|
|
$(document).ready(function () { |
|
|
|
|
let body = $('body'), |
|
|
|
|
popup = $('.popup.visible.open'), |
|
|
|
|
prevPopup = null; |
|
|
|
|
|
|
|
|
|
// CAPTURE EMAIL
|
|
|
|
|
const EMAIL_CAPTURED_COOKIE = 'email-captured'; |
|
|
|
|
|
|
|
|
|
if(window.LIL_STORE.user.id){ |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
api.captureEmail(email); |
|
|
|
|
hidePopup().then(() => { |
|
|
|
|
popup = prevPopup; |
|
|
|
|
}); |
|
|
|
|
$modalVideo.css('opacity', 1); |
|
|
|
|
Cookies.set(EMAIL_CAPTURED_COOKIE, 1); |
|
|
|
|
callback(); |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
$(".js-video-modal").each(function(){ |
|
|
|
|
const $this = $(this); |
|
|
|
|
const url = $this.data('videoUrl'); |
|
|
|
|
@ -31,11 +86,65 @@ $(document).ready(function () { |
|
|
|
|
} |
|
|
|
|
$this.attr('data-video-id', videoId); |
|
|
|
|
$this.attr('data-video-url', ''); |
|
|
|
|
$this.modalVideo({ channel }); |
|
|
|
|
$this.attr('data-channel', channel); |
|
|
|
|
$this.modalVideo({ channel, jsapi: true }); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
let body = $('body'), |
|
|
|
|
popup = $('.popup.visible.open'); |
|
|
|
|
$(".js-video-modal").on('player-created', e => { |
|
|
|
|
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 = () => { |
|
|
|
|
clearTimeout(timeout); |
|
|
|
|
if(! $('.modal-video').length){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
player.pauseVideo(); |
|
|
|
|
captureEmail(() => { |
|
|
|
|
player.playVideo(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
window.onYTPlayerStateChange = (event) => { |
|
|
|
|
if(event.data == YT.PlayerState.PLAYING && ! timeout){ |
|
|
|
|
timeout = setTimeout(pauseVideo, interval); |
|
|
|
|
} |
|
|
|
|
if(event.data == YT.PlayerState.ENDED && timeout){ |
|
|
|
|
clearTimeout(timeout); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
player.on('ended', () => { |
|
|
|
|
if(timeout){ |
|
|
|
|
clearTimeout(timeout); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
body.on('click', '[data-popup]', function(e){ |
|
|
|
|
const $this = $(this); |
|
|
|
|
@ -50,7 +159,6 @@ $(document).ready(function () { |
|
|
|
|
showPopup(); |
|
|
|
|
|
|
|
|
|
if(data === '.js-popup-buy') { |
|
|
|
|
console.log('reset selected'); |
|
|
|
|
popup.data('date-start', $this.data('date-start') || ''); |
|
|
|
|
popup.data('day', $this.data('day') || ''); |
|
|
|
|
$('[data-day]').prop('checked', false); |
|
|
|
|
@ -155,12 +263,15 @@ $(document).ready(function () { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('.js-popup-close').on('click', function(e){ |
|
|
|
|
if(popup.data('manual-close')){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
e.preventDefault(); |
|
|
|
|
hidePopup(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
body.on('click', '.js-outer', function(){ |
|
|
|
|
if (popup !== undefined) { |
|
|
|
|
if (popup !== undefined && ! popup.data('manual-close')) { |
|
|
|
|
hidePopup(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
@ -170,7 +281,9 @@ $(document).ready(function () { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$(document).keyup(function(e){ |
|
|
|
|
if (e.keyCode === 27) hidePopup(); |
|
|
|
|
if (e.keyCode === 27 && ! popup.data('manual-close')) { |
|
|
|
|
hidePopup(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -180,12 +293,16 @@ $(document).ready(function () { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function showPopup(){ |
|
|
|
|
if(! popup && popupName){ |
|
|
|
|
popup = $(popupName); |
|
|
|
|
} |
|
|
|
|
body.addClass('no-scroll'); |
|
|
|
|
popup.addClass('open'); |
|
|
|
|
return new Promise((resolve) => { |
|
|
|
|
setTimeout(function(){ |
|
|
|
|
popup.addClass('visible'); |
|
|
|
|
resolve(); |
|
|
|
|
$(document).trigger('popup-opened', popup); |
|
|
|
|
}, 100); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
@ -202,6 +319,7 @@ $(document).ready(function () { |
|
|
|
|
setTimeout(function(){ |
|
|
|
|
popup.removeClass('open'); |
|
|
|
|
resolve(); |
|
|
|
|
$(document).trigger('popup-closed', popup); |
|
|
|
|
}, 300); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|