From 2a08b2243f1b4470f6537b99392c4bbb1e8de3e9 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 23 May 2023 19:57:58 +0200 Subject: [PATCH] wip #5940 @0.5 --- js/libs/fluidbook/fluidbook.links.js | 39 ++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.links.js b/js/libs/fluidbook/fluidbook.links.js index 7686a2f8..8b5da7ac 100644 --- a/js/libs/fluidbook/fluidbook.links.js +++ b/js/libs/fluidbook/fluidbook.links.js @@ -239,13 +239,14 @@ FluidbookLinks.prototype = { $.each(ids, function (k, id) { $('div.link[data-id="' + id + '"]').hide(); }); + $this.updateAttachedLinks(); return false; } if (mode === 'toggle') { $.each(ids, function (k, id) { - console.log('toggle ' + id); $('div.link[data-id$="' + id + '"]').toggleClass('show'); + $this.updateAttachedLinks(); }); return false; } @@ -270,7 +271,6 @@ FluidbookLinks.prototype = { $.each(ids, function (k, id) { if ($('[data-id="' + id + '"].show').length > 0) { current = id; - console.log(current); } } ); @@ -364,7 +364,6 @@ FluidbookLinks.prototype = { $(l).find('img').css('pointer-events', 'none'); } - console.log(maxZindex); if (maxZindex !== undefined) { $(l).css('z-index', maxZindex + 1) } @@ -374,10 +373,13 @@ FluidbookLinks.prototype = { $this.animateContentLink($(l), true, true); } $(l).addClass('show'); + $this.updateAttachedLinks(); }, 10); }); }); + + return false; }); @@ -458,8 +460,24 @@ FluidbookLinks.prototype = { }); }, - stopLinkById: function (id) { + updateAttachedLinks: function () { + $('[data-attached]').each(function () { + var attached = $('.link[data-id="' + $(this).data('attached') + '"]'); + var visible = true; + if (attached.length === 0 || !$(attached).is(':visible') || ($(attached).attr('data-hidden') === '1' && !$(attached).hasClass('show'))) { + console.log(attached,this); + visible = false; + } + if (visible) { + $(this).show(); + } else { + $(this).hide(); + } + }); + }, + + stopLinkById: function (id) { var link = $('.link[data-id="' + id + '"]'); if ($(link).length === 0) { console.warn('Link ' + id + ' cant be stopped'); @@ -514,25 +532,30 @@ FluidbookLinks.prototype = { }, showLinkById: function (id) { + var $this = this; var s = $('div.link[data-id="' + id + '"]'); s.show(); setTimeout(function () { s.addClass('show'); + $this.updateAttachedLinks(); }, 10); }, hideLinkById: function (id) { + var $this = this; var s = $('div.link[data-id="' + id + '"]'); if ($(s).attr('data-hidden') != '1') { $(s).attr('data-hidden', '1').addClass('show'); } setTimeout(function () { $(s).removeClass('show'); + $this.updateAttachedLinks(); }, 10); }, hidePlacedLink: function (p, timeout) { + var $this = this; if ($(p).length === 0) { return; } @@ -544,7 +567,9 @@ FluidbookLinks.prototype = { $(p).find('.linkshowclose').remove(); setTimeout(function () { $(p).hide(); - }, 500) + $this.updateAttachedLinks(); + }, 500); + $this.updateAttachedLinks(); }, timeout); }, @@ -613,10 +638,12 @@ FluidbookLinks.prototype = { $this.fluidbook.audioplayer.initAudios(); $this.initInlineSlideshows(); $this.fluidbook.l10n.translateAttributes(); + $this.updateAttachedLinks(); }, 200); $(this.fluidbook).trigger('fluidbook.links.ready'); + $this.updateAttachedLinks(); this.resize(); }, @@ -1130,6 +1157,7 @@ FluidbookLinks.prototype = { if (animateBookmarks) { this._blink($("#links .bookmark:not([data-enabled])")); } + this.updateAttachedLinks(); }, _blink: function (el, delay) { @@ -1236,6 +1264,7 @@ FluidbookLinks.prototype = { .css({width: iw, height: ih, transform: 'scale(' + scale + ')'}); } }); + this.updateAttachedLinks(); }, rolloverEnter: function (iid) { -- 2.39.5