]> _ Git - fluidbook-html5.git/commitdiff
done #4422 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 22 Apr 2021 18:39:57 +0000 (20:39 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 22 Apr 2021 18:39:57 +0000 (20:39 +0200)
js/libs/fluidbook/fluidbook.links.js

index e608feb62ad44c81519d9b4b716f44f80a6702b1..a7a37386680ceb6ced0002b74d6df45de528591f 100644 (file)
@@ -163,12 +163,12 @@ FluidbookLinks.prototype = {
                 }
             }
 
-            var showid;
+            var showid = [];
             if (mode === 'pickrandom') {
                 while (true) {
                     var ids = $(this).data('showid').split(',');
                     var idx = Math.floor(Math.random() * ids.length);
-                    showid = ids[idx];
+                    showid = [ids[idx]];
                     if ($('div.link[data-hidden="1"][data-id$="' + showid + '"].show').length === 0 || ids.length === 0) {
                         break;
                     }
@@ -177,7 +177,7 @@ FluidbookLinks.prototype = {
                 var ids = $(this).data('showid').split(',');
                 var current = $(this).data('current-showid');
                 if (current === undefined) {
-                    showid = ids[0];
+                    showid = [ids[0]];
                 } else {
                     var idx = ids.indexOf(current) + 1;
                     if (idx === ids.length) {
@@ -187,37 +187,43 @@ FluidbookLinks.prototype = {
                             idx = 0;
                         }
                     }
-                    showid = ids[idx];
+                    showid = [ids[idx]];
                 }
-                $(this).data('current-showid', showid);
+                $(this).data('current-showid', showid[0]);
             } else {
-                showid = $(this).data('showid');
+                showid = $(this).data('showid').split(',');
             }
 
             if (mode === 'exclusiveshow' || mode === 'shownext' || mode === 'shownextcycle' || mode === 'pickrandom') {
-                $('div.link[data-hidden="1"].show:not([data-id$="' + showid + '"])').each(function () {
+                var selector = 'div.link[data-hidden="1"].show';
+                $.each(showid, function (k,id) {
+                    selector += ':not([data-id$="' + id + '"])';
+                });
+                $(selector).each(function () {
                     $this.hidePlacedLink(this, (mode === 'shownext' || mode === 'shownextcycle') ? 500 : 0);
                 });
             }
 
             var close = $(this).data('showclose');
-            $('div.link[data-id$="' + showid + '"]').each(function () {
-                var l = this;
-                if (close !== 'none') {
-                    $(l).append('<a href="#" class="linkshowclose ' + close + '"></a>');
-                }
-                $(l).show();
-                $(l).trigger('fluidbook.link.show');
-                if (close !== 'none') {
-                    $(l).removeClass('notinteractive');
-                    $(l).find('img').css('pointer-events', 'none');
-                }
-                setTimeout(function () {
-                    $(l).addClass('show');
-                }, 10);
+            console.log(showid);
+            $.each(showid, function (k,id) {
+                $('div.link[data-id$="' + id + '"]').each(function () {
+                    var l = this;
+                    if (close !== 'none') {
+                        $(l).append('<a href="#" class="linkshowclose ' + close + '"></a>');
+                    }
+                    $(l).show();
+                    $(l).trigger('fluidbook.link.show');
+                    if (close !== 'none') {
+                        $(l).removeClass('notinteractive');
+                        $(l).find('img').css('pointer-events', 'none');
+                    }
+                    setTimeout(function () {
+                        $(l).addClass('show');
+                    }, 10);
+                });
             });
 
-
             return false;
         });