2017-04-10 15:15:14 -07:00
|
|
|
(function ($) {
|
|
|
|
|
|
|
|
$(document).bind("DOMContentLoaded",
|
|
|
|
function () {
|
2017-04-11 14:37:42 -07:00
|
|
|
// TODO also grad maxwith and window padding data
|
2017-04-10 15:15:14 -07:00
|
|
|
var playBtn = '<i class="fa fa-play-circle-o play-button"></i>'
|
2017-04-11 14:37:42 -07:00
|
|
|
$('div[youtube_id]').each(function () {
|
|
|
|
var vid = $(this).attr('youtube_id');
|
|
|
|
var mw = $(this).attr('maxWidth');
|
|
|
|
var wp = $(this).attr('wPad');
|
|
|
|
var bgi = `style="background-image: url(https://i.ytimg.com/vi/${vid}/mqdefault.jpg)"`
|
|
|
|
var thumb = `<div class="thumb--yt" ${bgi} width="560" height="315">`
|
|
|
|
$(this).append(thumb).children().append(playBtn).click(insertIframe).fitToWindow(mw, wp)
|
|
|
|
})
|
2017-04-10 15:15:14 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
function insertIframe() {
|
|
|
|
var $box = $(this).parent()
|
2017-04-11 14:37:42 -07:00
|
|
|
var id = $box.attr('youtube_id')
|
|
|
|
var start = $box.attr("start") || 1
|
|
|
|
var list = ""
|
|
|
|
if ($box.attr("list")) { list = `&list=${$box.attr("list")}` }
|
|
|
|
var url = `https://www.youtube.com/embed/${id}?autoplay=1&start=${start}`
|
|
|
|
var vIframe = `<iframe width = "560" height = "315" src ="${url}${list}" frameborder = "0" allowfullscreen></iframe>`
|
|
|
|
$box.html(vIframe).children().fitToWindow($box.data("maxWidth"), $box.data("wPad"))
|
2017-04-10 15:15:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}(jQuery));
|