]> _ Git - fluidbook-html5.git/commitdiff
wait #5998 @0.75
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 6 Jun 2023 15:45:57 +0000 (17:45 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 6 Jun 2023 15:45:57 +0000 (17:45 +0200)
js/libs/fluidbook/fluidbook.links.js

index 9857785adedb9953935394a144ebbc1c70ca9366..2c995abd17686995e516e8c858fbabee3e81ac7e 100644 (file)
@@ -69,7 +69,7 @@ FluidbookLinks.prototype = {
 
         $(this.fluidbook).on('fluidbook.page.change.end', function () {
             if ($this.lastTriggeredLinksPage == $this.fluidbook.currentPage) {
-                return;
+               // return;
             }
             $this.lastTriggeredLinksPage = $this.fluidbook.currentPage;
             var pages = $this.fluidbook.getDisplayedPages();
@@ -84,10 +84,10 @@ FluidbookLinks.prototype = {
 
 
             $.each(links, function (k, link) {
-                console.log
                 setTimeout(function () {
+                    $this.showLinkAnimating = false;
                     $this.triggerLinkById(link.link);
-                }, link.delay * 1000);
+                }, k + (link.delay * 1000));
             });
         });
 
@@ -229,11 +229,14 @@ FluidbookLinks.prototype = {
                 return false;
             }
             $this.showLinkAnimating = true;
+            var transition = $(this).data('showtransition') ? $(this).data('showtransition') : 'fadein';
+            var preventOtherTransitionTimeout = transition === 'fadeinout' ? 1000 : 500;
+
             setTimeout(function () {
                 $this.showLinkAnimating = false;
-            }, 1000);
+            }, preventOtherTransitionTimeout);
             var mode = $(this).data('showmode');
-            var transition = $(this).data('showtransition') ? $(this).data('showtransition') : 'fadein';
+
             var ids = $(this).data('showid').toString().split(',');
 
             if (mode === 'hide') {
@@ -253,6 +256,8 @@ FluidbookLinks.prototype = {
             }
 
             var showid = [];
+            var hide = [];
+
             if (mode === 'pickrandom') {
                 while (true) {
                     var idx = Math.floor(Math.random() * ids.length);
@@ -292,38 +297,60 @@ FluidbookLinks.prototype = {
                 $('[data-showid="' + $(this).attr('data-showid') + '"]').each(function () {
                     $(this).data('current-showid', showid[0]);
                 });
+            } else if (mode === 'showhide') {
+                $.each(ids, function (k, v) {
+                    let sign = v.substring(0, 1);
+                    let offset = 0;
+                    let show = true;
+                    let id = v;
+                    if (sign === '+') {
+                        offset = 1;
+                    } else if (sign === '-') {
+                        offset = 1;
+                        show = false;
+                    }
+                    if (offset > 0) {
+                        id = id.substring(offset);
+                    }
+                    if (show) {
+                        showid.push(id);
+                    } else {
+                        hide.push(id);
+                    }
+                });
             } else {
                 showid = ids;
             }
 
             let showTimeout = 10;
-            if (mode === 'exclusiveshow' || mode === 'shownext' || mode === 'shownextcycle' || mode === 'showprev' || mode === 'showprevcycle' || mode === 'pickrandom') {
+            if (mode === 'exclusiveshow' || mode === 'shownext' || mode === 'shownextcycle' || mode === 'showprev' || mode === 'showprevcycle' || mode === 'pickrandom' || mode === 'showhide') {
                 var selector = 'div.link[data-hidden="1"].show';
-                var hide = [];
+
                 // Only hide links that are in the list
-                if ($(this).is('[data-showid]')) {
-                    hide = $(this).data('showid').split(',');
-                    var maxZindex = 0;
-                    $.each(hide, function (k, hideid) {
-                        var e = $('[data-id="' + hideid + '"]');
-                        var zIndex;
-                        if ($(e).is('[data-zindex]')) {
-                            zIndex = $(e).attr('data-zindex');
-                        } else {
-                            zIndex = $(e).css('z-index');
-                            $(e).attr('data-zindex', zIndex);
-                        }
+                if (mode !== 'showhide') {
+                    if ($(this).is('[data-showid]')) {
+                        hide = $(this).data('showid').split(',');
+                        var maxZindex = 0;
+                        $.each(hide, function (k, hideid) {
+                            var e = $('[data-id="' + hideid + '"]');
+                            var zIndex;
+                            if ($(e).is('[data-zindex]')) {
+                                zIndex = $(e).attr('data-zindex');
+                            } else {
+                                zIndex = $(e).css('z-index');
+                                $(e).attr('data-zindex', zIndex);
+                            }
 
-                        maxZindex = Math.max(parseInt(zIndex), maxZindex);
-                    });
-                } else {
-                    hide = 'all';
-                }
-                if (mode === 'exclusiveshow') {
-                    hide = 'all';
+                            maxZindex = Math.max(parseInt(zIndex), maxZindex);
+                        });
+                    } else {
+                        hide = 'all';
+                    }
+                    if (mode === 'exclusiveshow') {
+                        hide = 'all';
+                    }
                 }
 
-
                 var transitionTime = 500;
                 var hideTimeout = 10;
                 if (transition === 'fadein') {
@@ -357,6 +384,7 @@ FluidbookLinks.prototype = {
 
 
             $.each(showid, function (k, id) {
+
                 $('div.link[data-id$="' + id + '"]').each(function () {
                     var l = this;
                     if (close !== 'none') {