diff --git a/bower.json b/bower.json index 105f2c1e..ed6bd17a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "vide", - "version": "0.3.1", + "version": "0.3.2", "homepage": "http://vodkabears.github.io/vide/", "authors": [ "Ilya Makarov " diff --git a/dist/jquery.vide.js b/dist/jquery.vide.js index 88693ca2..8cef9c4c 100644 --- a/dist/jquery.vide.js +++ b/dist/jquery.vide.js @@ -1,5 +1,5 @@ /* - * Vide - v0.3.1 + * Vide - v0.3.2 * Easy as hell jQuery plugin for video backgrounds. * http://vodkabears.github.io/vide/ * @@ -66,9 +66,10 @@ option = arr[i]; // Ignore urls and a string without colon delimiters - if (option.search(/^(http|https|ftp):\/\//) !== -1 || - option.search(':') === -1) - { + if ( + option.search(/^(http|https|ftp):\/\//) !== -1 || + option.search(':') === -1 + ) { break; } @@ -166,21 +167,6 @@ $('').load(onLoad); } - /** - * Refresh current settings - * @private - * @param {Vide} vide - */ - function refreshSettings(vide) { - vide.$video.prop({ - autoplay: vide.settings.autoplay, - loop: vide.settings.loop, - volume: vide.settings.volume, - muted: vide.settings.muted, - playbackRate: vide.settings.playbackRate - }); - } - /** * Vide constructor * @param {HTMLElement} element @@ -287,9 +273,11 @@ if (vide.path.mp4) { sources += ''; } + if (vide.path.webm) { sources += ''; } + if (vide.path.ogv) { sources += ''; } @@ -307,7 +295,15 @@ vide.$video.css('visibility', 'hidden'); // Set video properties - refreshSettings(vide); + vide.$video.prop({ + autoplay: vide.settings.autoplay, + loop: vide.settings.loop, + volume: vide.settings.volume, + muted: vide.settings.muted, + defaultMuted: vide.settings.muted, + playbackRate: vide.settings.playbackRate, + defaultPlaybackRate: vide.settings.playbackRate + }); // Append a video vide.$wrapper.append(vide.$video); @@ -321,6 +317,7 @@ left: position.x, '-webkit-transform': 'translate(-' + position.x + ', -' + position.y + ')', '-ms-transform': 'translate(-' + position.x + ', -' + position.y + ')', + '-moz-transform': 'translate(-' + position.x + ', -' + position.y + ')', transform: 'translate(-' + position.x + ', -' + position.y + ')' }); @@ -328,11 +325,8 @@ vide.$video.on('canplaythrough.' + pluginName, function() { vide.$video.css('visibility', 'visible'); - // https://github.com/VodkaBears/Vide/pull/48 - refreshSettings(vide); - // Force to play, important for Safari - vide.settings.autoplay && vide.$video[0].play(); + vide.$video.prop('autoplay') && vide.$video[0].play(); vide.resize(); vide.$wrapper.css('background-image', 'none'); diff --git a/dist/jquery.vide.min.js b/dist/jquery.vide.min.js index 50fec61e..d6986100 100644 --- a/dist/jquery.vide.min.js +++ b/dist/jquery.vide.min.js @@ -1,9 +1,9 @@ /* - * Vide - v0.3.1 + * Vide - v0.3.2 * Easy as hell jQuery plugin for video backgrounds. * http://vodkabears.github.io/vide/ * * Made by Ilya Makarov * Under MIT License */ -!function(a,b,c,d){"use strict";function e(a){var b,c,d,e,f,g,h,i={};for(f=a.replace(/\s*:\s*/g,":").replace(/\s*,\s*/g,",").split(","),h=0,g=f.length;g>h&&(c=f[h],-1===c.search(/^(http|https|ftp):\/\//)&&-1!==c.search(":"));h++)b=c.indexOf(":"),d=c.substring(0,b),e=c.substring(b+1),e||(e=void 0),"string"==typeof e&&(e="true"===e||("false"===e?!1:e)),"string"==typeof e&&(e=isNaN(e)?e:+e),i[d]=e;return null==d&&null==e?a:i}function f(a){a=""+a;var b,c,d,e=a.split(/\s+/),f="50%",g="50%";for(d=0,b=e.length;b>d;d++)c=e[d],"left"===c?f="0%":"right"===c?f="100%":"top"===c?g="0%":"bottom"===c?g="100%":"center"===c?0===d?f="50%":g="50%":0===d?f=c:g=c;return{x:f,y:g}}function g(b,c){var d=function(){c(this.src)};a('').load(d),a('').load(d),a('').load(d),a('').load(d)}function h(a){a.$video.prop({autoplay:a.settings.autoplay,loop:a.settings.loop,volume:a.settings.volume,muted:a.settings.muted,playbackRate:a.settings.playbackRate})}function i(b,c,d){if(this.$element=a(b),"string"==typeof c&&(c=e(c)),d?"string"==typeof d&&(d=e(d)):d={},"string"==typeof c)c=c.replace(/\.\w*$/,"");else if("object"==typeof c)for(var f in c)c.hasOwnProperty(f)&&(c[f]=c[f].replace(/\.\w*$/,""));this.settings=a.extend({},k,d),this.path=c,this.init()}var j="vide",k={volume:1,playbackRate:1,muted:!0,loop:!0,autoplay:!0,position:"50% 50%",posterType:"detect",resizing:!0},l=/iPad|iPhone|iPod/i.test(d.userAgent),m=/Android/i.test(d.userAgent);i.prototype.init=function(){var b,c,d=this,e=f(d.settings.position);d.$wrapper=a("
").css({position:"absolute","z-index":-1,top:0,left:0,bottom:0,right:0,overflow:"hidden","-webkit-background-size":"cover","-moz-background-size":"cover","-o-background-size":"cover","background-size":"cover","background-repeat":"no-repeat","background-position":e.x+" "+e.y}),c=d.path,"object"==typeof d.path&&(d.path.poster?c=d.path.poster:d.path.mp4?c=d.path.mp4:d.path.webm?c=d.path.webm:d.path.ogv&&(c=d.path.ogv)),"detect"===d.settings.posterType?g(c,function(a){d.$wrapper.css("background-image","url("+a+")")}):"none"!==d.settings.posterType&&d.$wrapper.css("background-image","url("+c+"."+d.settings.posterType+")"),"static"===d.$element.css("position")&&d.$element.css("position","relative"),d.$element.prepend(d.$wrapper),l||m||(b="","object"==typeof d.path?(d.path.mp4&&(b+=''),d.path.webm&&(b+=''),d.path.ogv&&(b+=''),d.$video=a("")):d.$video=a(''),d.$video.css("visibility","hidden"),h(d),d.$wrapper.append(d.$video),d.$video.css({margin:"auto",position:"absolute","z-index":-1,top:e.y,left:e.x,"-webkit-transform":"translate(-"+e.x+", -"+e.y+")","-ms-transform":"translate(-"+e.x+", -"+e.y+")",transform:"translate(-"+e.x+", -"+e.y+")"}),d.$video.on("canplaythrough."+j,function(){d.$video.css("visibility","visible"),h(d),d.settings.autoplay&&d.$video[0].play(),d.resize(),d.$wrapper.css("background-image","none")}),d.$element.on("resize."+j,function(){d.settings.resizing&&d.resize()}))},i.prototype.getVideoObject=function(){return this.$video?this.$video[0]:null},i.prototype.resize=function(){if(this.$video){var a=this.$video[0].videoHeight,b=this.$video[0].videoWidth,c=this.$wrapper.height(),d=this.$wrapper.width();this.$video.css(d/b>c/a?{width:d+2,height:"auto"}:{width:"auto",height:c+2})}},i.prototype.destroy=function(){this.$element.off(j),this.$video&&this.$video.off(j),delete a[j].lookup[this.index],this.$element.removeData(j),this.$wrapper.remove()},a[j]={lookup:[]},a.fn[j]=function(b,c){var d;return this.each(function(){d=a.data(this,j),d&&d.destroy(),d=new i(this,b,c),d.index=a[j].lookup.push(d)-1,a.data(this,j,d)}),this},a(c).ready(function(){a(b).on("resize."+j,function(){for(var b,c=a[j].lookup.length,d=0;c>d;d++)b=a[j].lookup[d],b&&b.settings.resizing&&b.resize()}),a(c).find("[data-"+j+"-bg]").each(function(b,c){var d=a(c),e=d.data(j+"-options"),f=d.data(j+"-bg");d[j](f,e)})})}(window.jQuery,window,document,navigator); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(a){var b,c,d,e,f,g,h,i={};for(f=a.replace(/\s*:\s*/g,":").replace(/\s*,\s*/g,",").split(","),h=0,g=f.length;g>h&&(c=f[h],-1===c.search(/^(http|https|ftp):\/\//)&&-1!==c.search(":"));h++)b=c.indexOf(":"),d=c.substring(0,b),e=c.substring(b+1),e||(e=void 0),"string"==typeof e&&(e="true"===e||("false"===e?!1:e)),"string"==typeof e&&(e=isNaN(e)?e:+e),i[d]=e;return null==d&&null==e?a:i}function f(a){a=""+a;var b,c,d,e=a.split(/\s+/),f="50%",g="50%";for(d=0,b=e.length;b>d;d++)c=e[d],"left"===c?f="0%":"right"===c?f="100%":"top"===c?g="0%":"bottom"===c?g="100%":"center"===c?0===d?f="50%":g="50%":0===d?f=c:g=c;return{x:f,y:g}}function g(b,c){var d=function(){c(this.src)};a('').load(d),a('').load(d),a('').load(d),a('').load(d)}function h(b,c,d){if(this.$element=a(b),"string"==typeof c&&(c=e(c)),d?"string"==typeof d&&(d=e(d)):d={},"string"==typeof c)c=c.replace(/\.\w*$/,"");else if("object"==typeof c)for(var f in c)c.hasOwnProperty(f)&&(c[f]=c[f].replace(/\.\w*$/,""));this.settings=a.extend({},j,d),this.path=c,this.init()}var i="vide",j={volume:1,playbackRate:1,muted:!0,loop:!0,autoplay:!0,position:"50% 50%",posterType:"detect",resizing:!0},k=/iPad|iPhone|iPod/i.test(d.userAgent),l=/Android/i.test(d.userAgent);h.prototype.init=function(){var b,c,d=this,e=f(d.settings.position);d.$wrapper=a("
").css({position:"absolute","z-index":-1,top:0,left:0,bottom:0,right:0,overflow:"hidden","-webkit-background-size":"cover","-moz-background-size":"cover","-o-background-size":"cover","background-size":"cover","background-repeat":"no-repeat","background-position":e.x+" "+e.y}),c=d.path,"object"==typeof d.path&&(d.path.poster?c=d.path.poster:d.path.mp4?c=d.path.mp4:d.path.webm?c=d.path.webm:d.path.ogv&&(c=d.path.ogv)),"detect"===d.settings.posterType?g(c,function(a){d.$wrapper.css("background-image","url("+a+")")}):"none"!==d.settings.posterType&&d.$wrapper.css("background-image","url("+c+"."+d.settings.posterType+")"),"static"===d.$element.css("position")&&d.$element.css("position","relative"),d.$element.prepend(d.$wrapper),k||l||(b="","object"==typeof d.path?(d.path.mp4&&(b+=''),d.path.webm&&(b+=''),d.path.ogv&&(b+=''),d.$video=a("")):d.$video=a(''),d.$video.css("visibility","hidden"),d.$video.prop({autoplay:d.settings.autoplay,loop:d.settings.loop,volume:d.settings.volume,muted:d.settings.muted,defaultMuted:d.settings.muted,playbackRate:d.settings.playbackRate,defaultPlaybackRate:d.settings.playbackRate}),d.$wrapper.append(d.$video),d.$video.css({margin:"auto",position:"absolute","z-index":-1,top:e.y,left:e.x,"-webkit-transform":"translate(-"+e.x+", -"+e.y+")","-ms-transform":"translate(-"+e.x+", -"+e.y+")","-moz-transform":"translate(-"+e.x+", -"+e.y+")",transform:"translate(-"+e.x+", -"+e.y+")"}),d.$video.on("canplaythrough."+i,function(){d.$video.css("visibility","visible"),d.$video.prop("autoplay")&&d.$video[0].play(),d.resize(),d.$wrapper.css("background-image","none")}),d.$element.on("resize."+i,function(){d.settings.resizing&&d.resize()}))},h.prototype.getVideoObject=function(){return this.$video?this.$video[0]:null},h.prototype.resize=function(){if(this.$video){var a=this.$video[0].videoHeight,b=this.$video[0].videoWidth,c=this.$wrapper.height(),d=this.$wrapper.width();this.$video.css(d/b>c/a?{width:d+2,height:"auto"}:{width:"auto",height:c+2})}},h.prototype.destroy=function(){this.$element.off(i),this.$video&&this.$video.off(i),delete a[i].lookup[this.index],this.$element.removeData(i),this.$wrapper.remove()},a[i]={lookup:[]},a.fn[i]=function(b,c){var d;return this.each(function(){d=a.data(this,i),d&&d.destroy(),d=new h(this,b,c),d.index=a[i].lookup.push(d)-1,a.data(this,i,d)}),this},a(c).ready(function(){a(b).on("resize."+i,function(){for(var b,c=a[i].lookup.length,d=0;c>d;d++)b=a[i].lookup[d],b&&b.settings.resizing&&b.resize()}),a(c).find("[data-"+i+"-bg]").each(function(b,c){var d=a(c),e=d.data(i+"-options"),f=d.data(i+"-bg");d[i](f,e)})})}(window.jQuery,window,document,navigator); \ No newline at end of file diff --git a/package.json b/package.json index 7ec9d42d..03678137 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vide", - "version": "0.3.1", + "version": "0.3.2", "description": "Easy as hell jQuery plugin for video backgrounds.", "keywords": [ "jquery-plugin",