break;
}
}
- } else if (mode === 'shownext' || mode === 'shownextcycle') {
+ } else if (mode === 'shownext' || mode === 'shownextcycle' || mode === 'showprev' || mode === 'showprevcycle') {
var ids = $(this).data('showid').toString().split(',');
+
+ var a = 1;
+ if (mode === 'showprev' || mode === 'showprevcycle') {
+ a = -1;
+ }
+
var current = $(this).data('current-showid');
if (current === undefined) {
showid = [ids[0]];
} else {
- var idx = ids.indexOf(current) + 1;
- if (idx === ids.length) {
- if (mode === 'shownext') {
+ var idx = ids.indexOf(current) + a;
+ if (mode === 'showprevcycle' || mode === 'shownextcycle') {
+ idx = (ids.length + idx) % ids.length;
+ } else {
+ if (idx >= ids.length || idx < 0) {
return false;
- } else {
- idx = 0;
}
}
showid = [ids[idx]];
}
- $(this).data('current-showid', showid[0]);
+ $('[data-showid="' + $(this).attr('data-showid') + '"]').each(function () {
+ $(this).data('current-showid', showid[0]);
+ });
} else {
showid = $(this).data('showid').toString().split(',');
}
- if (mode === 'exclusiveshow' || mode === 'shownext' || mode === 'shownextcycle' || mode === 'pickrandom') {
+ if (mode === 'exclusiveshow' || mode === 'shownext' || mode === 'shownextcycle' || mode === 'showprev' || mode === 'showprevcycle' || mode === 'pickrandom') {
var selector = 'div.link[data-hidden="1"].show';
$.each(showid, function (k, id) {
selector += ':not([data-id$="' + id + '"])';