]> _ Git - fluidbook-html5.git/commitdiff
wait #5190 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 31 Mar 2022 17:10:26 +0000 (19:10 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 31 Mar 2022 17:10:26 +0000 (19:10 +0200)
js/libs/fluidbook/fluidbook.links.js

index 2e8b978318096172791d306a99905bcd12b205ef..96d2623d73b0feb8798be935b0503196457bd023 100644 (file)
@@ -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 + '"])';