From: Vincent Vanwaelscappel Date: Thu, 8 Jan 2026 17:21:22 +0000 (+0100) Subject: wip #7898 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=f6adcca5711666a52eedf4a404402b505c365ff9;p=fluidbook-html5.git wip #7898 @0.5 --- diff --git a/js/libs/fluidbook/cart/fluidbook.cart.kimplay.js b/js/libs/fluidbook/cart/fluidbook.cart.kimplay.js new file mode 100644 index 00000000..2469757b --- /dev/null +++ b/js/libs/fluidbook/cart/fluidbook.cart.kimplay.js @@ -0,0 +1,182 @@ +function FluidbookCartKimplay(cart) { + var $this = this; + this.cart = cart; + this.fluidbook = this.cart.fluidbook; + this.data = this.fluidbook.settings.basketReferences; + this.init(); +} + +FluidbookCartFlexipan.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; + }); + }, + + addToCart: function (ref, quantity) { + if (this.items.indexOf(ref) === -1) { + this.items.push(ref); + this.save(); + } + + return this.fluidbook.l10n.__("the item has been added to your selection"); + }, + + removeFromCart: function (key) { + this.items.splice(key, 1); + this.save(); + }, + + save: function () { + this.fluidbook.cache.set('cart', this.getItems()); + this.updateIcon(); + 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 ($('#flexipancart').length > 0) { + $('#flexipancart .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(this.fluidbook.l10n.__('my selection'), this.getCartContent(), function () { + callback(); + }); + }, + + getCartContent: function () { + if (this.getItemsNumbers() == 0) { + return '
' + this.fluidbook.l10n.__('your selection is empty') + '
'; + } + + var $this = this; + var 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 += ''; + content += ''; + content += ''; + }); + content += ''; + content += '
' + this.fluidbook.l10n.__('product name') + '' + this.fluidbook.l10n.__('product code') + '' + this.fluidbook.l10n.__('product range') + '' + this.fluidbook.l10n.__('category') + '
' + item.Denomination + '' + ref + '' + item.Gamme + '' + item.Categorie + '' + getSpriteIcon('interface-close') + '
'; + content += ''; + + return content; + }, + + exportPDF: function () { + + var element = $('#flexipancarttable').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 900; + }, + + 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 2d89c32d..404f30ee 100644 --- a/js/libs/fluidbook/fluidbook.cart.js +++ b/js/libs/fluidbook/fluidbook.cart.js @@ -130,35 +130,35 @@ FluidbookCart.prototype = { } var size = 2; - var r=0.5; - if ($(this).outerWidth() < 200*r) { + var r = 0.5; + if ($(this).outerWidth() < 200 * r) { size = Math.min(size, 0); c.push('small-w'); - } else if ($(this).outerWidth() < 280*r) { + } else if ($(this).outerWidth() < 280 * r) { size = Math.min(size, 1); c.push('medium-w'); } - if ($(this).outerHeight() < 100*r) { + if ($(this).outerHeight() < 100 * r) { size = Math.min(size, 0); c.push('small-h'); - } else if ($(this).outerHeight() < 130*r) { + } else if ($(this).outerHeight() < 130 * r) { size = Math.min(size, 1); c.push('medium-h'); } - if ($(this).outerHeight() < 300*r) { + if ($(this).outerHeight() < 300 * r) { c.push('condensed-h'); } - var bw = 250*r; - var bh = 100*r; + var bw = 250 * r; + var bh = 100 * r; if (size === 0) { - bw = 130*r; - bh = 60*r; + bw = 130 * r; + bh = 60 * r; $(this).addClass('small'); } else if (size === 1) { - bw = 170*r; - bh = 80*r; + bw = 170 * r; + bh = 80 * r; $(this).addClass('medium'); } $(this).addClass(c); @@ -236,6 +236,8 @@ FluidbookCart.prototype = { return new FluidbookCartBastideResah(this); case 'BastideResahGuest': return new FluidbookCartBastideResahGuest(this); + case 'Kimplay': + return new FluidbookCartKimplay(this); default: return null; } diff --git a/style/cart/kimplay.less b/style/cart/kimplay.less new file mode 100644 index 00000000..96c2f88c --- /dev/null +++ b/style/cart/kimplay.less @@ -0,0 +1,157 @@ +#flexipancart { + background-color: #fff; + + .caption { + color: #000; + margin-top: 0px; + position: relative; + top: 0px; + text-transform: uppercase; + + #mview-dialog-title{ + margin-top: 10px; + } + + a.button.back { + color: #fff; + } + } + + .cart-empty{ + color:#000; + } +} + +[data-type="7"] { + svg { + pointer-events: none; + + + } + + .on { + visibility: hidden; + } + + .off { + visibility: visible; + } + + &.active { + .off { + visibility: hidden; + } + + .on { + visibility: visible; + } + } +} + + +#flexipancarttable { + [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