function FluidbookCartRemarkable(cart) {
+ var $this = this;
this.cart = cart;
this.fluidbook = this.cart.fluidbook;
this.items = {};
+ this.database;
+ $.each(this.fluidbook.datas.basketReferences, function (k, v) {
+ $this.database = {};
+ $.each(v, function (index, line) {
+ $this.database[line[0]] = {
+ ref: line[0],
+ name: line[1],
+ price: parseFloat(line[2]),
+ tax: parseFloat(line[3]) / 100
+ }
+ });
+ return true;
+ });
this.init();
}
$(this.fluidbook).trigger('fluidbook.cart.updateIcon', {number: this.getItemsNumbers()});
},
+ openMenu: function (p1, p2, callback) {
+ if (p1 == 'shipping') {
+ return this.openShipping(p2, callback);
+ } else if (p1 == 'confirm') {
+ return this.openConfirm(p2, callback);
+ } else {
+ return this.openCart(p2, callback);
+ }
+ },
+
+ openCart: function (p2, callback) {
+ var $this = this;
+ var content = '<table class="cart-items">';
+ $.each(this.items, function (ref, quantity) {
+ var item = $this.getItemData(ref);
+
+ content += '<tr>';
+ content += '<td class="name">' + item.name + '</td>';
+ content += '<td class="quantity">' + quantity + '</td>';
+ content += '<td class="price_unit">' + $this.formatPrice(item.price, 'HT') + '</td>';
+ content += '<td class="price_excluding_taxes">' + $this.formatPrice(item.price * quantity, 'HT') + '</td>';
+ content += '<td class="price">' + $this.formatPrice((item.price * quantity) * (1 + item.tax), 'TTC') + '</td>';
+ content += '<td class="delete"></td>';
+
+ content + '</tr>';
+ });
+ content + '</table>';
+ this._endMenu(this.fluidbook.l10n.__('your cart'), content, callback);
+ },
+
+ formatPrice: function (price, currency, suffix) {
+ if (suffix == undefined) {
+ suffix = '';
+ }
+
+ return price.toLocaleString("fr-FR", {style: "currency", currency: "EUR"}) + ' ' + suffix;
+ },
+
+ getItemData: function (ref) {
+ return this.database[ref];
+ },
+
+
+ openShipping: function (p2, callback) {
+ var content = '';
+ this._endMenu(this.fluidbook.l10n.__('your contact details'), content, callback);
+ },
+
+ openConfirm: function (p2, callback) {
+ var content = '';
+ this._endMenu(this.fluidbook.l10n.__('confirmation'), content, callback);
+ },
+
+
+ _endMenu: function (title, content, callback) {
+ var view = '<div class="caption">' + this.fluidbook.menu.closeButton() + '<h2>' + title + '</h2></div>';
+ view += '<div class="content">';
+ view += "" + content;
+ view += '</div>';
+ $("#view").append('<div class="mview" data-menu="cart">' + view + '</div>');
+ callback();
+ }
+
};
\ No newline at end of file
if (callback != undefined) {
callback();
}
- }
- ,
+ },
+
+ openCart: function (p1, p2, callback) {
+ this.fluidbook.cart.instance.openMenu(p1, p2, callback);
+ },
openShare: function (p1, p2, callback) {
this.fluidbook.share.openShare(p1, p2, callback);
},
case 'locales':
w = 300;
break;
+ case 'cart':
+ w = 1024;
+ break;
case 'bookmarks':
var max = Math.floor((ww * 0.8) / 120) * 120 + 40;
w = Math.min(max, Math.max(m.find('.doubleThumb').length, 4) * 120 + 40);
h = nh * s;
}
- x = (w - (nw * s) ) / 2;
+ x = (w - (nw * s)) / 2;
y = (h - (nh * s)) / 2;
}
if (s < 1) {
- var css = {overflow: 'hidden', width: nw * s, height: nh * s, top: y, left: x, position: 'absolute'};
+ var css = {
+ overflow: 'hidden',
+ width: nw * s,
+ height: nh * s,
+ top: y,
+ left: x,
+ position: 'absolute'
+ };
m.find('.multimediaHolder').css(css);
} else {
- m.find('.multimediaHolder').css({position: "", overflow: '', width: '', height: '', top: '', left: ''});
+ m.find('.multimediaHolder').css({
+ position: "",
+ overflow: '',
+ width: '',
+ height: '',
+ top: '',
+ left: ''
+ });
}
- m.find('.multimediaScale').css({width: nw, height: nh, overflow: 'hidden'}).transform({scale: [s, s], origin: [0, 0]}).css('text-align', 'left');
+ m.find('.multimediaScale').css({width: nw, height: nh, overflow: 'hidden'}).transform({
+ scale: [s, s],
+ origin: [0, 0]
+ }).css('text-align', 'left');
break;
default:
break;
} else if (icon == 'print' && this.fluidbook.datas.print) {
link = this.addLink(navType, 'nav-print', '#', 'print', 'print', 'print');
} else if (icon == 'basket' && this.fluidbook.cart.enabled) {
- link = this.addLink(navType, 'nav-basket', '#', 'cart', 'basket', 'basket');
+ link = this.addLink(navType, 'nav-basket', '#/cart', 'cart', 'basket', 'basket');
$(this.fluidbook).on('fluidbook.cart.updateIcon', {link: link.attr('id')}, function (e, data) {
var n = data.number;
var l = $("#" + e.data.link);