From 968a37fa7ceb8a16eed7dc269e7a42643b0635cb Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 6 Jun 2023 17:45:57 +0200 Subject: [PATCH] wait #5998 @0.75 --- js/libs/fluidbook/fluidbook.links.js | 82 +++++++++++++++++++--------- 1 file changed, 55 insertions(+), 27 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.links.js b/js/libs/fluidbook/fluidbook.links.js index 9857785a..2c995abd 100644 --- a/js/libs/fluidbook/fluidbook.links.js +++ b/js/libs/fluidbook/fluidbook.links.js @@ -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') { -- 2.39.5