Feature/end video popup 28 05 19 See merge request lilschool/site!309remotes/origin/feature/buy-email-5-06-19
commit
24ab061c5e
17 changed files with 173 additions and 58 deletions
|
After Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 82 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 93 KiB |
@ -0,0 +1,52 @@ |
||||
import $ from 'jquery'; |
||||
import {loadScript} from '../utils'; |
||||
import {api} from '../modules/api'; |
||||
|
||||
function getVideoPopup($videoEl){ |
||||
const $container = $videoEl.parent(); |
||||
const courseId = $videoEl.data('courseId'); |
||||
let $popup = $container.children('.video-ended-popup'); |
||||
if(! $popup[0]){ |
||||
$popup = $('<div class="video-ended-popup"><div class="video-ended-popup__like-btn"></div></div>'); |
||||
if(courseId){ |
||||
$popup.addClass('video-ended-popup_black'); |
||||
/* |
||||
$popup.find('.video-ended-popup__like-btn').click(() => { |
||||
api.likeCourse(courseId).then(() => { |
||||
$popup.addClass('video-ended-popup_black'); |
||||
}); |
||||
});*/ |
||||
} |
||||
|
||||
$container.append($popup); |
||||
} |
||||
return $popup; |
||||
} |
||||
|
||||
$(document).ready(function () { |
||||
$('.js-video').each(function (){ |
||||
const $iframe = $(this); |
||||
if($iframe.data('isYoutube')){ |
||||
|
||||
} |
||||
if($iframe.data('isVimeo')){ |
||||
loadScript('https://player.vimeo.com/api/player.js').then(() => { |
||||
const player = new Vimeo.Player(this); |
||||
player.on('pause', function(data) { |
||||
if(data.percent == 1){ |
||||
getVideoPopup($iframe).show().animate({opacity: 1}, 200); |
||||
if (document.fullscreenElement){ |
||||
document.exitFullscreen(); |
||||
} |
||||
} |
||||
}); |
||||
player.on('play', function() { |
||||
const $p = getVideoPopup($iframe); |
||||
if($p.is(':visible')){ |
||||
$p.animate({opacity: 0}, 800).then(() => {$p.hide();}); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
}); |
||||
}); |
||||
@ -0,0 +1 @@ |
||||
import "../modules/content"; |
||||
@ -0,0 +1 @@ |
||||
import "../modules/content"; |
||||
@ -1,14 +1,28 @@ |
||||
export const rupluralize = (value, args, addValue=true) => { |
||||
let digit = Math.trunc(value) + ''; |
||||
digit = digit[digit.length - 1]; |
||||
return (addValue ? value + ' ' : '') + |
||||
args[(+value > 10 && +value < 20) |
||||
? 2 |
||||
: (digit == '1' ? 0 : ('234'.search(digit) > -1 ? 1 : 2))]; |
||||
} |
||||
export const rupluralize = (value, args, addValue = true) => { |
||||
let digit = Math.trunc(value) + ''; |
||||
digit = digit[digit.length - 1]; |
||||
return (addValue ? value + ' ' : '') + |
||||
args[(+value > 10 && +value < 20) |
||||
? 2 |
||||
: (digit == '1' ? 0 : ('234'.search(digit) > -1 ? 1 : 2))]; |
||||
}; |
||||
|
||||
export const loadScript = (url, onload) => { |
||||
const tag = document.createElement('script'); |
||||
tag.url = url; |
||||
document.getElementsByTagName('body'); |
||||
} |
||||
return new Promise(resolve => { |
||||
for (let script of document.getElementsByTagName('script')) { |
||||
if (script.src == url) { |
||||
onload && onload(); |
||||
resolve(); |
||||
return; |
||||
} |
||||
} |
||||
const script = document.createElement('script'); |
||||
script.async = true; |
||||
document.body.appendChild(script); |
||||
script.onload = function () { |
||||
onload && onload.apply(this, arguments); |
||||
resolve.apply(this, arguments); |
||||
}; |
||||
script.src = url; |
||||
}); |
||||
}; |
||||
|
||||
Loading…
Reference in new issue