this.fluidbook = this.cart.fluidbook;
this.data = this.fluidbook.settings.basketReferences;
this.exportFileName = '';
+ this.base64URL = {};
+ this.base64Loading = 0;
this.init();
}
value = $this.formatPrice(value, '€');
} else if (v.type === 'image') {
if ($this.data[ref] && $this.data[ref]['zoom_image']) {
+ $this.setBase64URL(ref);
value = '<img data-ref="' + ref + '" src="' + $this.data[ref]['zoom_image'] + '" />';
} else {
value = '-';
return content;
},
+ setBase64URL: function (ref) {
+ if (this.base64URL[ref] !== undefined && this.base64URL[ref] !== null) {
+ return;
+ }
+ this.base64URL[ref] = '__LOADING__';
+ this.base64Loading++;
+ let $this = this;
+ this.toDataURL(this.data[ref]['zoom_image'], function (dataUrl) {
+ $this.base64URL[ref] = dataUrl;
+ this.base64Loading--;
+ });
+ },
+
+ toDataURL: function (url, callback) {
+ var xhr = new XMLHttpRequest();
+ xhr.onload = function () {
+ var reader = new FileReader();
+ reader.onloadend = function () {
+ callback(reader.result);
+ }
+ reader.readAsDataURL(xhr.response);
+ };
+ xhr.open('GET', url);
+ xhr.responseType = 'blob';
+ xhr.send();
+ },
+
exportPDF: function () {
//
$.each(this.getItems(), function (i, ref) {
var img = workbook.addImage({
- base64: 'data:image/jpeg;base64,' + $this.data[ref]['zoom_url'], extension: 'jpeg',
+ base64: $this.base64URL[ref],
+ extension: 'jpeg',
});
sheet.addImage(img, {tl: {col: 0, row: i + 1}, br: {col: 1, row: i + 2}, editAs: 'twoCell'});
});
this.fluidbook = this.cart.fluidbook;
this.data = this.fluidbook.settings.basketReferences;
this.exportFileName = '';
+ this.base64URL = {};
+ this.base64Loading = 0;
this.init();
}
}
return false;
});
+
$(document).on(this.fluidbook.input.clickEvent, '.exportEANXLS', function () {
try {
$this.chooseFileName(function () {
content: 'Are you sure you want to empty your cart?',
buttons: {
confirm: {
- text: 'Confirm',
- btnClass: 'btn-ok',
- action: function () {
+ text: 'Confirm', btnClass: 'btn-ok', action: function () {
$this.emptyCart();
},
- },
- cancel: function () {
+ }, cancel: function () {
},
}
resize();
},
- addToCart: function (ref, quantity) {
- if (this.getItems().indexOf(ref) === -1) {
+ addToCart: function (ref, quantity, force) {
+ let inCart = this.getItems().indexOf(ref) >= 0;
+ let add = (force === undefined) ? !inCart : force;
+ if (add && !inCart) {
this.items.push(ref);
this.save();
return this.fluidbook.l10n.__("the item has been added to your cart");
- } else {
+ }
+ if (!add && inCart) {
this.removeFromCartByRef(ref);
return this.fluidbook.l10n.__("the item has been removed from your cart");
}
if (v === 'PVC' || v === 'Tarif') {
value = $this.formatPrice(value, '€');
} else if (v === 'Image') {
+
if ($this.data[ref] && $this.data[ref]['zoom_image']) {
+ $this.setBase64URL(ref);
value = '<img data-ref="' + ref + '" src="' + $this.data[ref]['zoom_image'] + '" />';
} else {
value = '-';
return content;
},
+ setBase64URL: function (ref) {
+ if (this.base64URL[ref] !== undefined && this.base64URL[ref] !== null) {
+ return;
+ }
+ this.base64URL[ref] = '__LOADING__';
+ this.base64Loading++;
+ let $this = this;
+ this.toDataURL(this.data[ref]['zoom_image'], function (dataUrl) {
+ $this.base64URL[ref] = dataUrl;
+ this.base64Loading--;
+ });
+ },
+
+ toDataURL: function (url, callback) {
+ var xhr = new XMLHttpRequest();
+ xhr.onload = function () {
+ var reader = new FileReader();
+ reader.onloadend = function () {
+ callback(reader.result);
+ }
+ reader.readAsDataURL(xhr.response);
+ };
+ xhr.open('GET', url);
+ xhr.responseType = 'blob';
+ xhr.send();
+ },
+
exportPDF: function () {
},
formatDate: function (date) {
- var d = new Date(date),
- month = '' + (d.getMonth() + 1),
- day = '' + d.getDate(),
- year = d.getFullYear();
+ var d = new Date(date), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear();
- if (month.length < 2)
- month = '0' + month;
- if (day.length < 2)
- day = '0' + day;
+ if (month.length < 2) month = '0' + month;
+ if (day.length < 2) day = '0' + day;
return [year, month, day].join('-');
},
var $this = this;
const workbook = new ExcelJS.Workbook();
const sheet = workbook.addWorksheet(this.fluidbook.settings.title);
- sheet.views = [
- {state: 'frozen', xSplit: 0, ySplit: 1, topLeftCell: 'A2', activeCell: 'A2'}
- ];
+ sheet.views = [{state: 'frozen', xSplit: 0, ySplit: 1, topLeftCell: 'A2', activeCell: 'A2'}];
sheet.properties.defaultRowHeight = 15;
var columnsLabels = ['Reference', 'Size Description', 'EAN13', 'Season Description', 'Rbu', 'Family', 'Article', 'Model Id', 'Color Id', 'Units'];
var columns = [];
var $this = this;
$.confirm({
title: 'Name your file',
- content: '' +
- '<form action="" class="formName">' +
- '<div class="form-group">' +
- '<input type="text" value="' + this.getExportFileName() + '" placeholder="File name" class="name form-control" required />' +
- '</div>' +
- '</form>',
+ content: '' + '<form action="" class="formName">' + '<div class="form-group">' + '<input type="text" value="' + this.getExportFileName() + '" placeholder="File name" class="name form-control" required />' + '</div>' + '</form>',
buttons: {
formSubmit: {
- text: 'Submit',
- btnClass: 'btn-ok',
- action: function () {
+ text: 'Submit', btnClass: 'btn-ok', action: function () {
$this.exportFileName = this.$content.find('.name').val();
callback();
}
- },
- cancel: function () {
+ }, cancel: function () {
//close
},
},
var $this = this;
const workbook = new ExcelJS.Workbook();
const sheet = workbook.addWorksheet(this.fluidbook.settings.title);
- sheet.views = [
- {state: 'frozen', xSplit: 0, ySplit: 1, topLeftCell: 'A2', activeCell: 'A2'}
- ];
+ sheet.views = [{state: 'frozen', xSplit: 0, ySplit: 1, topLeftCell: 'A2', activeCell: 'A2'}];
sheet.properties.defaultRowHeight = 15;
var columnsLabels = this.getExcelColumns();
var columns = [];
sheet.getColumn(k + 1).numFmt = fmt[v];
});
//
+
$.each(this.getItems(), function (i, ref) {
var img = workbook.addImage({
- base64: 'data:image/jpeg;base64,' + $this.data[ref]['zoom_url'],
- extension: 'jpeg',
+ base64: $this.base64URL[ref], extension: 'jpeg',
});
sheet.addImage(img, {tl: {col: 0, row: i + 1}, br: {col: 1, row: i + 2}, editAs: 'twoCell'});
});
}
var res = price.toLocaleString("fr-FR", {
- style: "currency",
- currency: "EUR",
- minimumFractionDigits: 2,
- maximumFractionDigits: 2
+ style: "currency", currency: "EUR", minimumFractionDigits: 2, maximumFractionDigits: 2
});
if (res.indexOf(suffix) === -1) {
res += ' ' + suffix;
// this.fluidbook.l10n.__("remove from cart")
+// this.fluidbook.l10n.__('remove all page products from cart')
+// this.fluidbook.l10n.__('add all page products to cart')
function FluidbookCart(fluidbook) {
this.fluidbook = fluidbook;
}
var ref = $(this).data('cart-ref');
+ let refs = [];
+ if (ref === 'auto:all_in_page') {
+ $('#links [data-cart-ref]').each(function () {
+ let r = $(this).data('cart-ref');
+ if (r.indexOf('auto:') === 0) {
+ return;
+ }
+ if (refs.indexOf(r) === -1) {
+ refs.push(r);
+ }
+ });
+ } else {
+ refs = [ref];
+ }
- $this.fluidbook.stats.track(15, $this.fluidbook.currentPage, ref);
+ let force = $this.instance.getItems().indexOf(refs[0]) === -1;
+
+ var tooltip;
+ $.each(refs, function (k, ref) {
+ $this.fluidbook.stats.track(15, $this.fluidbook.currentPage, ref);
+ $this.instance.addToCart(ref, qty, force);
+ });
+
+ if (refs.length > 1) {
+ if (force) {
+ tooltip = $this.fluidbook.l10n.__("the items have been added to your cart");
+ } else {
+ tooltip = $this.fluidbook.l10n.__("the items have been removed from your cart");
+ }
+ } else {
+ if (force) {
+ tooltip = $this.fluidbook.l10n.__("the item has been added to your cart");
+ } else {
+ tooltip = $this.fluidbook.l10n.__("the item has been removed from your cart");
+ }
+ }
var tooltipStyle = '';
try {
} 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();
} catch (err) {
}
+ if ($("#links a[data-cart-ref]").not('[data-cart-ref="auto:all_in_page"]').eq(0).hasClass('active')) {
+ $('[data-cart-ref="auto:all_in_page"]').addClass('active');
+ }
+
if (this.fluidbook.settings.cartLinkAppearance === 'overlay') {
$('a[data-cart-ref]').each(function () {
var c = [];
var paddingTop = 0.5 * ($(this).outerHeight() - bh);
var paddingLeft = 0.5 * ($(this).outerWidth() - bw);
$(this).attr('data-tooltip', null).addClass('overlay').css({
- paddingTop: paddingTop,
- paddingLeft: paddingLeft
+ paddingTop: paddingTop, paddingLeft: paddingLeft
}).html('<div class="remove">' + getSpriteIcon('link-cart-remove') + getSpriteIcon('link-cart-remove-hover') + '</div><div class="add">' + getSpriteIcon('link-cart-add') + getSpriteIcon('link-cart-add-hover') + '</div><div class="infos">' + getSpriteIcon('link-cart-info') + '</div>');
});
}
getSavedData: function () {
return this.fluidbook.cache.get('cart', {})
- },
- saveData: function (data) {
+ }, saveData: function (data) {
this.fluidbook.cache.set('cart', data);
- },
- createInstance: function () {
+ }, createInstance: function () {
switch (this.fluidbook.settings.basketManager) {
case "Remarkable":
return new FluidbookCartRemarkable(this);
this.element.val(this.normalize());
this.inited = true;
- },
- normalize: function (v) {
+ }, normalize: function (v) {
var origV;
if (v === undefined) {
v = this.element.val();
}
return v;
- },
- increment: function (i) {
+ }, increment: function (i) {
var v = this.normalize();
var v1 = v;
v += i;