diff --git a/responsiveslides.js b/responsiveslides.js
index 66333f1..5ebd0d3 100644
--- a/responsiveslides.js
+++ b/responsiveslides.js
@@ -1,33 +1,11 @@
-/*! ResponsiveSlides.js v1.25
+/*! ResponsiveSlides.js v1.3
* http://responsiveslides.com
*
* Copyright (c) 2011-2012 @viljamis
* Available under the MIT license
*/
-/* ResponsiveSlides.js is a tiny jQuery plugin that creates a responsive
- * slideshow using images inside
. It works with wide range of browsers
- * including all IE versions from IE6 and up. It also adds css max-width
- * support for IE6 and other browsers that don't natively support it. Only
- * dependency is jQuery (1.4 and up) and that all the images are same size.
- *
- * Features:
- * - Fully responsive
- * - Under 1kb minified and gzipped
- * - Simple markup using unordered lists
- * - Settings for transition and timeout durations
- * - Multiple slideshows supported
- * - Automatic and manual fade
- * - Works in all major desktop and mobile browsers
- * - Captions and other html-elements supported inside slides
- * - Separate pagination and next/prev controls
- * - Possibility to choose where the controls append to
- * - Images can be wrapped inside links
- * - Optional 'before' and 'after' callbacks
- *
- */
-
-/*jslint browser: true, sloppy: true, vars: true, plusplus: true, maxerr: 50, indent: 2 */
+/*jslint browser: true, sloppy: true, vars: true, plusplus: true, indent: 2 */
(function ($, window, i) {
$.fn.responsiveSlides = function (options) {
@@ -39,6 +17,9 @@
"timeout": 4000, // Integer: Time between slide transitions, in milliseconds
"pager": false, // Boolean: Show pager, true or false
"nav": false, // Boolean: Show navigation, true or false
+ "random": false, // Boolean: Randomize the order of the slides, true or false
+ "pause": false, // Boolean: Pause on hover, true or false
+ "pauseControls": false, // Boolean: Pause when hovering controls, true or false
"prevText": "Previous", // String: Text for the "previous" button
"nextText": "Next", // String: Text for the "next" button
"maxwidth": "", // Integer: Max-width of the slideshow, in pixels
@@ -104,6 +85,16 @@
});
};
+ // Random order
+ if (settings.random) {
+ $slide.sort(function () {
+ return (Math.round(Math.random()) - 0.5);
+ });
+ $this
+ .empty()
+ .append($slide);
+ }
+
// Add ID's to each slide
$slide.each(function (i) {
this.id = slideClassPrefix + i;
@@ -126,8 +117,13 @@
// Only run if there's more than one slide
if ($slide.size() > 1) {
+ // Make sure the timeout is at least 100ms longer than the fade
+ if (settings.timeout < settings.speed + 100) {
+ return;
+ }
+
// Pager
- if (settings.pager === true) {
+ if (settings.pager) {
var tabMarkup = [];
$slide.each(function (i) {
var n = i + 1;
@@ -158,14 +154,14 @@
}
// Auto cycle
- if (settings.auto === true) {
+ if (settings.auto) {
startCycle = function () {
rotate = setInterval(function () {
var idx = index + 1 < length ? index + 1 : 0;
- // Remove active state and set new if pager = "true"
- if (settings.pager === true) {
+ // Remove active state and set new if pager is set
+ if (settings.pager) {
selectTab(idx);
}
@@ -179,7 +175,7 @@
// Restarting cycle
restartCycle = function () {
- if (settings.auto === true) {
+ if (settings.auto) {
// Stop
clearInterval(rotate);
// Restart
@@ -187,11 +183,23 @@
}
};
+ // Pause on hover
+ if (settings.pause) {
+ $this.hover(function () {
+ clearInterval(rotate);
+ }, function () {
+ restartCycle();
+ });
+ }
+
// Pager click event handler
- if (settings.pager === true) {
+ if (settings.pager) {
$tabs.bind("click", function (e) {
e.preventDefault();
- restartCycle();
+
+ if (!settings.pauseControls) {
+ restartCycle();
+ }
// Get index of clicked tab
var idx = $tabs.index(this);
@@ -210,10 +218,19 @@
.eq(0)
.closest("li")
.addClass(activeClass);
+
+ // Pause when hovering pager
+ if (settings.pauseControls) {
+ $tabs.hover(function () {
+ clearInterval(rotate);
+ }, function () {
+ restartCycle();
+ });
+ }
}
// Navigation
- if (settings.nav === true) {
+ if (settings.nav) {
var navMarkup =
"" + settings.prevText + "" +
"" + settings.nextText + "";
@@ -244,18 +261,29 @@
// Go to slide
slideTo($(this)[0] === $prev[0] ? prevIdx : nextIdx);
- if (settings.pager === true) {
+ if (settings.pager) {
selectTab($(this)[0] === $prev[0] ? prevIdx : nextIdx);
}
- restartCycle();
+ if (!settings.pauseControls) {
+ restartCycle();
+ }
});
+
+ // Pause when hovering navigation
+ if (settings.pauseControls) {
+ $trigger.hover(function () {
+ clearInterval(rotate);
+ }, function () {
+ restartCycle();
+ });
+ }
}
}
// Max-width fallback
- if (typeof document.body.style.maxWidth === "undefined" && options && options.maxwidth) {
+ if (typeof document.body.style.maxWidth === "undefined" && options.maxwidth) {
var widthSupport = function () {
$this.css("width", "100%");
if ($this.width() > maxw) {
diff --git a/responsiveslides.min.js b/responsiveslides.min.js
index d1c66c3..562b535 100644
--- a/responsiveslides.min.js
+++ b/responsiveslides.min.js
@@ -1,6 +1,6 @@
-/*! http://responsiveslides.com v1.25 by @viljamis */
-(function(b,C,u){b.fn.responsiveSlides=function(e){var c=b.extend({auto:!0,speed:1E3,timeout:4E3,pager:!1,nav:!1,prevText:"Previous",nextText:"Next",maxwidth:"",controls:"",namespace:"rslides"},e);return this.each(function(){u++;var d=b(this),l,o,p,v,m,k=0,f=d.children(),w=f.size(),x=parseFloat(c.speed),q=parseFloat(c.maxwidth),g=c.namespace,h=g+u,i=g+"_nav "+h+"_nav",r=g+"_here",j=h+"_on",y=h+"_s",n=b(""),z={"float":"left",position:"relative"},D={"float":"none",
-position:"absolute"},s=function(a){d.trigger(g+"-before");f.stop().fadeOut(x,function(){b(this).removeClass(j).css(D)}).eq(a).fadeIn(x,function(){b(this).addClass(j).css(z).trigger(g+"-after");k=a})};f.each(function(a){this.id=y+a});d.addClass(g+" "+h);e&&e.maxwidth&&d.css("max-width",q);f.hide().eq(0).addClass(j).css(z).show();if(1"+a+""});n.append(t);m=n.find("a");e.controls?b(c.controls).append(n):
-d.after(n);l=function(a){m.closest("li").removeClass(r).eq(a).addClass(r)}}!0===c.auto&&(o=function(){v=setInterval(function(){var a=k+1"+c.prevText+""+c.nextText+"";e.controls?b(c.controls).append(i):d.after(i);var i=b("."+h+"_nav"),A=b("."+h+"_nav.prev");i.bind("click",function(a){a.preventDefault();if(!b("."+j+":animated").length){var d=f.index(b("."+j)),a=d-1,d=d+1q&&d.css("width",q)};B();b(C).bind("resize",function(){B()})}})}})(jQuery,
-this,0);
\ No newline at end of file
+/*! http://responsiveslides.com v1.3 by @viljamis */
+(function(d,C,v){d.fn.responsiveSlides=function(i){var b=d.extend({auto:!0,speed:1E3,timeout:4E3,pager:!1,nav:!1,random:!1,pause:!1,pauseControls:!1,prevText:"Previous",nextText:"Next",maxwidth:"",controls:"",namespace:"rslides"},i);return this.each(function(){v++;var c=d(this),o,q,j,l,m,n=0,e=c.children(),w=e.size(),x=parseFloat(b.speed),r=parseFloat(b.maxwidth),g=b.namespace,h=g+v,f=g+"_nav "+h+"_nav",s=g+"_here",k=h+"_on",y=h+"_s",p=d(""),z={"float":"left",position:"relative"},
+D={"float":"none",position:"absolute"},t=function(a){c.trigger(g+"-before");e.stop().fadeOut(x,function(){d(this).removeClass(k).css(D)}).eq(a).fadeIn(x,function(){d(this).addClass(k).css(z).trigger(g+"-after");n=a})};b.random&&(e.sort(function(){return Math.round(Math.random())-0.5}),c.empty().append(e));e.each(function(a){this.id=y+a});c.addClass(g+" "+h);i&&i.maxwidth&&c.css("max-width",r);e.hide().eq(0).addClass(k).css(z).show();if(1"+a+"")});p.append(u);m=p.find("a");i.controls?d(b.controls).append(p):c.after(p);o=function(a){m.closest("li").removeClass(s).eq(a).addClass(s)}}b.auto&&(q=function(){l=setInterval(function(){var a=n+1"+b.prevText+""+b.nextText+"";i.controls?d(b.controls).append(f):c.after(f);var f=d("."+h+"_nav"),A=d("."+h+"_nav.prev");f.bind("click",function(a){a.preventDefault();if(!d("."+k+":animated").length){var c=e.index(d("."+k)),
+a=c-1,c=c+1r&&c.css("width",r)};B();d(C).bind("resize",function(){B()})}})}})(jQuery,this,0);
\ No newline at end of file