/* 4/01/2009 PikaChoose Jquery plugin for photo galleries Copyright (C) 2009 Jeremy Fry This program 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 3 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, see . */ /* thanks to Antonio Terceiro for suggestion and implementation of the multi lang support*/ jQuery.iPikaChoose = { build : function(user_options) { var user_options; var defaults = { show_captions: true, slide_enabled: true, auto_play: true, show_prev_next: false, slide_speed: 5000, thumb_width: 50, thumb_height: 40, buttons_text: { play: "Play", stop: "Stop", previous: "Previous", next: "Next" }, delay_caption: false, user_thumbs: true }; return jQuery(this).each( function() { //bring in options var options = jQuery.extend(defaults, user_options); // grab our images var images = jQuery(this).children('li').children('img'); //hide the images so the user doesn't see crap images.fadeOut(1); //save our list for future ref var ulist = jQuery(this); images.each(LoadImages); //start building structure jQuery(this).before("
"); // houses eveything about the UL var main_div = jQuery(this).prev(".pika_main"); //add in slideshow elements when appropriate if(options.slide_enabled){ main_div.append("
"); var play_div = jQuery(this).prev(".pika_main").children(".pika_play"); play_div.html("" + options.buttons_text.play + "" + options.buttons_text.stop + ""); play_div.fadeOut(1); var play_anchor = play_div.children('a:first'); var stop_anchor = play_div.children('a:last'); } //this div is used to make image and caption fade together main_div.append("
"); var sub_div = main_div.children(".pika_subdiv"); //the main image we'll be using to load sub_div.append(""); var main_img = sub_div.children("img"); //create the caption div when appropriate if(options.show_captions){ sub_div.append("
"); var caption_div = sub_div.children(".pika_caption"); } //navigation div ALWAYS gets created, its refrenced a lot jQuery(this).after("
"); var navigation_div = jQuery(this).next(".pika_navigation"); //fill in sub elements navigation_div.prepend("" + options.buttons_text.previous + " :: " + options.buttons_text.next + ""); var previous_image_anchor = navigation_div.children('a:first'); var next_image_anchor = navigation_div.children('a:last'); //hide the navigation if the user doesn't want it if(!options.show_prev_next){ navigation_div.css("display","none"); } //playing triggers the loop for the slideshow var playing = options.auto_play; main_img.wrap(""); var main_link = main_img.parent("a"); function LoadImages() { jQuery(this).bind("load", function() { //had to make a seperate function so that the thumbnails wouldn't have problems //from beings resized before loaded, thus not h/w var w = jQuery(this).width(); var h = jQuery(this).height(); if(w===0){w = jQuery(this).attr("width");} if(h===0){h = jQuery(this).attr("height");} //grab a ratio for image to user defined settings var rw = options.thumb_width/w; var rh = options.thumb_height/h; //determine which has the smallest ratio (thus needing //to be the side we use to scale so our whole thumb is filled) if(rw