]> _ Git - fluidbook-html5.git/commitdiff
wait #6421 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 14 Nov 2023 18:14:45 +0000 (19:14 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 14 Nov 2023 18:14:45 +0000 (19:14 +0100)
js/libs/fluidbook/fluidbook.links.js

index 8eb58b20391509674f567baef771290a53122c7e..c3a8d1dc343eeab3bfc484c4371f1fcfbf261f36 100644 (file)
@@ -298,7 +298,8 @@ FluidbookLinks.prototype = {
                 $('[data-showid="' + $(this).attr('data-showid') + '"]').each(function () {
                     $(this).data('current-showid', showid[0]);
                 });
-            } else if (mode === 'showhide') {
+            } else if (mode === 'showhide' || mode === 'toggleshowhide') {
+                let invert = false;
                 $.each(ids, function (k, v) {
                     let sign = v.substring(0, 1);
                     let offset = 0;
@@ -313,22 +314,29 @@ FluidbookLinks.prototype = {
                     if (offset > 0) {
                         id = id.substring(offset);
                     }
-                    if (show) {
+
+                    if (k === 0 && mode === 'toggleshowhide') {
+                        let l = $('div.link[data-id="' + id + '"]').hasClass('show');
+                        invert = (l && show) || (!l && !show);
+                    }
+
+                    if ((show && !invert) || (!show && invert)) {
                         showid.push(id);
                     } else {
                         hide.push(id);
                     }
                 });
+                console.log('showhide', showid, hide);
             } else {
                 showid = ids;
             }
 
             let showTimeout = 10;
-            if (mode === 'exclusiveshow' || mode === 'shownext' || mode === 'shownextcycle' || mode === 'showprev' || mode === 'showprevcycle' || mode === 'pickrandom' || mode === 'showhide') {
+            if (mode === 'exclusiveshow' || mode === 'shownext' || mode === 'shownextcycle' || mode === 'showprev' || mode === 'showprevcycle' || mode === 'pickrandom' || mode === 'showhide' || mode === 'toggleshowhide') {
                 var selector = 'div.link[data-hidden="1"].show';
 
                 // Only hide links that are in the list
-                if (mode !== 'showhide') {
+                if (mode !== 'showhide' && mode !== 'toggleshowhide') {
                     if ($(this).is('[data-showid]')) {
                         hide = $(this).data('showid').split(',');
                         var maxZindex = 0;
@@ -364,6 +372,7 @@ FluidbookLinks.prototype = {
                 $.each(showid, function (k, id) {
                     selector += ':not([data-id$="' + id + '"])';
                 });
+                console.log(selector);
                 $(selector).each(function () {
                     let timeout = hideTimeout;
                     if ($(selector).is('[data-animation-hide]')) {
@@ -374,6 +383,7 @@ FluidbookLinks.prototype = {
                         if ($(this).is('[data-zindex]')) {
                             $(this).css('z-index', $(this).data('zindex'));
                         }
+                        console.log('hide ',id);
                         $this.hidePlacedLink(this, timeout);
                     }
                 });