]> _ Git - fluidbook-html5.git/commitdiff
wip #6554 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 20 Dec 2023 08:39:43 +0000 (09:39 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 20 Dec 2023 08:39:43 +0000 (09:39 +0100)
js/libs/fluidbook/fluidbook.cart.js

index 34970f724543d6f72d25824742c894c451a8167f..30f1ce6b0b493b8fc4fbbb548293329f55c73cc2 100644 (file)
@@ -40,6 +40,7 @@ FluidbookCart.prototype = {
 
                     var ref = $(this).data('cart-ref');
                     let refs = [];
+                    let force = false;
                     if (ref === 'auto:all_in_page') {
                         $('#links [data-cart-ref]').each(function () {
                             let r = $(this).data('cart-ref');
@@ -48,13 +49,16 @@ FluidbookCart.prototype = {
                             }
                             if (refs.indexOf(r) === -1) {
                                 refs.push(r);
+                                if ($this.instance.getItems().indexOf(r) === -1) {
+                                    force = true;
+                                }
                             }
                         });
                     } else {
+                        force = $this.instance.getItems().indexOf(ref) === -1;
                         refs = [ref];
                     }
 
-                    let force = $this.instance.getItems().indexOf(refs[0]) === -1;
 
                     var tooltip;
                     $.each(refs, function (k, ref) {
@@ -112,7 +116,7 @@ FluidbookCart.prototype = {
         } catch (err) {
         }
 
-        if ($("#links a[data-cart-ref]").not('[data-cart-ref="auto:all_in_page"]').eq(0).hasClass('active')) {
+        if ($("#links a[data-cart-ref]").not('[data-cart-ref="auto:all_in_page"]').not('.active').length === 0) {
             $('[data-cart-ref="auto:all_in_page"]').addClass('active');
         }