Skip to content

Commit 5509501

Browse files
author
Jonathan Mitchell
committed
Add simple nextUrl and prevUrl config options to the slideshow plugin.
When the end of the slideshow is reached the next/prev buttons redirect to the nextUrl, prevUrl rather than becoming disabled. If nextUrl and/or prevUrl are not defined then the appropriate button is disabled. In order for this to work the disabled class display property must be changed to .disabled.noUrl { visibility:hidden !important; } The slidehow configuration is: slideshow({ prevUrl:'/our-prev-url' , nextUrl:'/our-next-url' , noUrlClass:'noUrl' });
1 parent d65b237 commit 5509501

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/tabs/tabs.slideshow.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919
next: '.forward',
2020
prev: '.backward',
2121
disabledClass: 'disabled',
22+
noUrlClass: 'noUrl',
2223
autoplay: false,
2324
autopause: true,
2425
interval: 3000,
2526
clickable: true,
26-
api: false
27+
api: false,
28+
nextUrl: null,
29+
prevUrl: null
2730
}
2831
};
2932

@@ -43,11 +46,19 @@
4346
}
4447

4548
var nextButton = find(conf.next).click(function() {
49+
if ($(this).hasClass(conf.disabledClass) && conf.nextUrl != null) {
50+
window.location = conf.nextUrl;
51+
return;
52+
}
4653
tabs.next();
4754
});
4855

4956
var prevButton = find(conf.prev).click(function() {
50-
tabs.prev();
57+
if ($(this).hasClass(conf.disabledClass) && conf.prevUrl != null) {
58+
window.location = conf.prevUrl;
59+
return;
60+
}
61+
tabs.prev();
5162
});
5263

5364

@@ -171,6 +182,9 @@
171182
$(this).data("slideshow", el);
172183
});
173184

185+
if (conf.prevUrl == null) $(conf.prev).addClass(conf.noUrlClass);
186+
if (conf.nextUrl == null) $(conf.next).addClass(conf.noUrlClass);
187+
174188
return conf.api ? el : this;
175189
};
176190

0 commit comments

Comments
 (0)