save: function () {
this.fluidbook.cache.set('cart', this.items);
+ this.fluidbook.cart.updateLinks();
+ },
+ getItemsReferences: function () {
+ return this.items;
},
getItemsNumbers: function () {
return this.items.length;
qty = parseInt($(this).attr('data-cart-qty'));
}
- var tooltipStyle='';
- try{
- tooltipStyle= $this.instance.getTooltipStyle();
- }catch (e){
+ var tooltipStyle = '';
+ try {
+ tooltipStyle = $this.instance.getTooltipStyle();
+ } catch (e) {
}
if ($this.instance.addToCart($(this).data('cart-ref'), qty)) {
- $this.fluidbook.tooltip.displayTooltip($this.fluidbook.l10n.__("the item has been added to your cart"),tooltipStyle);
+ $this.fluidbook.tooltip.displayTooltip($this.fluidbook.l10n.__("the item has been added to your cart"), tooltipStyle);
}
return false;
});
+
+ $(this.fluidbook).on('fluidbook.links.ready', function () {
+ $this.updateLinks();
+ });
+ },
+
+ updateLinks: function () {
+ $('a[data-cart-ref]').removeClass('active');
+ try {
+ var references = this.instance.getItemsReferences();
+ } catch (err) {
+ return;
+ }
+
+ $.each(references, function (k, ref) {
+ $('a[data-cart-ref="' + ref + '"]').addClass('active');
+ });
},
getMenuWidth: function () {
try {