this.cart = cart;
this.fluidbook = this.cart.fluidbook;
this.data = this.fluidbook.settings.basketReferences;
- this.form_endpoint = 'https://workshop.fluidbook.com/services/bastide'; // Where cart form is processed
+ this.form_endpoint = this.fluidbook.service.getBaseURL()+'bastide'; // Where cart form is processed
this.init();
}
this.fluidbook = this.cart.fluidbook;
this.data = this.fluidbook.settings.basketReferences;
this.TVA_percentage = 20; // Displayed in Cart and used to calculate HT value from TTC
- this.form_endpoint = 'https://workshop.fluidbook.com/services/CFOC'; // Where cart form is processed
+ this.form_endpoint = this.fluidbook.service.getBaseURL() + 'CFOC'; // Where cart form is processed
this.init();
}
return true;
});
- $(document).on('change', '#CFOC_user_details [name="profile"]', function() {
+ $(document).on('change', '#CFOC_user_details [name="profile"]', function () {
let profile = $(this).val();
$('#CFOC_user_details form').addClass('hidden'); // Hide all forms
});
// Handle "Valider ma sélection" button in cart
- $(document).on(this.fluidbook.input.clickEvent, '#CFOC_cart [data-validate-cart]', function(event) {
+ $(document).on(this.fluidbook.input.clickEvent, '#CFOC_cart [data-validate-cart]', function (event) {
event.preventDefault();
// Use the built-in HTML5 validation to make sure all fields are valid in the cart
});
// Handle details form validation and submission
- $(document).on(this.fluidbook.input.clickEvent, '#CFOC_user_details [data-send-cart]', function(event) {
+ $(document).on(this.fluidbook.input.clickEvent, '#CFOC_user_details [data-send-cart]', function (event) {
event.preventDefault();
// Since there are multiple forms depending on the profile,
label: 'Profil',
value: $('#CFOC_user_details select[name="profile"]').val()
}
- user_data.forEach(function(value, key) {
+ user_data.forEach(function (value, key) {
user_details[key] = {
label: forms[form_name][key]['label'],
value: value,
this.items.unshift(item);
this.save();
- setTimeout(function() {
+ setTimeout(function () {
$this.fluidbook.tooltip.displayTooltip(fluidbook.l10n.__("the item has been added to your cart"));
setTimeout($this.fluidbook.tooltip.hideTooltip, 3000);
}, 100);
$.each($this.getColumnsForXLS(), function (key, title) {
- switch(key) {
+ switch (key) {
case 'QTE':
item[key] = cart_item['quantity'];
break;
// The columns should be the same as for the cart except we add "EAN" after LIGNE and skip "DELETE"
let columns = {};
- $.each(this.getColumns(), function(key, title) {
+ $.each(this.getColumns(), function (key, title) {
if (key === 'DELETE') return;
getCartContent: function () {
if (this.getItemCount() === 0) {
- return `<div class="cart-empty">${ this.fluidbook.l10n.__('your cart is empty') }</div>`;
+ return `<div class="cart-empty">${this.fluidbook.l10n.__('your cart is empty')}</div>`;
}
let $this = this;
let columns = this.getColumns();
let content =
- `<div class="inner-content">
+ `<div class="inner-content">
<form>
<table id="cfoc-cart-table" class="cart-items">
<thead style="text-transform:uppercase">
<tr>
${Object.entries(columns)
- .map(heading => `<th data-name="${heading[0]}">${heading[1]}</th>`)
- .join('')
- }
+ .map(heading => `<th data-name="${heading[0]}">${heading[1]}</th>`)
+ .join('')
+ }
</tr>
</thead>
<tbody>`;
let value = data[key] || '—'; // Fallback for missing values
let output = '';
- switch(key) {
+ switch (key) {
case 'LIGNE':
- output = data['EXCLU'] ? '*' : ''; // Mark exclusive products with an asterisk
+ output = data['EXCLU'] ? '*' : ''; // Mark exclusive products with an asterisk
output += value;
break;
case 'COULEUR':
let css_class = (item.EAN === '') ? 'alert' : '';
- output = `<select data-item-EAN data-item-index="${index}" class="${css_class}" required>
- <option value="">${ $this.fluidbook.l10n.__('Choisir une couleur') }</option>`;
- $.each(colours, function(EAN, product) {
+ output = `<select data-item-EAN data-item-index="${index}" class="${css_class}" required>
+ <option value="">${$this.fluidbook.l10n.__('Choisir une couleur')}</option>`;
+ $.each(colours, function (EAN, product) {
let selected = (item.EAN === EAN) ? 'selected' : '';
output += `<option value="${EAN}" ${selected}>${product['COULEUR']}</option>`;
});
case 'QTE':
let min_quantity = data['QTE MINI'] || 1;
- output = `<div class="quantity-controls">`;
+ output = `<div class="quantity-controls">`;
output += `<button onclick="this.parentNode.querySelector('input[type=number]').stepDown();
this.parentNode.querySelector('input[type=number]').dispatchEvent(new Event('input', { bubbles: true }));
return content;
},
- getCartSummary: function() {
+ getCartSummary: function () {
// Calculate totals
let total_TTC = this.cartTotalTTC();
let total_HT = this.calculateHT(total_TTC);
}
},
- getCartUserDetailsContent: function() {
+ getCartUserDetailsContent: function () {
let forms = '';
- $.each(this.getForms(), function(name, fields) {
+ $.each(this.getForms(), function (name, fields) {
forms += `<form class="hidden" data-name="${name}">`;
- $.each(fields, function(field_name, field_details) {
+ $.each(fields, function (field_name, field_details) {
let required = field_details.required ? 'required' : '';
let label = field_details.required ? `${field_details.label}*` : field_details.label;
let field_ID = `${name}_${field_name}`;
});
let content =
- `<div class="inner-content" id="CFOC_user_details">
+ `<div class="inner-content" id="CFOC_user_details">
<div class="details-columns">
<div class="details-left">
<select name="profile" class="alert" required>
},
// Calculate the Hors Tax amount based on the TTC amount
- calculateHT: function(TTC_value) {
+ calculateHT: function (TTC_value) {
return this.parseFloat(TTC_value) * 100 / (100 + this.TVA_percentage);
},
- cartTotalTTC: function() {
+ cartTotalTTC: function () {
let $this = this;
// Sum all the raw totals in the cart
if ($this.fluidbook.settings.bookmark_email_body !== '') {
body = $this.fluidbook.settings.bookmark_email_body;
}
- if(body.indexOf('%link%')===-1){
- body += $this.fluidbook.l10n.__(": ") +'%link%';
+ if (body.indexOf('%link%') === -1) {
+ body += $this.fluidbook.l10n.__(": ") + '%link%';
}
subject = subject.replace(/\%title\%/gi, $this.fluidbook.settings.title);
var p_a = this.getPagesOfGroup(a)[0];
var p_b = this.getPagesOfGroup(b)[0];
return p_a - p_b;
- }, sortnumeric: function (a, b) {
+ },
+
+ sortnumeric: function (a, b) {
return a - b;
- }, openPDF: function (element, print) {
+ },
+
+ openPDF: function (element, print) {
print = print || false;
this.fluidbook._openFile(this.getPDF(), element, 'pdf', this.getBookmarksCompacted() + '.pdf', print);
- }, getPDF: function () {
- return 'https://workshop.fluidbook.com/s/e/' + this.fluidbook.settings.cid + '/' + this.getBookmarksCompacted();
- }, getBookmarksCompacted: function () {
+ },
+
+ getPDF: function () {
+ return this.fluidbook.service.getBaseURL(true) + 'e/' + this.fluidbook.settings.cid + '/' + this.getBookmarksCompacted();
+ },
+
+ getBookmarksCompacted: function () {
this.bookmarks.sort(this.sortnumeric);
}, saveBookmarks: function () {
this.fluidbook.cache.set('bookmarks', this.bookmarks);
}, getSavedBookmarks: function () {
- var res=[];
+ var res = [];
if (this.fluidbook.cache.isset('bookmarks')) {
res = this.fluidbook.cache.get('bookmarks');
if (res === undefined || res === null || res === 'undefined' || res === 'null' || res === '') {
var pdfName;
if (this.settings.pages != this.contentlock.getMaxPage()) {
- pdf = 'https://workshop.fluidbook.com/s/e/' + this.settings.cid + '/1-' + this.contentlock.getMaxPage();
+ pdf = this.service.getBaseURL(true) + 'e/' + this.settings.cid + '/1-' + this.contentlock.getMaxPage();
} else if (this.settings.pdfName.substr(0, 4) === 'http') {
pdf = this.settings.pdfName;
} else {
var w = this.wopen(url, '_blank', '');
if (print) {
setTimeout(function () {
- w.print();
+ // w.print();
}, 2000);
}
},
window.location = 'mailto:tech@fluidbook.com?subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(JSON.stringify(o));
}
},
+
+
};
var element = $(this);
var mode = element.data('mode'); // Either 'print' or 'download'
var print = (mode === 'print');
- var dynamicPDF = 'https://workshop.fluidbook.com/s/' + (print ? 'ep' : 'e') + '/' + $this.fluidbook.settings.cid + '/';
+ var dynamicPDF = $this.fluidbook.service.getBaseURL(true) + (print ? 'ep' : 'e') + '/' + $this.fluidbook.settings.cid + '/';
var leftPageNumber = $this.fluidbook.getPhysicalPageNumberOfSide('left');
var rightPageNumber = $this.fluidbook.getPhysicalPageNumberOfSide('right');
var choice = $('input[name="pageChoice"]:checked').val();
// NOTE: Each option has two labels so thumbnails are also clickable and so it works with the custom radio inputs
- if(this.fluidbook.settings.pdfComplexShowCurrent) {
+ if (this.fluidbook.settings.pdfComplexShowCurrent) {
view += this.getSinglePages();
// Double Page
view += '</div>'; // .print-option
}
- if(this.fluidbook.settings.pdfComplexShowCurrent) {
+ if (this.fluidbook.settings.pdfComplexShowCurrent) {
view += '<div class="print-option blank" aria-hidden="true"></div>'; // Extra empty div to ensure flexbox space-between works as expected
}
function FluidbookPrivacy(fluidbook) {
this.fluidbook = fluidbook;
this.storageKey = 'cookieConsent';
- if (location.host == 'workshop.fluidbook.com') {
+ if (location.host === 'workshop.fluidbook.com' || location.host === 'toolbox.fluidbook.com') {
this.storageKey = 'fluidbook.' + fluidbook.settings.id + '.' + this.storageKey;
}
if (!this.fluidbook.settings.cookieConsent) {
});
},
displayCookieConsent: function () {
- if($("#cookieConsent").length>0){
+ if ($("#cookieConsent").length > 0) {
return;
}
var $this = this;
},
close: function () {
// hide
- gsap.to($('#cookieConsent'),{duration:0.5,autoAlpha:0});
+ gsap.to($('#cookieConsent'), {duration: 0.5, autoAlpha: 0});
// set the flag to avoid to display it for the next fisit
localStorage.setItem(this.storageKey, '1');
},
function FluidbookService(fluidbook, id) {
this.fluidbook = fluidbook;
- this.baseURL = 'https://workshop.fluidbook.com/services/';
this.id = id;
}
FluidbookService.prototype = {
+ getBaseURL: function (short) {
+ var res = 'https://toolbox.fluidbook.com/';
+ if (this.fluidbook.settings.id < 30000) {
+ res = 'https://workshop.fluidbook.com/';
+ }
+ if (short === 'true') {
+ res += 's';
+ } else {
+ res += 'services';
+ }
+ res += '/';
+ return res;
+ },
call: function (func, settings, handler, context) {
settings['id'] = this.id;
return $.ajax({
- url: this.baseURL + func,
+ url: this.getBaseURL() + func,
context: context,
format: 'xml',
crossDomain: true,
$.each(settings, function (k, v) {
u.push(k + '=' + encodeURIComponent(v));
});
- var url = this.baseURL + func + '?' + u.join('&');
+ var url = this.getBaseURL() + func + '?' + u.join('&');
this.fluidbook.wopen(url, '_blank', options);
}
}
\ No newline at end of file
this.fluidbook.wopen('https://twitter.com/intent/tweet?source=webclient' + data.url + '&text=' + encodeURIComponent(data.content), 'share_twitter', 'width=650,height=400');
this.fluidbook.stats.track(13, null, 'twitter');
- }, sendWhatsapp: function (url, context) {
+ },
+
+ sendWhatsapp: function (url, context) {
var data = this._getShortShare(url, context);
this.fluidbook.wopen('https://api.whatsapp.com/send?text=' + encodeURIComponent(data.content), 'share_whatsapp', 'width=600,height=600');
this.fluidbook.stats.track(12, null, 'whatsapp');
- }, sendFacebook: function (url, context) {
+ },
+
+ sendFacebook: function (url, context) {
this.fluidbook.wopen('https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(this.getShareURL(url)), 'share_facebook', 'width=650,height=400');
this.fluidbook.stats.track(12, null, 'facebook');
- }, sendLinkedin: function (url, context) {
+ },
+
+ sendLinkedin: function (url, context) {
this.fluidbook.wopen('https://www.linkedin.com/sharing/share-offsite/?url=' + encodeURIComponent(this.getShareURL(url)), 'share_linkedin', 'width=650,height=400');
this.fluidbook.stats.track(12, null, 'linkedin');
- }, sendPinterest: function (url, context) {
- this.fluidbook.wopen('http://pinterest.com/pin/create/button/?url=' + encodeURIComponent(this.getShareURL(url)) + '&media=' + encodeURIComponent('https://workshop.fluidbook.com/services/facebook_thumbnail?id=' + this.fluidbook.settings.id + '&j=' + Date.now()) + '"', 'width=650,height=400');
+ },
+
+ sendPinterest: function (url, context) {
+ this.fluidbook.wopen('http://pinterest.com/pin/create/button/?url=' + encodeURIComponent(this.getShareURL(url)) + '&media=' + encodeURIComponent(this.fluidbook.service.getBaseURL() + 'facebook_thumbnail?id=' + this.fluidbook.settings.id + '&j=' + Date.now()) + '"', 'width=650,height=400');
this.fluidbook.stats.track(12, null, 'pinterest');
}
};
}
var custom_vars = {};
- if (window.location.toString().indexOf('workshop.fluidbook.com') >= 0) {
+ if (window.location.toString().indexOf('workshop.fluidbook.com') >= 0 || window.location.toString().indexOf('toolbox.fluidbook.com')) {
custom_vars.env_work = 'pre-prod';
}
var $this = this;
var view = this.fluidbook.menu.getCaption($this.locale.title);
view += '<div class="content">';
- view += '<form class="avery-form" action="https://workshop.fluidbook.com/services/subscribe" method="post">';
+ view += '<form class="avery-form" action="' + this.fluidbook.service.getBaseURL() + 'subscribe" method="post">';
view += '<div><input type="hidden" value="avery" name="form"><input type="hidden" value="' + this.fluidbook.l10n.currentLang + '" name="locale">';
view += '<h3>' + this.locale.subtitle + '</h3>';
view += '<div class="line">';
view += '</form>';
view += '</div>';
- this.fluidbook.menu.viewWrap(view,'form','data-form="avery" data-maxwidth="650"');
+ this.fluidbook.menu.viewWrap(view, 'form', 'data-form="avery" data-maxwidth="650"');
var options = ['<option value=""> -- ' + this.locale.choose_country + ' -- </option>'];
$.each(this.fluidbook.settings.countries, function (code, name) {
return res;
},
display: function () {
- var i=$("#innerView");
+ var i = $("#innerView");
i.html(this.getHTML()).show();
this.resize();
this.initEvent();
i.hide();
- gsap.to(i,{duration:0.5,autoAlpha: 1});
+ gsap.to(i, {duration: 0.5, autoAlpha: 1});
},
hide: function () {
gsap.to($("#formBulle"), {
});
$('#formBulle form').submit(function () {
$(this).ajaxSubmit({
- url: 'https://workshop.fluidbook.com/services/bulle',
+ url: $this.fluidbook.service.getBaseURL() + 'bulle',
success: function (data) {
$this.hide();
}