]> _ Git - fluidbook-html5.git/commitdiff
wip #4259 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 5 Apr 2022 08:31:46 +0000 (10:31 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 5 Apr 2022 08:31:46 +0000 (10:31 +0200)
js/libs/fluidbook/cart/fluidbook.cart.thiriet.js [new file with mode: 0644]
js/libs/fluidbook/fluidbook.cart.js

diff --git a/js/libs/fluidbook/cart/fluidbook.cart.thiriet.js b/js/libs/fluidbook/cart/fluidbook.cart.thiriet.js
new file mode 100644 (file)
index 0000000..d202ce0
--- /dev/null
@@ -0,0 +1,36 @@
+function FluidbookCartThiriet(cart) {
+    this.cart = cart;
+    this.fluidbook = this.cart.fluidbook;
+    this.handleClicks = true;
+    this.init();
+}
+
+FluidbookCartThiriet.prototype = {
+    init: function () {
+        $(document).on(this.fluidbook.input.clickEvent, '[data-cart-ref] .add', function () {
+            try {
+                plusProduct($(this).data('cart-ref'));
+            } catch (e) {
+                console.warn('plusProduct() is unavailable');
+                console.error(e);
+            }
+        });
+        $(document).on(this.fluidbook.input.clickEvent, '[data-cart-ref] .remove', function () {
+            try {
+                minusProduct($(this).data('cart-ref'));
+            } catch (e) {
+                console.warn('minusProduct() is unavailable');
+                console.error(e);
+            }
+        });
+
+        $(document).on(this.fluidbook.input.clickEvent, '[data-cart-ref] .info', function () {
+            try {
+                infoProduct($(this).data('cart-ref'));
+            } catch (e) {
+                console.warn('infoProduct() is unavailable');
+                console.error(e);
+            }
+        });
+    },
+};
\ No newline at end of file
index 0bdfbff25a3fcb24beb7e97f3fe9141d20810f3c..97d6665f8ee00a36e080d06ec3ca8aa9f844426b 100644 (file)
@@ -16,46 +16,48 @@ FluidbookCart.prototype = {
         this.enabled = true;
         this.instance = this.createInstance();
 
-        $(document).on(this.fluidbook.input.clickEvent, '[data-cart-delete]', function () {
-            if ($(this).closest('.override-delete').length > 0) {
-                return true;
-            }
-            $this.instance.removeFromCart($(this).data('cart-delete'));
-            $this.instance.updateCart(false);
-            return false;
-        });
-
-        $(document).on(this.fluidbook.input.clickEvent, '[data-cart-ref]', function () {
-            try {
-                var qty = 1;
-                if ($(this).data('cart-qty') !== null) {
-                    qty = parseInt($(this).attr('data-cart-qty'));
+        if (this.instance.handleClicks !== true) {
+            $(document).on(this.fluidbook.input.clickEvent, '[data-cart-delete]', function () {
+                if ($(this).closest('.override-delete').length > 0) {
+                    return true;
                 }
+                $this.instance.removeFromCart($(this).data('cart-delete'));
+                $this.instance.updateCart(false);
+                return false;
+            });
 
-                var ref = $(this).data('cart-ref');
-
-                $this.fluidbook.stats.track(15, $this.fluidbook.currentPage, ref);
-
-                var tooltipStyle = '';
+            $(document).on(this.fluidbook.input.clickEvent, '[data-cart-ref]', function () {
                 try {
-                    tooltipStyle = $this.instance.getTooltipStyle();
+                    var qty = 1;
+                    if ($(this).data('cart-qty') !== null) {
+                        qty = parseInt($(this).attr('data-cart-qty'));
+                    }
+
+                    var ref = $(this).data('cart-ref');
+
+                    $this.fluidbook.stats.track(15, $this.fluidbook.currentPage, ref);
+
+                    var tooltipStyle = '';
+                    try {
+                        tooltipStyle = $this.instance.getTooltipStyle();
+                    } catch (e) {
+
+                    }
+                    var tooltip = $this.instance.addToCart(ref, qty);
+                    if (tooltip === undefined || tooltip === null || !tooltip || tooltip === true || tooltip === false || tooltip === 'true' || tooltip === 'false') {
+                        tooltip = $this.fluidbook.l10n.__("the item has been added to your cart");
+                    }
+                    $this.fluidbook.tooltip.displayTooltip(tooltip, tooltipStyle);
+                    setTimeout(function () {
+                        $this.fluidbook.tooltip.hideTooltip();
+                    }, 2500);
                 } catch (e) {
 
                 }
-                var tooltip = $this.instance.addToCart(ref, qty);
-                if (tooltip === undefined || tooltip === null || !tooltip || tooltip === true || tooltip === false || tooltip === 'true' || tooltip === 'false') {
-                    tooltip = $this.fluidbook.l10n.__("the item has been added to your cart");
-                }
-                $this.fluidbook.tooltip.displayTooltip(tooltip, tooltipStyle);
-                setTimeout(function () {
-                    $this.fluidbook.tooltip.hideTooltip();
-                }, 2500);
-            } catch (e) {
-
-            }
 
-            return false;
-        });
+                return false;
+            });
+        }
 
         $(this.fluidbook).on('fluidbook.links.ready', function () {
             $this.updateLinks();