diff --git a/bower.json b/bower.json index 0c53e930..be10f78e 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "vide", - "version": "0.1.4", + "version": "0.2.0", "homepage": "http://vodkabears.github.io/vide/", "authors": [ "Ilya Makarov " diff --git a/dist/jquery.vide.js b/dist/jquery.vide.js index af5c9966..31060067 100644 --- a/dist/jquery.vide.js +++ b/dist/jquery.vide.js @@ -1,12 +1,12 @@ /* - * Vide - v0.1.4 + * Vide - v0.2.0 * Easy as hell jQuery plugin for video backgrounds. * http://vodkabears.github.io/vide/ * * Made by Ilya Makarov * Under MIT License */ -;(function ($, window, document, navigator) { +;(function($, window, document, navigator) { "use strict"; /** @@ -22,23 +22,13 @@ autoplay: true, position: "50% 50%", posterType: "detect" - }; + }, - /** - * Is iOs or Android? - * @private - */ - var iOS = /iPad|iPhone|iPod/i.test(navigator.userAgent), - android = /Android/i.test(navigator.userAgent); + // is iOs? + isIOS = /iPad|iPhone|iPod/i.test(navigator.userAgent), - /** - * Special plugin object for instances. - * @type {Object} - * @public - */ - $[pluginName] = { - lookup: [] - }; + // is Android? + isAndroid = /Android/i.test(navigator.userAgent); /** * Parse string with options @@ -46,22 +36,20 @@ * @returns {Object|String} * @private */ - var parseOptions = function (str) { - var obj = {}, arr; + function parseOptions(str) { + var obj = {}, arr, i, len, prop, val, delimiterIndex, option; // remove spaces around delimiters and split arr = str.replace(/\s*:\s*/g, ":").replace(/\s*,\s*/g, ",").split(","); // parse string - var i, len, prop, val, delimiterIndex, option; for (i = 0, len = arr.length; i < len; i++) { option = arr[i]; // Ignore urls and 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; } @@ -93,7 +81,7 @@ } return obj; - }; + } /** * Parse position option @@ -101,15 +89,16 @@ * @returns {Object} * @private */ - var parsePosition = function (str) { + function parsePosition(str) { // convert anything to the string str = "" + str; // default value is a center var args = str.split(/\s+/), - x = "50%", y = "50%"; + x = "50%", y = "50%", + i, len, arg; - for (var i = 0, len = args.length, arg; i < len; i++) { + for (i = 0, len = args.length; i < len; i++) { arg = args[i]; // convert values @@ -121,7 +110,7 @@ y = "0%"; } else if (arg === "bottom") { y = "100%"; - } else if (arg === "center"){ + } else if (arg === "center") { if (i === 0) { x = "50%"; } else { @@ -137,7 +126,7 @@ } return { x: x, y: y }; - }; + } /** * Search poster @@ -145,8 +134,8 @@ * @param {Function} callback * @private */ - var findPoster = function (path, callback) { - var onLoad = function () { + function findPoster(path, callback) { + var onLoad = function() { callback(this.src); }; @@ -154,7 +143,7 @@ $("").load(onLoad); $("").load(onLoad); $("").load(onLoad); - }; + } /** * Vide constructor @@ -201,14 +190,14 @@ * Initialization * @public */ - Vide.prototype.init = function () { - var that = this; - - this.wrapper = $("
"); + Vide.prototype.init = function() { + var that = this, + position = parsePosition(this.settings.position), + poster, + sources; // Set video wrapper styles - var position = parsePosition(this.settings.position); - this.wrapper.css({ + this.wrapper = $("
").css({ "position": "absolute", "z-index": -1, "top": 0, @@ -225,7 +214,7 @@ }); // Get poster path - var poster = this.path; + poster = this.path; if (typeof this.path === "object") { if (this.path.poster) { poster = this.path.poster; @@ -242,11 +231,12 @@ // Set video poster if (this.settings.posterType === "detect") { - findPoster(poster, function (url) { + findPoster(poster, function(url) { that.wrapper.css("background-image", "url(" + url + ")"); }); } else if (this.settings.posterType !== "none") { - this.wrapper.css("background-image", "url(" + poster + "." + this.settings.posterType + ")"); + this.wrapper + .css("background-image", "url(" + poster + "." + this.settings.posterType + ")"); } // if parent element has a static position, make it relative @@ -256,19 +246,20 @@ this.element.prepend(this.wrapper); - if (!iOS && !android) { + if (!isIOS && !isAndroid) { + sources = ""; if (typeof this.path === "object") { - var sources = ""; if (this.path.mp4) { sources += ""; } - if(this.path.webm) { + if (this.path.webm) { sources += ""; } - if(this.path.ogv) { + if (this.path.ogv) { sources += ""; } + this.video = $(""); } else { this.video = $("