2 * Media helper for fancyBox
3 * version: 1.0.5 (Tue, 23 Oct 2012)
4 * @requires fancyBox v2.0 or later
7 * $(".fancybox").fancybox({
13 * Set custom URL parameters:
14 * $(".fancybox").fancybox({
27 * $(".fancybox").fancybox({,
39 * http://www.youtube.com/watch?v=opj24KnzrWo
40 * http://www.youtube.com/embed/opj24KnzrWo
41 * http://youtu.be/opj24KnzrWo
43 * http://vimeo.com/40648169
44 * http://vimeo.com/channels/staffpicks/38843628
45 * http://vimeo.com/groups/surrealism/videos/36516384
46 * http://player.vimeo.com/video/45074303
48 * http://www.metacafe.com/watch/7635964/dr_seuss_the_lorax_movie_trailer/
49 * http://www.metacafe.com/watch/7635964/
51 * http://www.dailymotion.com/video/xoytqh_dr-seuss-the-lorax-premiere_people
53 * http://twitvid.com/QY7MD
55 * http://twitpic.com/7p93st
57 * http://instagr.am/p/IejkuUGxQn/
58 * http://instagram.com/p/IejkuUGxQn/
60 * http://maps.google.com/maps?q=Eiffel+Tower,+Avenue+Gustave+Eiffel,+Paris,+France&t=h&z=17
61 * http://maps.google.com/?ll=48.857995,2.294297&spn=0.007666,0.021136&t=m&z=16
62 * 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
67 //Shortcut for fancyBox object
69 format = function( url, rez, params ) {
70 params = params || '';
72 if ( $.type( params ) === "object" ) {
73 params = $.param(params, true);
76 $.each(rez, function(key, value) {
77 url = url.replace( '$' + key, value || '' );
81 url += ( url.indexOf('?') > 0 ? '&' : '?' ) + params;
91 matcher : /(youtube\.com|youtu\.be)\/(watch\?v=|v\/|u\/|embed\/?)?(videoseries\?list=(.*)|[\w-]{11}|\?listType=(.*)&list=(.*)).*/i,
102 url : '//www.youtube.com/embed/$3'
105 matcher : /(?:vimeo(?:pro)?.com)\/(?:[^\d]+)?(\d+)(?:.*)/,
115 url : '//player.vimeo.com/video/$1'
118 matcher : /metacafe.com\/(?:watch|fplayer)\/([\w\-]{1,10})/,
123 url : function( rez, params, obj ) {
124 obj.swf.flashVars = 'playerVars=' + $.param( params, true );
126 return '//www.metacafe.com/fplayer/' + rez[1] + '/.swf';
130 matcher : /dailymotion.com\/video\/(.*)\/?(.*)/,
136 url : '//www.dailymotion.com/swf/video/$1'
139 matcher : /twitvid\.com\/([a-zA-Z0-9_\-\?\=]+)/i,
144 url : '//www.twitvid.com/embed.php?guid=$1'
147 matcher : /twitpic\.com\/(?!(?:place|photos|events)\/)([a-zA-Z0-9\?\=\-]+)/i,
149 url : '//twitpic.com/show/full/$1/'
152 matcher : /(instagr\.am|instagram\.com)\/p\/([a-zA-Z0-9_\-]+)\/?/i,
154 url : '//$1/p/$2/media/'
157 matcher : /maps\.google\.([a-z]{2,3}(\.[a-z]{2})?)\/(\?ll=|maps\?)(.*)/i,
159 url : function( rez ) {
160 return '//maps.google.' + rez[1] + '/' + rez[3] + '' + rez[4] + '&output=' + (rez[4].indexOf('layer=c') > 0 ? 'svembed' : 'embed');
165 beforeLoad : function(opts, obj) {
166 var url = obj.href || '',
175 rez = url.match( item.matcher );
179 params = $.extend(true, {}, item.params, obj[ what ] || ($.isPlainObject(opts[ what ]) ? opts[ what ].params : null));
181 url = $.type( item.url ) === "function" ? item.url.call( this, rez, params, obj ) : format( item.url, rez, params );
191 obj.autoHeight = false;