Permalink
Browse files

regenerate source files

  • Loading branch information...
1 parent 23ddfcf commit 02665698194eee8dc10b55c80ee51f727fbf43f0 @phlipper committed Oct 29, 2011
Showing with 102 additions and 75 deletions.
  1. +10 −5 demo/jquery.fancy-photoset.min.js
  2. +81 −65 jquery.fancy-photoset.js
  3. +11 −5 jquery.fancy-photoset.min.js

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,69 +1,85 @@
-/*! Copyright (c) 2010 Phil Cohen (http://phlippers.net)
- * Dual licensed under the MIT (MIT_LICENSE.txt)
- * and GPL Version 2 (GPL_LICENSE.txt) licenses.
+/*!
+ * 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.4.0
+ * Version: 0.5.0
* Requires jQuery 1.4.2+, Fancybox 1.3.1+
* Docs: http://phlippers.net/code/fancy-photoset
*/
-(function($) {
- $.fn.fancyPhotoset = function(options) {
- var opts = $.extend($.fn.fancyPhotoset.defaults, options);
- var domId = 'fancyPhotoset-' + opts.photosetId;
- var jsonUrl = 'http://api.flickr.com/services/rest/?&method=flickr.photosets.getPhotos&api_key={apiKey}&photoset_id={photosetId}&extras=url_sq,url_t,url_s,url_m,url_o&format=json&jsoncallback=?'.replace(/\{\w+\}/g, function(match) {
- return opts[match.replace(/\{|\}/g, '')];
- });
-
- // Create a fancyPhotoset for each selector
- return this.each(function() {
- var obj = $(this);
- $(obj).append(
- $('<ul/>').attr('id', domId).addClass('fancyPhotoset')
- );
-
- $.getJSON(jsonUrl, function(data) {
- $.each(data.photoset.photo, function(index, photo) {
- $(obj).find('ul').append(
- $('<li/>').html(
- $('<a/>').attr({'href': $.fn.fancyPhotoset.urlFor(photo, {size: opts.large}), 'rel': 'flickr-' + opts.photosetId, 'title': photo.title}).html(
- $('<img/>').attr({'src': $.fn.fancyPhotoset.urlFor(photo, {size: opts.small}), 'title': photo.title, 'alt': photo.title}).after(
- (opts.captions ? $('<span/>').addClass('caption').text(photo.title) : '')
- )
- ).fancybox(opts.fancybox)
- )
- );
- });
-
- // Hide all except the first image
- if (opts.firstOnly) {
- $(obj).find('li').not(':first').hide();
- }
- });
- });
- };
-
- // generate static image url
- $.fn.fancyPhotoset.urlFor = function(photo, options) {
- var opts = $.extend({size: 'square'}, options);
- var urls = {
- 'square' : photo.url_sq,
- 'thumbnail' : photo.url_t,
- 'small' : photo.url_s,
- 'medium' : photo.url_m,
- 'original' : photo.url_o
- };
-
- return urls[opts.size];
- };
-
- // default options
- $.fn.fancyPhotoset.defaults = {
- apiKey : '',
- photosetId : '',
- small : 'square',
- large : 'medium',
- captions : true,
- firstOnly : false,
- fancybox : {}
- };
-})(jQuery);
+;(function($, window, document) {
+ var FancyPhotoset, defaults, pluginName;
+ pluginName = "fancyPhotoset";
+ defaults = {
+ apiKey: "",
+ photosetId: "",
+ small: "square",
+ large: "medium",
+ captions: true,
+ firstOnly: false,
+ fancybox: {}
+ };
+ FancyPhotoset = (function() {
+ function FancyPhotoset(element, options) {
+ this.element = element;
+ this.options = $.extend({}, defaults, options);
+ this._defaults = defaults;
+ this._name = pluginName;
+ this.init();
+ }
+ FancyPhotoset.prototype.init = function() {
+ var domId, element, jsonUrl, options;
+ options = this.options;
+ element = $(this.element);
+ domId = "fancyPhotoset-" + options.photosetId;
+ jsonUrl = "http://api.flickr.com/services/rest/?" + "method=flickr.photosets.getPhotos&" + ("api_key=" + options.apiKey + "&") + ("photoset_id=" + options.photosetId + "&") + "extras=url_sq,url_t,url_s,url_m,url_o&" + "format=json&jsoncallback=?";
+ element.append(($("<ul/>")).attr("id", domId).addClass("fancyPhotoset"));
+ return $.getJSON(jsonUrl, function(data) {
+ $.each(data.photoset.photo, function(index, photo) {
+ var anchor, image;
+ image = ($("<img/>")).attr({
+ src: FancyPhotoset.prototype.urlFor(photo, {
+ size: options.small
+ }),
+ title: photo.title,
+ alt: photo.title
+ });
+ anchor = ($("<a/>")).attr({
+ href: FancyPhotoset.prototype.urlFor(photo, {
+ size: options.large
+ }),
+ rel: "flickr-" + options.photosetId,
+ title: photo.title
+ });
+ anchor.html(image).fancybox(options.fancybox);
+ if (options.captions) {
+ image.after(($("<span/>")).addClass("caption").text(photo.title));
+ }
+ return element.find("ul").append(($("<li/>")).html(anchor));
+ });
+ if (options.firstOnly) {
+ return element.find("li").not(":first").hide();
+ }
+ });
+ };
+ FancyPhotoset.prototype.urlFor = function(photo, options) {
+ return {
+ square: photo.url_sq,
+ thumbnail: photo.url_t,
+ small: photo.url_s,
+ medium: photo.url_m,
+ original: photo.url_o
+ }[options.size];
+ };
+ return FancyPhotoset;
+ })();
+ return $.fn[pluginName] = function(options) {
+ return this.each(function() {
+ if (!$.data(this, "plugin_" + pluginName)) {
+ return $.data(this, "plugin_" + pluginName, new FancyPhotoset(this, options));
+ }
+ });
+ };
+})(jQuery, window, document);

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 0266569

Please sign in to comment.