From: Vincent Vanwaelscappel Date: Fri, 17 Sep 2021 16:56:55 +0000 (+0200) Subject: wip #4664 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=55377f850f8b68aeb2ec12900863ade1a781c00d;p=fluidbook-html5.git wip #4664 @2 --- diff --git a/js/libs/fluidbook/cart/fluidbook.cart.grandpavois.js b/js/libs/fluidbook/cart/fluidbook.cart.grandpavois.js new file mode 100644 index 00000000..e1b38482 --- /dev/null +++ b/js/libs/fluidbook/cart/fluidbook.cart.grandpavois.js @@ -0,0 +1,214 @@ +function FluidbookCartGrandPavois(cart) { + this.cart = cart; + this.fluidbook = this.cart.fluidbook; + this.data = this.fluidbook.settings.basketReferences; + this.init(); +} + +FluidbookCartGrandPavois.prototype = { + init: function () { + var $this = this; + this.items = this.fluidbook.cache.get('cart', []); + $(document).on(this.fluidbook.input.clickEvent, '.exportCartPDF', function () { + $this.exportPDF(); + return false; + }); + $(document).on(this.fluidbook.input.clickEvent, '.sendAsEmail', function () { + try { + $this.sendCartAsEmail(); + } catch (err) { + console.log(err); + } + return false; + }); + }, + + addToCart: function (ref, quantity) { + if (this.items.indexOf(ref) === -1) { + this.items.push(ref); + this.save(); + } + return "L'exposant a été ajouté à votre visite"; + }, + + removeFromCart: function (key) { + this.items.splice(key, 1); + this.save(); + }, + + save: function () { + this.fluidbook.cache.set('cart', this.getItems()); + this.fluidbook.cart.updateLinks(); + }, + + getItems: function () { + var res = []; + var $this = this; + $(this.items).each(function (i, ref) { + if ($this.data[ref] !== undefined && $this.data[ref] !== null) { + res.push(ref); + } + }); + return res; + }, + + + getItemsReferences: function () { + return this.getItems(); + }, + getItemsNumbers: function () { + return this.getItems().length; + }, + getAllQuantities: function () { + return this.getItemsNumbers(); + }, + + updateCart: function () { + if ($('#mifcart').length > 0) { + $('#mifcart .content').html(this.getCartContent()); + } + }, + + updateIcon: function () { + $(this.fluidbook).trigger('fluidbook.cart.updateIcon', {number: this.getItemsNumbers()}); + }, + + openMenu: function (p1, p2, callback) { + this.fluidbook.menu.quickCloseView(); + return this.openCart(p2, callback); + }, + + openCart: function (p2, callback) { + this._endMenu('Ma visite', this.getCartContent(), function () { + callback(); + }); + }, + + getCartContent: function () { + if (this.getItemsNumbers() == 0) { + return '
Votre liste d\'exposants est vide
'; + } + + var $this = this; + var content = ''; + content += ''; + content += ''; + content += ''; + content += ''; + content += ''; + content += ''; + content += ''; + content += ''; + content += ''; + content += ''; + content += ''; + content += ''; + $.each(this.getItems(), function (i, ref) { + var item = $this.data[ref]; + if (item === undefined) { + return; + } + content += ''; + content += ''; + content += ''; + content += ''; + content += ''; + var image = ''; + if (item.Image) { + image = ''; + } else { + image = '-'; + } + content += ''; + content += ''; + content += ''; + content += ''; + }); + content += ''; + content += '
CatégorieMarqueNom du produitPrixImage
' + item.Categorie + '' + item.Marque + '' + item.Produit + '' + item.Prix + '' + image + '' + getSpriteIcon('icon-eye') + '' + getSpriteIcon('interface-close') + '
'; + content += ''; + + return content; + }, + + sendCartAsEmail: function () { + var $this = this; + + var subject = 'Ma liste de Noël' + var body = 'Ma liste de Noël : ' + "\n\n"; + + $.each(this.getItems(), function (i, ref) { + var item = $this.fluidbook.settings.basketReferences[ref]; + if (item === undefined) { + return; + } + body += item.Produit + ' (' + item.Marque + ') - ' + item.Prix + " :\n"; + body += item.Lien + "\n\n"; + }); + window.location.href = 'mailto:?subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(body); + }, + + exportPDF: function () { + + var element = $('#mifcarttable').get(0); + var options = { + margin: 15, + filename: this.getExportFileName() + '.pdf', + image: {type: 'jpeg', quality: 0.98}, + html2canvas: {dpi: 150, scale: 2, letterRendering: true}, + jsPDF: {unit: 'mm', format: 'A4', orientation: 'portrait'} + }; + $(element).addClass('print') + html2pdf().set(options).from(element).save().then(function () { + $(element).removeClass('print'); + }); + + setTimeout(function () { + $(element).removeClass('print'); + }, 2000); + }, + + getExportFileName: function () { + var date = new Date(); + return this.fluidbook.settings.title + ' - Cart - ' + date.getFullYear() + '-' + date.getMonth() + '-' + date.getDay(); + }, + + _endMenu: function (title, content, callback) { + var view = '
'; + view += this.fluidbook.menu.getCaption(title); + view += '
'; + view += "" + content; + view += '
'; + view += '
'; + this.fluidbook.menu.viewWrap(view, 'cart'); + callback(); + }, + + getMenuWidth: function () { + return 1200; + }, + + parseFloat: function (s) { + if (typeof s === 'number') { + return s; + } + if (s === undefined || s === null || s === '') { + return 0; + } + s = s.replace(/\s/g, ''); + return parseFloat(s); + }, + + parseInt: function (s) { + if (typeof s === 'number') { + return Math.round(s); + } + if (s === undefined || s === null || s === '') { + return 0; + } + s = s.replace(/\s/g, ''); + return parseInt(s); + }, +}; \ No newline at end of file diff --git a/js/libs/fluidbook/fluidbook.cart.js b/js/libs/fluidbook/fluidbook.cart.js index 45852a29..571bf13c 100644 --- a/js/libs/fluidbook/fluidbook.cart.js +++ b/js/libs/fluidbook/fluidbook.cart.js @@ -98,6 +98,8 @@ FluidbookCart.prototype = { return new FluidbookCartPuma(this); case 'MIF': return new FluidbookCartMIF(this); + case 'GrandPavois': + return new FluidbookCartGrandPavois(this); case 'Flexipan': return new FluidbookCartFlexipan(this); case 'GrandVision': diff --git a/style/cart/grandpavois.less b/style/cart/grandpavois.less new file mode 100644 index 00000000..dc91e769 --- /dev/null +++ b/style/cart/grandpavois.less @@ -0,0 +1,140 @@ +#mifcart { + .caption { + margin-top: 10px; + text-transform: uppercase; + } +} + +[data-type="7"] { + svg { + pointer-events: none; + + + } + + .on { + visibility: hidden; + } + + .off { + visibility: visible; + } + + &.active { + .off { + visibility: hidden; + } + + .on { + visibility: visible; + } + } +} + + +#mifcarttable { + [data-cart-delete], [data-cart-view] { + color: #fff; + background-color: @menu-button-background; + padding: 5px 6px 7px 6px; + width: 23px; + height: 23px; + display: block; + position: relative; + left: 20px; + } + + [data-cart-view] { + padding: 0; + } + + tr.print-header { + display: none; + font-size: 0; + + td { + padding: 0; + display: table-cell !important; + + img { + max-width: 100%; + } + } + } + + padding: 0; + border-collapse: collapse; + margin: 20px 30px 40px; + width: ~"calc(100% - 60px)"; + max-width: none; + + &.print { + tr.print-header { + display: table-row !important; + } + + span { + text-decoration: none; + } + + margin: 0; + font-size: 8px; + width: 100%; + + td, th { + vertical-align: top; + padding: 5px; + + &:last-child { + display: none; + } + } + + [data-cart-delete], [data-cart-view] { + display: none; + } + } + + td, th { + padding: 20px 0 20px 30px; + font-size: 11px; + text-align: center; + + span { + display: block; + max-width: 120px; + white-space: normal; + margin: 0 auto; + } + + img { + max-width: 80px; + } + + &:last-child { + padding-right: 30px; + padding-left: 0px; + } + } + + thead { + th { + text-transform: uppercase; + color: #fff; + background-color: @menu-button-background; + font-weight: normal; + } + } + + tbody { + td { + border-top: 1px solid #000; + } + + tr { + background-color: #fff; + color: #000 + } + + } +} \ No newline at end of file