commit
05f0a0e860
|
@ -352,7 +352,7 @@ $config['enable_embedding'] = true;
|
||||||
|
|
||||||
$config['youtube_js_html'] = '<div class="video-container" data-video="$2">'.
|
$config['youtube_js_html'] = '<div class="video-container" data-video="$2">'.
|
||||||
'<a href="https://youtu.be/$2" target="_blank" class="file">'.
|
'<a href="https://youtu.be/$2" target="_blank" class="file">'.
|
||||||
'<img style="width:255px;height:190px;" src="//img.youtube.com/vi/$2/0.jpg" class="post-image"/>'.
|
'https://youtu.be/$2'.
|
||||||
'</a></div>';
|
'</a></div>';
|
||||||
|
|
||||||
$config['embedding'] = array();
|
$config['embedding'] = array();
|
||||||
|
|
|
@ -24,22 +24,35 @@
|
||||||
|
|
||||||
|
|
||||||
onready(function(){
|
onready(function(){
|
||||||
var do_embed_yt = function(tag) {
|
const ON = "[Remove]";
|
||||||
$('div.video-container a', tag).click(function() {
|
const OFF = "[Embed]";
|
||||||
var videoID = $(this.parentNode).data('video');
|
|
||||||
|
function addEmbedButton(index, videoNode) {
|
||||||
$(this.parentNode).html('<iframe style="float:left;margin: 10px 20px" type="text/html" '+
|
videoNode = $(videoNode);
|
||||||
'width="360" height="270" src="//www.youtube.com/embed/' + videoID +
|
var videoId = videoNode.data('video');
|
||||||
|
var span = $("<span>[Embed]</span>");
|
||||||
|
var embedNode = $('<iframe style="float:left;margin: 10px 20px" type="text/html" '+
|
||||||
|
'width="360" height="270" src="//www.youtube.com/embed/' + videoId +
|
||||||
'?autoplay=1&html5=1" allowfullscreen frameborder="0"/>');
|
'?autoplay=1&html5=1" allowfullscreen frameborder="0"/>');
|
||||||
|
span.click(function() {
|
||||||
return false;
|
if (span.text() == ON){
|
||||||
|
embedNode.remove();
|
||||||
|
span.text(OFF);
|
||||||
|
} else{
|
||||||
|
videoNode.append(embedNode);
|
||||||
|
span.text(ON);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
|
||||||
do_embed_yt(document);
|
|
||||||
|
|
||||||
// allow to work with auto-reload.js, etc.
|
videoNode.append(span);
|
||||||
$(document).on('new_post', function(e, post) {
|
}
|
||||||
do_embed_yt(post);
|
|
||||||
});
|
$('div.video-container', document).each(addEmbedButton);
|
||||||
|
|
||||||
|
|
||||||
|
// allow to work with auto-reload.js, etc.
|
||||||
|
$(document).on('new_post', function(e, post) {
|
||||||
|
$('div.video-container', post).each(addEmbedButton);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue