annotate static/js/fancybox2/source/helpers/jquery.fancybox-media.js @ 166:491f0acbaeaf

Update WSGI script for Django 1.7 upgrade.
author Brian Neal <bgneal@gmail.com>
date Thu, 02 Apr 2015 20:25:48 -0500
parents 846cda22d77c
children
rev   line source
bgneal@106 1 /*!
bgneal@106 2 * Media helper for fancyBox
bgneal@106 3 * version: 1.0.6 (Fri, 14 Jun 2013)
bgneal@106 4 * @requires fancyBox v2.0 or later
bgneal@106 5 *
bgneal@106 6 * Usage:
bgneal@106 7 * $(".fancybox").fancybox({
bgneal@106 8 * helpers : {
bgneal@106 9 * media: true
bgneal@106 10 * }
bgneal@106 11 * });
bgneal@106 12 *
bgneal@106 13 * Set custom URL parameters:
bgneal@106 14 * $(".fancybox").fancybox({
bgneal@106 15 * helpers : {
bgneal@106 16 * media: {
bgneal@106 17 * youtube : {
bgneal@106 18 * params : {
bgneal@106 19 * autoplay : 0
bgneal@106 20 * }
bgneal@106 21 * }
bgneal@106 22 * }
bgneal@106 23 * }
bgneal@106 24 * });
bgneal@106 25 *
bgneal@106 26 * Or:
bgneal@106 27 * $(".fancybox").fancybox({,
bgneal@106 28 * helpers : {
bgneal@106 29 * media: true
bgneal@106 30 * },
bgneal@106 31 * youtube : {
bgneal@106 32 * autoplay: 0
bgneal@106 33 * }
bgneal@106 34 * });
bgneal@106 35 *
bgneal@106 36 * Supports:
bgneal@106 37 *
bgneal@106 38 * Youtube
bgneal@106 39 * http://www.youtube.com/watch?v=opj24KnzrWo
bgneal@106 40 * http://www.youtube.com/embed/opj24KnzrWo
bgneal@106 41 * http://youtu.be/opj24KnzrWo
bgneal@106 42 * http://www.youtube-nocookie.com/embed/opj24KnzrWo
bgneal@106 43 * Vimeo
bgneal@106 44 * http://vimeo.com/40648169
bgneal@106 45 * http://vimeo.com/channels/staffpicks/38843628
bgneal@106 46 * http://vimeo.com/groups/surrealism/videos/36516384
bgneal@106 47 * http://player.vimeo.com/video/45074303
bgneal@106 48 * Metacafe
bgneal@106 49 * http://www.metacafe.com/watch/7635964/dr_seuss_the_lorax_movie_trailer/
bgneal@106 50 * http://www.metacafe.com/watch/7635964/
bgneal@106 51 * Dailymotion
bgneal@106 52 * http://www.dailymotion.com/video/xoytqh_dr-seuss-the-lorax-premiere_people
bgneal@106 53 * Twitvid
bgneal@106 54 * http://twitvid.com/QY7MD
bgneal@106 55 * Twitpic
bgneal@106 56 * http://twitpic.com/7p93st
bgneal@106 57 * Instagram
bgneal@106 58 * http://instagr.am/p/IejkuUGxQn/
bgneal@106 59 * http://instagram.com/p/IejkuUGxQn/
bgneal@106 60 * Google maps
bgneal@106 61 * http://maps.google.com/maps?q=Eiffel+Tower,+Avenue+Gustave+Eiffel,+Paris,+France&t=h&z=17
bgneal@106 62 * http://maps.google.com/?ll=48.857995,2.294297&spn=0.007666,0.021136&t=m&z=16
bgneal@106 63 * 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 64 */
bgneal@106 65 (function ($) {
bgneal@106 66 "use strict";
bgneal@106 67
bgneal@106 68 //Shortcut for fancyBox object
bgneal@106 69 var F = $.fancybox,
bgneal@106 70 format = function( url, rez, params ) {
bgneal@106 71 params = params || '';
bgneal@106 72
bgneal@106 73 if ( $.type( params ) === "object" ) {
bgneal@106 74 params = $.param(params, true);
bgneal@106 75 }
bgneal@106 76
bgneal@106 77 $.each(rez, function(key, value) {
bgneal@106 78 url = url.replace( '$' + key, value || '' );
bgneal@106 79 });
bgneal@106 80
bgneal@106 81 if (params.length) {
bgneal@106 82 url += ( url.indexOf('?') > 0 ? '&' : '?' ) + params;
bgneal@106 83 }
bgneal@106 84
bgneal@106 85 return url;
bgneal@106 86 };
bgneal@106 87
bgneal@106 88 //Add helper object
bgneal@106 89 F.helpers.media = {
bgneal@106 90 defaults : {
bgneal@106 91 youtube : {
bgneal@106 92 matcher : /(youtube\.com|youtu\.be|youtube-nocookie\.com)\/(watch\?v=|v\/|u\/|embed\/?)?(videoseries\?list=(.*)|[\w-]{11}|\?listType=(.*)&list=(.*)).*/i,
bgneal@106 93 params : {
bgneal@106 94 autoplay : 1,
bgneal@106 95 autohide : 1,
bgneal@106 96 fs : 1,
bgneal@106 97 rel : 0,
bgneal@106 98 hd : 1,
bgneal@106 99 wmode : 'opaque',
bgneal@106 100 enablejsapi : 1
bgneal@106 101 },
bgneal@106 102 type : 'iframe',
bgneal@106 103 url : '//www.youtube.com/embed/$3'
bgneal@106 104 },
bgneal@106 105 vimeo : {
bgneal@106 106 matcher : /(?:vimeo(?:pro)?.com)\/(?:[^\d]+)?(\d+)(?:.*)/,
bgneal@106 107 params : {
bgneal@106 108 autoplay : 1,
bgneal@106 109 hd : 1,
bgneal@106 110 show_title : 1,
bgneal@106 111 show_byline : 1,
bgneal@106 112 show_portrait : 0,
bgneal@106 113 fullscreen : 1
bgneal@106 114 },
bgneal@106 115 type : 'iframe',
bgneal@106 116 url : '//player.vimeo.com/video/$1'
bgneal@106 117 },
bgneal@106 118 metacafe : {
bgneal@106 119 matcher : /metacafe.com\/(?:watch|fplayer)\/([\w\-]{1,10})/,
bgneal@106 120 params : {
bgneal@106 121 autoPlay : 'yes'
bgneal@106 122 },
bgneal@106 123 type : 'swf',
bgneal@106 124 url : function( rez, params, obj ) {
bgneal@106 125 obj.swf.flashVars = 'playerVars=' + $.param( params, true );
bgneal@106 126
bgneal@106 127 return '//www.metacafe.com/fplayer/' + rez[1] + '/.swf';
bgneal@106 128 }
bgneal@106 129 },
bgneal@106 130 dailymotion : {
bgneal@106 131 matcher : /dailymotion.com\/video\/(.*)\/?(.*)/,
bgneal@106 132 params : {
bgneal@106 133 additionalInfos : 0,
bgneal@106 134 autoStart : 1
bgneal@106 135 },
bgneal@106 136 type : 'swf',
bgneal@106 137 url : '//www.dailymotion.com/swf/video/$1'
bgneal@106 138 },
bgneal@106 139 twitvid : {
bgneal@106 140 matcher : /twitvid\.com\/([a-zA-Z0-9_\-\?\=]+)/i,
bgneal@106 141 params : {
bgneal@106 142 autoplay : 0
bgneal@106 143 },
bgneal@106 144 type : 'iframe',
bgneal@106 145 url : '//www.twitvid.com/embed.php?guid=$1'
bgneal@106 146 },
bgneal@106 147 twitpic : {
bgneal@106 148 matcher : /twitpic\.com\/(?!(?:place|photos|events)\/)([a-zA-Z0-9\?\=\-]+)/i,
bgneal@106 149 type : 'image',
bgneal@106 150 url : '//twitpic.com/show/full/$1/'
bgneal@106 151 },
bgneal@106 152 instagram : {
bgneal@106 153 matcher : /(instagr\.am|instagram\.com)\/p\/([a-zA-Z0-9_\-]+)\/?/i,
bgneal@106 154 type : 'image',
bgneal@106 155 url : '//$1/p/$2/media/?size=l'
bgneal@106 156 },
bgneal@106 157 google_maps : {
bgneal@106 158 matcher : /maps\.google\.([a-z]{2,3}(\.[a-z]{2})?)\/(\?ll=|maps\?)(.*)/i,
bgneal@106 159 type : 'iframe',
bgneal@106 160 url : function( rez ) {
bgneal@106 161 return '//maps.google.' + rez[1] + '/' + rez[3] + '' + rez[4] + '&output=' + (rez[4].indexOf('layer=c') > 0 ? 'svembed' : 'embed');
bgneal@106 162 }
bgneal@106 163 }
bgneal@106 164 },
bgneal@106 165
bgneal@106 166 beforeLoad : function(opts, obj) {
bgneal@106 167 var url = obj.href || '',
bgneal@106 168 type = false,
bgneal@106 169 what,
bgneal@106 170 item,
bgneal@106 171 rez,
bgneal@106 172 params;
bgneal@106 173
bgneal@106 174 for (what in opts) {
bgneal@106 175 if (opts.hasOwnProperty(what)) {
bgneal@106 176 item = opts[ what ];
bgneal@106 177 rez = url.match( item.matcher );
bgneal@106 178
bgneal@106 179 if (rez) {
bgneal@106 180 type = item.type;
bgneal@106 181 params = $.extend(true, {}, item.params, obj[ what ] || ($.isPlainObject(opts[ what ]) ? opts[ what ].params : null));
bgneal@106 182
bgneal@106 183 url = $.type( item.url ) === "function" ? item.url.call( this, rez, params, obj ) : format( item.url, rez, params );
bgneal@106 184
bgneal@106 185 break;
bgneal@106 186 }
bgneal@106 187 }
bgneal@106 188 }
bgneal@106 189
bgneal@106 190 if (type) {
bgneal@106 191 obj.href = url;
bgneal@106 192 obj.type = type;
bgneal@106 193
bgneal@106 194 obj.autoHeight = false;
bgneal@106 195 }
bgneal@106 196 }
bgneal@106 197 };
bgneal@106 198
bgneal@106 199 }(jQuery));