From ec11341874552f03476feb002134df653360f64d Mon Sep 17 00:00:00 2001 From: VodkaBears Date: Wed, 12 Aug 2015 02:24:45 +0300 Subject: [PATCH] Release v0.3.7 --- dist/jquery.vide.js | 208 ++++++++++++++++++++++------------------ dist/jquery.vide.min.js | 4 +- package.js | 2 +- package.json | 2 +- 4 files changed, 118 insertions(+), 98 deletions(-) diff --git a/dist/jquery.vide.js b/dist/jquery.vide.js index 7947476f..2373109b 100644 --- a/dist/jquery.vide.js +++ b/dist/jquery.vide.js @@ -1,5 +1,5 @@ /* - * Vide - v0.3.6 + * Vide - v0.3.7 * Easy as hell jQuery plugin for video backgrounds. * http://vodkabears.github.io/vide/ * @@ -43,6 +43,14 @@ resizing: true }; + /** + * Not implemented error message + * @private + * @const + * @type {String} + */ + var NOT_IMPLEMENTED_MSG = 'Not implemented'; + /** * Parse a string with options * @private @@ -204,7 +212,14 @@ this.settings = $.extend({}, DEFAULTS, options); this.path = path; - this.init(); + // https://github.com/VodkaBears/Vide/issues/110 + try { + this.init(); + } catch (e) { + if (e.message !== NOT_IMPLEMENTED_MSG) { + throw e; + } + } } /** @@ -213,12 +228,18 @@ */ Vide.prototype.init = function() { var vide = this; - var position = parsePosition(vide.settings.position); + var path = vide.path; + var poster = path; var sources = ''; - var poster; + var $element = vide.$element; + var settings = vide.settings; + var position = parsePosition(settings.position); + var posterType = settings.posterType; + var $video; + var $wrapper; // Set styles of a video wrapper - vide.$wrapper = $('
').css({ + $wrapper = vide.$wrapper = $('
').css({ position: 'absolute', 'z-index': -1, top: 0, @@ -235,110 +256,113 @@ }); // Get a poster path - poster = vide.path; - if (typeof vide.path === 'object') { - if (vide.path.poster) { - poster = vide.path.poster; + if (typeof path === 'object') { + if (path.poster) { + poster = path.poster; } else { - if (vide.path.mp4) { - poster = vide.path.mp4; - } else if (vide.path.webm) { - poster = vide.path.webm; - } else if (vide.path.ogv) { - poster = vide.path.ogv; + if (path.mp4) { + poster = path.mp4; + } else if (path.webm) { + poster = path.webm; + } else if (path.ogv) { + poster = path.ogv; } } } // Set a video poster - if (vide.settings.posterType === 'detect') { + if (posterType === 'detect') { findPoster(poster, function(url) { - vide.$wrapper.css('background-image', 'url(' + url + ')'); + $wrapper.css('background-image', 'url(' + url + ')'); }); - } else if (vide.settings.posterType !== 'none') { - vide.$wrapper - .css('background-image', 'url(' + poster + '.' + vide.settings.posterType + ')'); + } else if (posterType !== 'none') { + $wrapper.css('background-image', 'url(' + poster + '.' + posterType + ')'); } // If a parent element has a static position, make it relative - if (vide.$element.css('position') === 'static') { - vide.$element.css('position', 'relative'); + if ($element.css('position') === 'static') { + $element.css('position', 'relative'); } - vide.$element.prepend(vide.$wrapper); + $element.prepend($wrapper); - if (typeof vide.path === 'object') { - if (vide.path.mp4) { - sources += ''; + if (typeof path === 'object') { + if (path.mp4) { + sources += ''; } - if (vide.path.webm) { - sources += ''; + if (path.webm) { + sources += ''; } - if (vide.path.ogv) { - sources += ''; + if (path.ogv) { + sources += ''; } - vide.$video = $(''); + $video = vide.$video = $(''); } else { - vide.$video = $('