forked from Victa/HTML5-Background-Video
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.backgroundvideo.min.js
More file actions
8 lines (8 loc) · 1.62 KB
/
jquery.backgroundvideo.min.js
File metadata and controls
8 lines (8 loc) · 1.62 KB
1
2
3
4
5
6
7
8
/*
* jQuery Background video plugin for jQuery
* ---
* Copyright 2011, Victor Coulon (http://victorcoulon.fr)
* Released under the MIT, BSD, and GPL Licenses.
* based on jQuery Plugin Boilerplate 1.3
*/
(function(a){a.backgroundVideo=function(d,j){var e={videoid:"video_background"};var f=this;f.settings={};var h=function(){f.settings=a.extend({},e,j);f.el=d;b()};var b=function(){var l="";l+='<video id="'+f.settings.videoid+'" preload="auto" autoplay="autoplay" loop="loop"';l+='style="display:none;position:fixed;top:0;left:0;bottom:0;right:0;z-index:-100;width:100%;height:100%;">';for(var k=0;k<f.settings.types.length;k++){l+='<source src="'+f.settings.path+f.settings.filename+"."+f.settings.types[k]+'" type="video/'+f.settings.types[k]+'" />'}l+="bgvideo</video>";f.el.prepend(l);f.videoEl=document.getElementById(f.settings.videoid);f.$videoEl=a(f.videoEl);f.$videoEl.fadeIn(2000);c()};var c=function(){var k=i();f.$videoEl.width(k*f.settings.width);f.$videoEl.height(k*f.settings.height);if(typeof f.settings.align!=="undefined"){g()}};var i=function(){var l=a(window).width();var o=a(window).height();var k=l/o;var n=f.settings.width/f.settings.height;var m=o/f.settings.height;if(k>=n){m=l/f.settings.width}return m};var g=function(){var l=((a(window).width()>>1)-(f.$videoEl.width()>>1))|0;var k=((a(window).height()>>1)-(f.$videoEl.height()>>1))|0;if(f.settings.align=="centerXY"){f.$videoEl.css({left:l,top:k});return}if(f.settings.align=="centerX"){f.$videoEl.css("left",l);return}if(f.settings.align=="centerY"){f.$videoEl.css("top",k);return}};h();a(window).resize(function(){c()});f.$videoEl.bind("ended",function(){this.play()})}})(jQuery);