]> _ Git - fluidbook-html5.git/commitdiff
wip #5940 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 23 May 2023 17:57:58 +0000 (19:57 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 23 May 2023 17:57:58 +0000 (19:57 +0200)
js/libs/fluidbook/fluidbook.links.js

index 7686a2f8c4eeb6fb5c02266b79a220bea30a481a..8b5da7acabd16e064500b5f32a9420394d95d6cf 100644 (file)
@@ -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) {