]> _ Git - fluidbook-html5.git/commitdiff
wip #5893 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 27 Apr 2023 18:24:17 +0000 (20:24 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 27 Apr 2023 18:24:17 +0000 (20:24 +0200)
js/libs/fluidbook/cart/fluidbook.cart.bastide.js
js/libs/fluidbook/cart/fluidbook.cart.cfoc.js
js/libs/fluidbook/fluidbook.bookmarks.js
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.print.js
js/libs/fluidbook/fluidbook.privacy.js
js/libs/fluidbook/fluidbook.service.js
js/libs/fluidbook/fluidbook.share.js
js/libs/fluidbook/fluidbook.stats.js
js/libs/fluidbook/forms/fluidbook.form.avery.js
js/libs/fluidbook/forms/fluidbook.form.bulle.js

index e5079bd4aa6e6601043d6c4710f0f857fed3e425..28b4bcc8f6b8b82259b43330f321ccb7f16902a9 100644 (file)
@@ -2,7 +2,7 @@ function FluidbookCartBastide(cart) {
     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();
 }
 
index cdda3da4c6a00a94ab500da7dcdacf0fffe54ab4..403da75d5742368ad022286c8f74e77751c72d81 100644 (file)
@@ -4,7 +4,7 @@ function FluidbookCartCFOC(cart) {
     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();
 }
 
@@ -56,7 +56,7 @@ FluidbookCartCFOC.prototype = {
             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
 
@@ -76,7 +76,7 @@ FluidbookCartCFOC.prototype = {
         });
 
         // 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
@@ -92,7 +92,7 @@ FluidbookCartCFOC.prototype = {
         });
 
         // 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,
@@ -116,7 +116,7 @@ FluidbookCartCFOC.prototype = {
                 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,
@@ -209,7 +209,7 @@ FluidbookCartCFOC.prototype = {
         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);
@@ -263,7 +263,7 @@ FluidbookCartCFOC.prototype = {
 
             $.each($this.getColumnsForXLS(), function (key, title) {
 
-                switch(key) {
+                switch (key) {
                     case 'QTE':
                         item[key] = cart_item['quantity'];
                         break;
@@ -356,7 +356,7 @@ FluidbookCartCFOC.prototype = {
         // 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;
 
@@ -451,22 +451,22 @@ FluidbookCartCFOC.prototype = {
 
     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>`;
@@ -484,9 +484,9 @@ FluidbookCartCFOC.prototype = {
                 let value = data[key] || '&mdash;'; // 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':
@@ -496,9 +496,9 @@ FluidbookCartCFOC.prototype = {
 
                             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>`;
                             });
@@ -511,7 +511,7 @@ FluidbookCartCFOC.prototype = {
                     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 }));
@@ -600,7 +600,7 @@ FluidbookCartCFOC.prototype = {
         return content;
     },
 
-    getCartSummary: function() {
+    getCartSummary: function () {
         // Calculate totals
         let total_TTC = this.cartTotalTTC();
         let total_HT = this.calculateHT(total_TTC);
@@ -613,14 +613,14 @@ FluidbookCartCFOC.prototype = {
         }
     },
 
-    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}`;
@@ -640,7 +640,7 @@ FluidbookCartCFOC.prototype = {
         });
 
         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>
@@ -670,11 +670,11 @@ FluidbookCartCFOC.prototype = {
     },
 
     // 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
index ec4f9581a6c78580955436090036d92533279c0f..a91a0c92ea6eebffe0e7231d71ccf27aa2e2a890 100644 (file)
@@ -43,8 +43,8 @@ FluidbookBookmarks.prototype = {
             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);
@@ -123,14 +123,22 @@ FluidbookBookmarks.prototype = {
         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);
 
 
@@ -367,7 +375,7 @@ FluidbookBookmarks.prototype = {
     }, 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 === '') {
index 1521b308480c0be718bdfc0be6d9085bf7bc759e..8905f4100d108aebe65fdcf6831dde5835c93275 100644 (file)
@@ -793,7 +793,7 @@ Fluidbook.prototype = {
         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 {
@@ -832,7 +832,7 @@ Fluidbook.prototype = {
         var w = this.wopen(url, '_blank', '');
         if (print) {
             setTimeout(function () {
-                w.print();
+               // w.print();
             }, 2000);
         }
     },
@@ -1191,4 +1191,6 @@ Fluidbook.prototype = {
             window.location = 'mailto:tech@fluidbook.com?subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(JSON.stringify(o));
         }
     },
+
+
 };
index c96ef257b108f2ce8f47950cd8b1950a1573d2c7..b9a372084194328caaf9ba21dcb2f706803467ee 100644 (file)
@@ -17,7 +17,7 @@ FluidbookPrint.prototype = {
             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();
@@ -97,7 +97,7 @@ FluidbookPrint.prototype = {
 
         // 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
@@ -159,7 +159,7 @@ FluidbookPrint.prototype = {
             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
         }
 
index 4a03c31b291896d2d944f7e4649d1461b2b08508..38e9dd42c70bdc8d77c8de05082820fa1357cf7a 100644 (file)
@@ -1,7 +1,7 @@
 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) {
@@ -22,7 +22,7 @@ FluidbookPrivacy.prototype = {
         });
     },
     displayCookieConsent: function () {
-        if($("#cookieConsent").length>0){
+        if ($("#cookieConsent").length > 0) {
             return;
         }
         var $this = this;
@@ -39,7 +39,7 @@ FluidbookPrivacy.prototype = {
     },
     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');
     },
index 60a0245f96b489779c74d7fc3ec5977d95dbe848..224eb2aae10280b4dcf57060dede25a6dd85f798 100644 (file)
@@ -1,14 +1,26 @@
 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,
@@ -24,7 +36,7 @@ FluidbookService.prototype = {
         $.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
index 95f523b6eb1be95cb0c241f03f7e0279fca35bc3..fd985fb5bb9b2a17a8c4be9692bc30cdfa110c80 100644 (file)
@@ -322,18 +322,26 @@ FluidbookShare.prototype = {
 
         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');
     }
 };
index 6d8f01a10d96a77e9cb1668335caf01f314f8f11..088e4bff1a139836fbac1dfb632beb17a2d1e844 100644 (file)
@@ -109,7 +109,7 @@ FluidbookStats.prototype = {
             }
 
             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';
             }
 
index 126685bcdb0d9c8e8cb1d77c01368bda56170c45..dd48fc7b6c54553ea0b00123515bdd22f2e9eaa2 100644 (file)
@@ -85,7 +85,7 @@ FluidbookAveryForm.prototype = {
         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">';
@@ -129,7 +129,7 @@ FluidbookAveryForm.prototype = {
         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) {
index f9169bc73a9af755cfac4475d1d64c3eb5b6ced3..b6bf373267c0ee9b747bc1831dc96e7a9546251a 100644 (file)
@@ -36,12 +36,12 @@ FluidbookBulleForm.prototype = {
         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"), {
@@ -60,7 +60,7 @@ FluidbookBulleForm.prototype = {
         });
         $('#formBulle form').submit(function () {
             $(this).ajaxSubmit({
-                url: 'https://workshop.fluidbook.com/services/bulle',
+                url: $this.fluidbook.service.getBaseURL() + 'bulle',
                 success: function (data) {
                     $this.hide();
                 }