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