From: Vincent Vanwaelscappel Date: Mon, 16 Nov 2020 11:07:36 +0000 (+0100) Subject: wait #4057 @0.75 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ff255cfeb2df59f34c796704e84f7ce46278bc41;p=fluidbook-html5.git wait #4057 @0.75 --- diff --git a/js/libs/fluidbook/cart/fluidbook.cart.puma.js b/js/libs/fluidbook/cart/fluidbook.cart.puma.js index cb2d5437..f526c2a1 100644 --- a/js/libs/fluidbook/cart/fluidbook.cart.puma.js +++ b/js/libs/fluidbook/cart/fluidbook.cart.puma.js @@ -1,3 +1,5 @@ + + function FluidbookCartPuma(cart) { var $this = this; this.cart = cart; @@ -28,16 +30,19 @@ FluidbookCartPuma.prototype = { if (this.getItems().indexOf(ref) === -1) { this.items.push(ref); this.save(); - return true; + return this.fluidbook.l10n.__("the item has been added to your cart"); } else { this.removeFromCart(ref); - return false; + return this.fluidbook.l10n.__("the item has been removed from your cart"); } }, - removeFromCart: function (key) { - this.items.splice(key, 1); - this.save(); + removeFromCart: function (ref) { + var key = this.items.indexOf(ref); + if (key >= 0) { + this.items.splice(key, 1); + this.save(); + } }, save: function () { @@ -81,7 +86,7 @@ FluidbookCartPuma.prototype = { getItems: function () { var res = []; - var $this=this; + var $this = this; $(this.items).each(function (i, ref) { if ($this.data[ref] !== undefined && $this.data[ref] !== null) { res.push(ref); diff --git a/js/libs/fluidbook/fluidbook.cart.js b/js/libs/fluidbook/fluidbook.cart.js index c513e164..664f25b2 100644 --- a/js/libs/fluidbook/fluidbook.cart.js +++ b/js/libs/fluidbook/fluidbook.cart.js @@ -1,3 +1,5 @@ +// this.fluidbook.l10n.__("remove from cart") + function FluidbookCart(fluidbook) { this.fluidbook = fluidbook; this.enabled = false; @@ -35,9 +37,12 @@ FluidbookCart.prototype = { } catch (e) { } - if ($this.instance.addToCart(ref, qty)) { - $this.fluidbook.tooltip.displayTooltip($this.fluidbook.l10n.__("the item has been added to your cart"), tooltipStyle); + var tooltip = $this.instance.addToCart(ref, qty); + if (!tooltip) { + tooltip = $this.fluidbook.l10n.__("the item has been added to your cart"); } + $this.fluidbook.tooltip.displayTooltip(tooltip, tooltipStyle); + return false; }); diff --git a/js/libs/fluidbook/fluidbook.tooltip.js b/js/libs/fluidbook/fluidbook.tooltip.js index b080545b..27895671 100644 --- a/js/libs/fluidbook/fluidbook.tooltip.js +++ b/js/libs/fluidbook/fluidbook.tooltip.js @@ -107,20 +107,31 @@ FluidbookTooltip.prototype = { } var $this = this; - - var text = ''; if ($(target).is('[data-tooltip]')) { text = $(target).attr('data-tooltip'); } else if ($(target).is('[data-keyboard-tooltip]')) { text = $(target).attr('data-keyboard-tooltip'); } + var conditionnalText = false; + if ($(target).is('[data-tooltip-conditional]')) { + $.each($(target).data('tooltip-conditional'), function (condition, ctext) { + if ($(target).is(condition)) { + text = '~' + ctext; + conditionnalText = true; + return false; + } + }); + } text = $('