-
Notifications
You must be signed in to change notification settings - Fork 42
/
directorySlider.min.js
8 lines (8 loc) · 1.33 KB
/
directorySlider.min.js
1
2
3
4
5
6
7
8
/**
* directorySlider v0.9 - Loads all images in a specified directory and creates a slide show
* Author: Justin W. Hall
* http://www.justinwhall.com/directory-jquery-slider/
*
* License: GPL v3
*/
(function(a){var b=function(b,c){var d=a(b),f=d[0].id,g=a.extend({animation:"slide",filebase:"slide_",extension:"jpg",speed:1e3,timeout:4e3,directory:null,numslides:null,height:null,width:null},c||{});g.height&&a(d).css("height",g.height),g.width&&a(d).css("width",g.width),a(d).css("overflow","hidden");for(var h=[],i=1;g.numslides>=i;)h.push('<img src="'+g.directory+g.filebase+i+"."+g.extension+'" />'),i++;var j=a('<div class="'+f+'-slide-wrap" ></div>');j.appendTo(d),a.each(h,function(b,c){a(c).css({position:"absolute",top:0,left:0}).appendTo(j)}),setInterval(function(){var b=d.find("img:first-child"),c=d.find("img:last-child");switch(g.animation){case"fade":a(c).animate({opacity:0},g.speed,function(){a(this).insertBefore(b).css("opacity",1)});break;case"uncover":c.animate({marginLeft:-a(this).width()},g.speed,function(){a(this).insertBefore(b).css("marginLeft",0)});break;default:a(c).animate({opacity:0},g.speed,function(){a(this).insertBefore(b).css("opacity",1)})}},g.timeout)};a.fn.directorySlider=function(c){return this.each(function(){var d=a(this);if(!d.data("directoryslider")){var e=new b(this,c);d.data("directoryslider",e)}})}})(jQuery);