bgneal@106: /*! bgneal@106: * Media helper for fancyBox bgneal@106: * version: 1.0.6 (Fri, 14 Jun 2013) bgneal@106: * @requires fancyBox v2.0 or later bgneal@106: * bgneal@106: * Usage: bgneal@106: * $(".fancybox").fancybox({ bgneal@106: * helpers : { bgneal@106: * media: true bgneal@106: * } bgneal@106: * }); bgneal@106: * bgneal@106: * Set custom URL parameters: bgneal@106: * $(".fancybox").fancybox({ bgneal@106: * helpers : { bgneal@106: * media: { bgneal@106: * youtube : { bgneal@106: * params : { bgneal@106: * autoplay : 0 bgneal@106: * } bgneal@106: * } bgneal@106: * } bgneal@106: * } bgneal@106: * }); bgneal@106: * bgneal@106: * Or: bgneal@106: * $(".fancybox").fancybox({, bgneal@106: * helpers : { bgneal@106: * media: true bgneal@106: * }, bgneal@106: * youtube : { bgneal@106: * autoplay: 0 bgneal@106: * } bgneal@106: * }); bgneal@106: * bgneal@106: * Supports: bgneal@106: * bgneal@106: * Youtube bgneal@106: * http://www.youtube.com/watch?v=opj24KnzrWo bgneal@106: * http://www.youtube.com/embed/opj24KnzrWo bgneal@106: * http://youtu.be/opj24KnzrWo bgneal@106: * http://www.youtube-nocookie.com/embed/opj24KnzrWo bgneal@106: * Vimeo bgneal@106: * http://vimeo.com/40648169 bgneal@106: * http://vimeo.com/channels/staffpicks/38843628 bgneal@106: * http://vimeo.com/groups/surrealism/videos/36516384 bgneal@106: * http://player.vimeo.com/video/45074303 bgneal@106: * Metacafe bgneal@106: * http://www.metacafe.com/watch/7635964/dr_seuss_the_lorax_movie_trailer/ bgneal@106: * http://www.metacafe.com/watch/7635964/ bgneal@106: * Dailymotion bgneal@106: * http://www.dailymotion.com/video/xoytqh_dr-seuss-the-lorax-premiere_people bgneal@106: * Twitvid bgneal@106: * http://twitvid.com/QY7MD bgneal@106: * Twitpic bgneal@106: * http://twitpic.com/7p93st bgneal@106: * Instagram bgneal@106: * http://instagr.am/p/IejkuUGxQn/ bgneal@106: * http://instagram.com/p/IejkuUGxQn/ bgneal@106: * Google maps bgneal@106: * http://maps.google.com/maps?q=Eiffel+Tower,+Avenue+Gustave+Eiffel,+Paris,+France&t=h&z=17 bgneal@106: * http://maps.google.com/?ll=48.857995,2.294297&spn=0.007666,0.021136&t=m&z=16 bgneal@106: * http://maps.google.com/?ll=48.859463,2.292626&spn=0.000965,0.002642&t=m&z=19&layer=c&cbll=48.859524,2.292532&panoid=YJ0lq28OOy3VT2IqIuVY0g&cbp=12,151.58,,0,-15.56 bgneal@106: */ bgneal@106: (function ($) { bgneal@106: "use strict"; bgneal@106: bgneal@106: //Shortcut for fancyBox object bgneal@106: var F = $.fancybox, bgneal@106: format = function( url, rez, params ) { bgneal@106: params = params || ''; bgneal@106: bgneal@106: if ( $.type( params ) === "object" ) { bgneal@106: params = $.param(params, true); bgneal@106: } bgneal@106: bgneal@106: $.each(rez, function(key, value) { bgneal@106: url = url.replace( '$' + key, value || '' ); bgneal@106: }); bgneal@106: bgneal@106: if (params.length) { bgneal@106: url += ( url.indexOf('?') > 0 ? '&' : '?' ) + params; bgneal@106: } bgneal@106: bgneal@106: return url; bgneal@106: }; bgneal@106: bgneal@106: //Add helper object bgneal@106: F.helpers.media = { bgneal@106: defaults : { bgneal@106: youtube : { bgneal@106: matcher : /(youtube\.com|youtu\.be|youtube-nocookie\.com)\/(watch\?v=|v\/|u\/|embed\/?)?(videoseries\?list=(.*)|[\w-]{11}|\?listType=(.*)&list=(.*)).*/i, bgneal@106: params : { bgneal@106: autoplay : 1, bgneal@106: autohide : 1, bgneal@106: fs : 1, bgneal@106: rel : 0, bgneal@106: hd : 1, bgneal@106: wmode : 'opaque', bgneal@106: enablejsapi : 1 bgneal@106: }, bgneal@106: type : 'iframe', bgneal@106: url : '//www.youtube.com/embed/$3' bgneal@106: }, bgneal@106: vimeo : { bgneal@106: matcher : /(?:vimeo(?:pro)?.com)\/(?:[^\d]+)?(\d+)(?:.*)/, bgneal@106: params : { bgneal@106: autoplay : 1, bgneal@106: hd : 1, bgneal@106: show_title : 1, bgneal@106: show_byline : 1, bgneal@106: show_portrait : 0, bgneal@106: fullscreen : 1 bgneal@106: }, bgneal@106: type : 'iframe', bgneal@106: url : '//player.vimeo.com/video/$1' bgneal@106: }, bgneal@106: metacafe : { bgneal@106: matcher : /metacafe.com\/(?:watch|fplayer)\/([\w\-]{1,10})/, bgneal@106: params : { bgneal@106: autoPlay : 'yes' bgneal@106: }, bgneal@106: type : 'swf', bgneal@106: url : function( rez, params, obj ) { bgneal@106: obj.swf.flashVars = 'playerVars=' + $.param( params, true ); bgneal@106: bgneal@106: return '//www.metacafe.com/fplayer/' + rez[1] + '/.swf'; bgneal@106: } bgneal@106: }, bgneal@106: dailymotion : { bgneal@106: matcher : /dailymotion.com\/video\/(.*)\/?(.*)/, bgneal@106: params : { bgneal@106: additionalInfos : 0, bgneal@106: autoStart : 1 bgneal@106: }, bgneal@106: type : 'swf', bgneal@106: url : '//www.dailymotion.com/swf/video/$1' bgneal@106: }, bgneal@106: twitvid : { bgneal@106: matcher : /twitvid\.com\/([a-zA-Z0-9_\-\?\=]+)/i, bgneal@106: params : { bgneal@106: autoplay : 0 bgneal@106: }, bgneal@106: type : 'iframe', bgneal@106: url : '//www.twitvid.com/embed.php?guid=$1' bgneal@106: }, bgneal@106: twitpic : { bgneal@106: matcher : /twitpic\.com\/(?!(?:place|photos|events)\/)([a-zA-Z0-9\?\=\-]+)/i, bgneal@106: type : 'image', bgneal@106: url : '//twitpic.com/show/full/$1/' bgneal@106: }, bgneal@106: instagram : { bgneal@106: matcher : /(instagr\.am|instagram\.com)\/p\/([a-zA-Z0-9_\-]+)\/?/i, bgneal@106: type : 'image', bgneal@106: url : '//$1/p/$2/media/?size=l' bgneal@106: }, bgneal@106: google_maps : { bgneal@106: matcher : /maps\.google\.([a-z]{2,3}(\.[a-z]{2})?)\/(\?ll=|maps\?)(.*)/i, bgneal@106: type : 'iframe', bgneal@106: url : function( rez ) { bgneal@106: return '//maps.google.' + rez[1] + '/' + rez[3] + '' + rez[4] + '&output=' + (rez[4].indexOf('layer=c') > 0 ? 'svembed' : 'embed'); bgneal@106: } bgneal@106: } bgneal@106: }, bgneal@106: bgneal@106: beforeLoad : function(opts, obj) { bgneal@106: var url = obj.href || '', bgneal@106: type = false, bgneal@106: what, bgneal@106: item, bgneal@106: rez, bgneal@106: params; bgneal@106: bgneal@106: for (what in opts) { bgneal@106: if (opts.hasOwnProperty(what)) { bgneal@106: item = opts[ what ]; bgneal@106: rez = url.match( item.matcher ); bgneal@106: bgneal@106: if (rez) { bgneal@106: type = item.type; bgneal@106: params = $.extend(true, {}, item.params, obj[ what ] || ($.isPlainObject(opts[ what ]) ? opts[ what ].params : null)); bgneal@106: bgneal@106: url = $.type( item.url ) === "function" ? item.url.call( this, rez, params, obj ) : format( item.url, rez, params ); bgneal@106: bgneal@106: break; bgneal@106: } bgneal@106: } bgneal@106: } bgneal@106: bgneal@106: if (type) { bgneal@106: obj.href = url; bgneal@106: obj.type = type; bgneal@106: bgneal@106: obj.autoHeight = false; bgneal@106: } bgneal@106: } bgneal@106: }; bgneal@106: bgneal@106: }(jQuery));