added custom video overlay player to avoid to load all the iframe systematicly
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
(function($) {
|
||||
|
||||
Clameurs = function(){
|
||||
|
||||
function init(){
|
||||
console.log("Clameurs");
|
||||
initVideoEvents();
|
||||
}
|
||||
|
||||
function initVideoEvents(){
|
||||
|
||||
$('.field-type-video-embed-field a').on('click', clickVideo);
|
||||
|
||||
};
|
||||
|
||||
function clickVideo(event){
|
||||
event.preventDefault();
|
||||
console.log('Click video', this);
|
||||
var vid_src = $(this).attr('href');
|
||||
console.log("vid_src", vid_src);
|
||||
getEmVidField(vid_src);
|
||||
return false;
|
||||
};
|
||||
|
||||
function getEmVidField(src){
|
||||
$.getJSON('clameursmod/getemvidfield',
|
||||
{'src':src},
|
||||
function(json){
|
||||
console.log("json loaded", json);
|
||||
displayVid(json)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
function displayVid(json){
|
||||
$('#videoframe').remove();
|
||||
|
||||
$vid = $('<div>')
|
||||
.attr('id', 'videoframe')
|
||||
.append(json.embed)
|
||||
.hide()
|
||||
.appendTo('body');
|
||||
|
||||
var iframe = $('iframe', $vid)[0];
|
||||
|
||||
var winwidth = $(window).width();
|
||||
var winheight = $(window).height();
|
||||
console.log('win :'+winwidth+' | '+winheight);
|
||||
|
||||
if (winwidth > winheight) {
|
||||
var w = winwidth*0.9;
|
||||
var h = w*(360/640);
|
||||
}else{
|
||||
var h = winheight*0.9;
|
||||
var w = h*(640/360);
|
||||
}
|
||||
|
||||
console.log('win :'+w+' | '+h);
|
||||
|
||||
$.openDOMWindow({
|
||||
loader:0,
|
||||
windowPadding:10,
|
||||
overlay:1,
|
||||
overlayColor:'#fff',
|
||||
overlayOpacity:'90',
|
||||
borderColor:'transparent',
|
||||
borderSize:'0',
|
||||
width:w,
|
||||
height:h,
|
||||
windowSourceID:"#videoframe"
|
||||
});
|
||||
}
|
||||
|
||||
init();
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
var clameurs = new Clameurs();
|
||||
});
|
||||
|
||||
|
||||
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user