/** * LICENSE * This file is part of Flickr Gallery. * * Flickr Gallery is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * @package flickr-gallery * @author Dan Coulter * @copyright Copyright 2009 Dan Coulter * @license http://www.gnu.org/licenses/gpl.txt GPL 2.0 * @version 1.0.1 * @link http://co.deme.me/projects/flickr-gallery/ */ ;(function($){ $.flightboxIsVideo = false; $.flightboxShow = function($calling) { $calling = $($calling); $(".flightbox-current").removeClass("flightbox-current"); $calling.addClass("flightbox-current"); var $flightbox = $("#flightbox"); $("#flightbox-image, #flightbox-meta").remove(); $flightbox.prepend(""); $image = $("#flightbox-image"); $image.unbind("load"); $image.load(function(){ $("#flightbox-image").after("
"); $("#flightbox-title").html($calling.attr("title")); $("#flightbox-flickr-link a").attr("href", $calling.parent("a").attr("href")); $("#flightbox-meta").css({width:$image.innerWidth()}); $("#flightbox-left, #flightbox-right").css({ top: 15, width: Math.floor($image.innerWidth()/2), height: $image.innerHeight() }); $("#flightbox-close").click(function(){ $("#floverlay").remove(); $("#flightbox").remove(); }); $("#flightbox-video").remove(); if ( $calling.hasClass("video") ) { $.flightboxIsVideo = true; $("#flightbox-right,#flightbox-left").css({height: 33, top: $image.innerHeight()+15}); $("#flightbox-prev,#flightbox-next").css({top:0, display:"block"}); $("#flightbox-meta").css({paddingTop:33}); var img_data = $image.attr("src").match(/[^\/]+_[^\/]+.jpg/g)[0].split(".")[0]; var photo_id = img_data.split("_")[0]; var photo_secret = img_data.split("_")[1]; $image.before('').hide(); $("#flightbox-type").html("video"); } else { if ( $.flightboxIsVideo == true ) { $("#flightbox-next, #flightbox-prev").hide() } $.flightboxIsVideo = false; $("#flightbox-prev,#flightbox-next").css({top:100}); $("#flightbox-meta").css({paddingTop:0}); $("#flightbox-type").html("photo"); } $("#flightbox").animate({ left: (($("body").width() - $image.innerWidth()-30)/2), height: $image.innerHeight() + $("#flightbox-meta").innerHeight(), width: $image.innerWidth() }, "normal", "swing", function(){ $("#flightbox-meta").fadeIn("fast"); if ( !$calling.hasClass("video") ) { $image.fadeIn("fast"); } else { $("#flightbox-video").show(); } }); $("#flightbox-left").click(function(){ $prev = $calling.parents(".flickr-thumb").prev(".flickr-thumb").find("img"); if ( $prev.length ) { $.flightboxShow($prev); } else { $("#flightbox").remove(); $("#floverlay").remove(); } }); $("#flightbox-right").click(function(){ $next = $calling.parents(".flickr-thumb").next(".flickr-thumb").find("img"); if ( $next.length ) { $.flightboxShow($next); } else { $("#flightbox").remove(); $("#floverlay").remove(); } }); }); $image.attr("src", $calling.attr("src").replace(/_[stm]\./g, ".")); } $.fn.flightbox = function() { return this.each(function(){ $(this).click(function(){ var $calling = $(this); var $document = $(this.ie6 ? document.body : document); $("body"). append('
'). append('
'); var flightbox_offset; if (self.pageYOffset) { flightbox_offset = self.pageYOffset + 100; } else if (document.documentElement && document.documentElement.scrollTop) { flightbox_offset = document.documentElement.scrollTop + 100; } else if (document.body) { flightbox_offset = document.body.scrollTop + 100; } $("#floverlay").css({ width: $document.width(), height: $document.height() }).click(function(){ $(this).remove(); $("#flightbox").remove(); }); $("#flightbox").css({ top: flightbox_offset, left: (($("body").width() - 130)/2) }); $("#flightbox-left, #flightbox-right").mouseover(function(e){ if ( e.target.id == "flightbox-left" && $(".flightbox-current").parents(".flickr-thumb").prev(".flickr-thumb").find("img").length == 0) { $(e.target).css("cursor", "default"); return; } else if ( e.target.id == "flightbox-right" && $(".flightbox-current").parents(".flickr-thumb").next(".flickr-thumb").find("img").length == 0) { $(e.target).css("cursor", "default"); return; } else { $(e.target).css("cursor", "pointer"); } if ( !$.flightboxIsVideo ) $(this).children().show(); }); $("#flightbox-left, #flightbox-right").mouseout(function(){ if ( !$.flightboxIsVideo ) $(this).children().hide(); }); $.flightboxShow($calling); return false; }); }); } })(jQuery);