$(document).ready(function(){ /* start video entry */ $('.main .video-wrapper .video video, .wrapper .box .video video, .factsheet-bilder .video video').click(function(e) { /*if(this.paused) { this.play(); $(this).closest('.video').addClass('playing'); } else { this.pause(); $(this).closest('.video').removeClass('playing'); }*/ if(!$(this).closest('.video').hasClass('playing')){ this.play(); $(this).closest('.video').addClass('playing'); }else{ if(this.paused) { this.play(); } else { this.pause(); } } e.stopPropagation(); }); $('.main .video-wrapper .video .video-play').click(function(e) { $(this).prevAll('video').click(); e.stopPropagation(); }); $('.main .video-wrapper .video-darkening').click(function(e) { var $video = $(this).prev('.video').find('video'); $video[0].pause(); $video.closest('.video').removeClass('playing'); }); $('.wrapper .pfbox .video').click(function(e) { $(this).find('video').click(); $(this).find('video, .video-progress-bar').css('left', (- parseInt($(this).parents('.box').css('left'))) + "px"); e.stopPropagation(); }); $('.wrapper .pfbox .video-darkening').click(function(e) { //$(this).prev('.video').find('video').click(); var $video = $(this).prev('.video').find('video'); $video[0].pause(); $video.closest('.video').removeClass('playing'); }); $('.wrapper .bildbox .video-slide').click(function(e) { $('.vid_' + $(this).data('vid')).find('video').click(); e.stopPropagation(); }); $('.wrapper .bildbox .video-darkening').click(function(e) { //$(this).prevAll('video').click(); var $videos = $(this).prevAll('video'); $videos.each(function(){ $(this)[0].pause(); $(this).closest('.video').removeClass('playing'); }); }); $('.factsheet-bilder .video .video-play').click(function(e) { $(this).nextAll('video').click(); e.stopPropagation(); }); $('.factsheet-bilder .video .video-darkening').click(function(e) { //$(this).closest('.video').find('video').click(); var $video = $(this).closest('.video').find('video'); $video[0].pause(); $video.closest('.video').removeClass('playing'); }); /* video progress-bar */ $('.main .video-wrapper .video video, .wrapper .box .video video, .factsheet-bilder .video video').on('timeupdate', function() { updateVideoUI(this); }); $('.main .video-wrapper .video video, .wrapper .box .video video, .factsheet-bilder .video video').on('progress', function() { updateVideoUI(this); }); $('.main .video-wrapper .video .video-progress-bar, .wrapper .box .video .video-progress-bar, .factsheet-bilder .video .video-progress-bar').click(function(e) { var video = $(this).prevAll('video')[0]; video.currentTime = (e.pageX - $(this).offset().left) / $(this).width() * video.duration; updateVideoUI(video); e.stopPropagation(); }); /* end video progress-bar */ /* end video entry */ /* start login bildlink */ var maxlength = 0; var links = $('.main-col.right').children().children('.bildlink'); for(var i = 0; i < links.length; i++){ if($(links[i]).children('span').width() > maxlength){ maxlength = $(links[i]).children('span').width(); } console.log(maxlength); } $('.main-col.right').children().children('.bildlink').children('span').css('width',maxlength+50+'px'); /* end login bildlink */ }); // video helper function to update progress-bar function updateVideoUI(video) { if(video.buffered.length > 0) { $(video).nextAll('.video-progress-bar').find('.video-seek-bar').css('width',((video.buffered.end(0) - video.buffered.start(0)) * 100 / video.duration) + "%"); } $(video).nextAll('.video-progress-bar').find('.video-play-bar').css('width',(video.currentTime * 100 / video.duration) + "%"); }