This repository has been archived by the owner on Oct 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
jquery.fancy-photoset.min.js
15 lines (15 loc) · 1.7 KB
/
jquery.fancy-photoset.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/*!
* Project: fancy-photoset
* Description: A jQuery plugin for viewing Flickr Photostreams in a Fancybox gallery
* Author: Phil Cohen
* License: MIT
*
* Copyright (c) 2010-2011 Phil Cohen (http://phlippers.net)
*
* Version: 0.5.0
* Requires jQuery 1.4.2+, Fancybox 1.3.1+
* Docs: http://phlippers.net/code/fancy-photoset
*/
(function(b){var i,d,a;a="fancyPhotoset";d={apiKey:"",photosetId:"",small:"square",large:"medium",captions:true,firstOnly:false,fancybox:{}};i=function(){function g(e,f){this.element=e;this.options=b.extend({},d,f);this._defaults=d;this._name=a;this.init()}g.prototype.init=function(){var e,f,a,c;c=this.options;f=b(this.element);e="fancyPhotoset-"+c.photosetId;a="http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&"+("api_key="+c.apiKey+"&")+("photoset_id="+c.photosetId+"&")+"extras=url_sq,url_t,url_s,url_m,url_o&format=json&jsoncallback=?";
f.append(b("<ul/>").attr("id",e).addClass("fancyPhotoset"));return b.getJSON(a,function(e){b.each(e.photoset.photo,function(e,a){var d,h;h=b("<img/>").attr({src:g.prototype.urlFor(a,{size:c.small}),title:a.title,alt:a.title});d=b("<a/>").attr({href:g.prototype.urlFor(a,{size:c.large}),rel:"flickr-"+c.photosetId,title:a.title});d.html(h).fancybox(c.fancybox);c.captions&&h.after(b("<span/>").addClass("caption").text(a.title));return f.find("ul").append(b("<li/>").html(d))});if(c.firstOnly)return f.find("li").not(":first").hide()})};
g.prototype.urlFor=function(a,b){return{square:a.url_sq,thumbnail:a.url_t,small:a.url_s,medium:a.url_m,original:a.url_o}[b.size]};return g}();return b.fn[a]=function(d){return this.each(function(){if(!b.data(this,"plugin_"+a))return b.data(this,"plugin_"+a,new i(this,d))})}})(jQuery,window,document);