]> _ Git - fluidbook-html5.git/commitdiff
wip #7898 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 14 Jan 2026 10:58:19 +0000 (11:58 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 14 Jan 2026 10:58:19 +0000 (11:58 +0100)
js/libs/fluidbook/cart/fluidbook.cart.kimplay.js
js/libs/fluidbook/fluidbook.cart.js
style/cart/kimplay.less

index 03e32446c69bf33c27fa1bc382dadc8ddf5dc65b..6b998f70a2e04ef079d08ec45df5172be5fe0383 100644 (file)
@@ -86,7 +86,11 @@ FluidbookCartKimplay.prototype = {
     },
 
     getItemsNumbers: function () {
-        return this.getItems().length;
+        let res = 0;
+        $.each(this.getItems(), function (i, item) {
+            res++;
+        });
+        return res;
     },
 
     getAllQuantities: function () {
@@ -104,6 +108,7 @@ FluidbookCartKimplay.prototype = {
     },
 
     updateIcon: function () {
+        console.log(this.getItemsNumbers());
         $(this.fluidbook).trigger('fluidbook.cart.updateIcon', {number: this.getItemsNumbers()});
     },
 
index 6d470492b1e75cfce045fc64974c08c1b7141ba8..c5f5291bff159edf2e3dd6411396826ef096ecac 100644 (file)
@@ -102,6 +102,27 @@ FluidbookCart.prototype = {
         $(this.fluidbook).on('fluidbook.links.ready', function () {
             $this.updateLinks();
         });
+
+        $(this.fluidbook).on('fluidbook.cart.updateIcon', function (e, data) {
+            var n = data.number;
+            let l = $('div.link[data-action="basket"]');
+            if ($(l).length > 0) {
+                if (n === 0) {
+                    $(l).find('span.number').remove();
+                } else {
+                    if ($(l).find('span.number').length === 0) {
+                        $(l).append('<span class="number"></span>');
+                    }
+                    $(l).find('span.number').text(n);
+                }
+            }
+        });
+
+        if (this.instance.updateIcon !== undefined) {
+            $(this.fluidbook).on('fluidbook.ready', function () {
+                $this.instance.updateIcon();
+            });
+        }
     },
 
     hasItem: function (ref) {
index e3c8d1a3176cbeb8bc10f03438e89a70a3b609ad..3a176b1c3e176fac45780c79c084341ba1cf405e 100644 (file)
       cursor: pointer;
     }
   }
+}
+
+div.link[data-action="basket"] {
+  position: relative;
+
+  span.number {
+    position: absolute;
+    background-color: #e30613;
+    color: #fff;
+    text-align: center;
+    right: -10px;
+    bottom: -10px;
+    width: 20px;
+    height: 20px;
+    border-radius: 50%;
+    font-weight: bold;
+    font-size: 12px;
+    line-height: 20px;
+  }
 }
\ No newline at end of file