From: Vincent Vanwaelscappel Date: Thu, 31 Mar 2022 17:10:26 +0000 (+0200) Subject: wait #5190 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=470f08cf01b3bd75b2e1fb21f1ef69d0f09c640e;p=fluidbook-html5.git wait #5190 @0.5 --- diff --git a/js/libs/fluidbook/fluidbook.links.js b/js/libs/fluidbook/fluidbook.links.js index 2e8b9783..96d2623d 100644 --- a/js/libs/fluidbook/fluidbook.links.js +++ b/js/libs/fluidbook/fluidbook.links.js @@ -203,28 +203,36 @@ FluidbookLinks.prototype = { 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 + '"])';