/* * faded 0.3.1 - jquery plugin * written by nathan searles * http://nathansearles.com/faded/ * * copyright (c) 2009 nathan searles (http://nathansearles.com/) * dual licensed under the mit (mit-license.txt) * and gpl (gpl-license.txt) licenses. * * built for jquery library * http://jquery.com * compatible with jquery 1.3.2+ * */ if(typeof jquery != "undefined") { jquery(function($) { $.fn.extend({ faded: function(options) { var settings = $.extend({}, $.fn.faded.defaults, options); return this.each( function() { if($.fn.jquery < "1.3.1") {return;} var $t = $(this); var $c = $t.children(":nth-child(1)"); var o = $.metadata ? $.extend({}, settings, $t.metadata()) : settings; var total = $c.children().size(); var next = 0, prev = 0, number = 0, currentitem = 0, restart = 0, restartinterval = 0; var loaded,active,imgsrc,clicked,current; if (o.random) { $.fn.reorder = function(callback) { function randord() { return(math.round(math.random())-0.5); } return($(this).each(function() { var $this = $(this); var $children = $this.children(); var childcount = $children.length; if (childcount > 1) { $children.hide(); var indices = new array(); for (i=0;i"); $c.children().each(function(){ $("."+o.pagination+"",$t).append("
  • "+(number+1)+"
  • "); number++; }); } $("."+o.pagination+" li a:eq(0)",$t).parent().addclass("current"); $("."+o.pagination+" li a",$t).click(function(){ current = $("."+o.pagination+" li.current a",$t).attr("rel"); clicked = $(this).attr("rel"); if (current != clicked) {animate("pagination",clicked,current);} if(o.autoplay){pause();} return false; }); } if (o.sequentialloading&&$c.children()[0].tagname=="img") { $c.css({background:"url("+o.loadingimg+") no-repeat 50% 50%"}); imgsrc = $("img:eq(0)",$c).attr("src"); $("img:eq(0)",$c).attr("src", imgsrc).load(function() { $(this).fadein(o.speed,function(){ loaded = true; }); }); } else { $c.find(":eq(0)").fadein(o.speed,function(){ loaded = true; }); } if (o.bigtarget) { $c.css({"cursor":"pointer"}); $c.click(function(){ animate("next"); if(o.autoplay){ if (o.autorestart) { pause(); } else { clearinterval(autoplay); } } return false; }); } if (o.autoplay) { autoplay = setinterval(function(){ animate("next"); },o.autoplay); pause(); } $("."+o.nextbtn,$t).click(function(){ animate("next"); if(o.autoplay){ if (o.autorestart) { pause(); } else { clearinterval(autoplay); } } return false; }); $("."+o.prevbtn,$t).click(function(){ animate("prev"); if(o.autoplay){ if (o.autorestart) { pause(); } else { clearinterval(autoplay); } } return false; }); function animate(dir,clicked,current){ if (!active&&loaded) { active=true; switch(dir) { case "next": prev = next; next = currentitem*1+1; if (total === next) { next = 0; } break; case "prev": prev = next; next = currentitem*1-1; if (next === -1) { next = total-1; } break; case "pagination": next = clicked; prev = current; break; } if (o.pagination) { $(".pagination li.current",$t).removeclass("current"); $(".pagination li a:eq("+next+")",$t).parent().addclass("current"); } if (o.crossfade) { $c.children(":eq("+next+")").css({zindex:10}).fadein(o.speed,function(){ $c.children(":eq("+prev+")").css({display:"none",zindex:0}); $(this).css({zindex:0}); currentitem = next; active = false; }); } else { $c.children(":eq("+prev+")").fadeout(o.speed,function(){ if (o.autoheight) { $c.animate({height: $c.children(":eq("+next+")").outerheight()},o.autoheight,function(){ $c.children(":eq("+next+")").fadein(o.speed); }); } else { $c.children(":eq("+next+")").fadein(o.speed); } currentitem = next; active = false; }); } } } } ); } }); $.fn.faded.defaults = { speed: 300, crossfade: false, bigtarget: false, sequentialloading: false, autoheight: false, pagination: "pagination", autopagination: true, nextbtn: "next", prevbtn: "prev", loadingimg: false, autoplay: false, autorestart: false, random: false }; }); }