+
+
function FluidbookCartPuma(cart) {
var $this = this;
this.cart = cart;
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 () {
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);
+// this.fluidbook.l10n.__("remove from cart")
+
function FluidbookCart(fluidbook) {
this.fluidbook = fluidbook;
this.enabled = false;
} 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;
});
}
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 = $('<textarea />').html(text).text();
if (text.substr(0, 1) == '~') {
var text = $this.fluidbook.l10n.__(text.substring(1));
- $(target).attr('data-tooltip', text);
+ if (!conditionnalText) {
+ $(target).attr('data-tooltip', text);
+ }
}
+
if (text == undefined || text == '') {
return false;
}