From 47b3a6ca2edca9a021617e987edd9d29b59224dd Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 23 Feb 2021 15:09:39 +0100 Subject: [PATCH] wip #4286 @0.75 --- .../cart/fluidbook.cart.grandvision.js | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/js/libs/fluidbook/cart/fluidbook.cart.grandvision.js b/js/libs/fluidbook/cart/fluidbook.cart.grandvision.js index 1a3905dc..fcbe2eec 100644 --- a/js/libs/fluidbook/cart/fluidbook.cart.grandvision.js +++ b/js/libs/fluidbook/cart/fluidbook.cart.grandvision.js @@ -12,7 +12,7 @@ FluidbookCartGrandVision.prototype = { var $this = this; this.items = this.fluidbook.cache.get('cart', []); this.boxes = this.fluidbook.cache.get('boxes', [{name: 'Box 1', refs: []}]); - if (this.boxes===undefined || this.boxes===null || this.boxes.length === 0) { + if (typeof this.boxes === "string" || this.boxes === undefined || this.boxes === null || this.boxes.length === 0) { this.boxes = [{name: 'Box 1', refs: []}]; } this.boxIndex = Math.max(0, Math.min(this.boxes.length - 1, parseInt(this.fluidbook.cache.get('boxindex', '0')))); @@ -45,7 +45,13 @@ FluidbookCartGrandVision.prototype = { }); $(document).on('change', 'select[name="box"]', function () { - $this.boxIndex = parseInt($(this).find('option[value="' + $(this).val() + '"]').data('i')); + var val = $(this).val(); + var opt = $(this).find('option[value="' + val + '"]'); + var i = $(opt).data('index'); + console.log(val, opt, i); + $this.boxIndex = parseInt(i); + $this.fluidbook.cache.set('boxindex', $this.boxIndex); + $this.setBox(); return true; }); @@ -68,10 +74,18 @@ FluidbookCartGrandVision.prototype = { $this.updateBoxesSelector(); return false; }); + + $(document).on('click', '[data-action="export"]', function () { + $this.exportBoxes(); + }); + }, + + exportBoxes:function(){ + }, - addNewBox:function(){ - this.boxes.push({name: 'Box ' + (this.boxes.length + 2), refs: []}); + addNewBox: function () { + this.boxes.push({name: 'Box ' + (this.boxes.length + 1), refs: []}); this.boxIndex = this.boxes.length - 1; this.fluidbook.cache.set('boxes', this.boxes); @@ -94,7 +108,6 @@ FluidbookCartGrandVision.prototype = { this.updateBoxesSelector(); this.setBox(); - }, removeFromCart: function (ref) { @@ -284,7 +297,7 @@ FluidbookCartGrandVision.prototype = { var $this = this; $.each(this.boxes, function (k, b) { var selected = (k === $this.boxIndex) ? ' selected ' : ''; - res += ''; + res += ''; }); $("select[name='box']").html(res); }, -- 2.39.5