From 02b1248068149c5fd1d8b27357b2589ecd99b0e4 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 13 Oct 2022 14:50:47 +0200 Subject: [PATCH] wait #5519 @1.5 --- js/libs/fluidbook/fluidbook.tabs.js | 53 +++++++++++++++++++---------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.tabs.js b/js/libs/fluidbook/fluidbook.tabs.js index 850950cc..6b5e2c0c 100644 --- a/js/libs/fluidbook/fluidbook.tabs.js +++ b/js/libs/fluidbook/fluidbook.tabs.js @@ -118,13 +118,6 @@ FluidbookTabs.prototype = { }, addLinks: function (pages) { - pages = pages.map(function (x) { - if (x === '-') { - return '-'; - } - return parseInt(x); - }); - this.links = []; var $this = this; var sections = []; @@ -134,12 +127,21 @@ FluidbookTabs.prototype = { var sectionPages = []; var foundOnePage = false; $.each(pages, function (k, p) { + let weight = 1; + let e = p.split('*'); + if (e.length === 2) { + weight = parseInt(e[1]); + p = e[0]; + } + let page = {page: p, weight: weight}; + if (p === '-' && foundOnePage) { - sectionPages.push(p); + sectionPages.push(page); } else { - if ($this.getSectionByPageNumber(p) - 1 === id) { + page.page = parseInt(page.page); + if ($this.getSectionByPageNumber(page.page) - 1 === id) { foundOnePage = true; - sectionPages.push(p); + sectionPages.push(page); } else if (foundOnePage) { // Assume that if this page is not in the current section, next ones won't be either return false; @@ -149,28 +151,42 @@ FluidbookTabs.prototype = { sections.push(sectionPages); }); } else { - sections.push(pages); + var section = []; + $.each(pages, function (k, p) { + let weight = 1; + let e = p.toString().split('*'); + if (e.length === 2) { + weight = parseInt(e[1]); + p = e[0]; + } + section.push({page: p, weight: weight}); + }); + sections.push(section); } var index = 1; $.each(sections, function (k, sectionPages) { - var nbPages = sectionPages.length; + var totalWeight = 0; + $.each(sectionPages, function (k, value) { + totalWeight += value.weight; + }); + var i = 0; $.each(sectionPages, function (k, value) { - if (value !== '-') { - var activeLandscape = value; + if (value.page !== '-') { + var activeLandscape = parseInt(value.page); if (!$this.fluidbook.alwaysDisplayOnePage && value % 2 === 1) { activeLandscape--; } $this.links.push({ - css: {height: (100 / nbPages) + '%', top: (100 / nbPages * i) + '%'}, - page: parseInt(value), + css: {height: (value.weight * (100 / totalWeight)) + '%', top: (100 / totalWeight * i) + '%'}, + page: parseInt(value.page), pageActiveLandscape: activeLandscape, index: index, id: 'o' + index }); } - i++; + i += value.weight; index++; }); }); @@ -216,6 +232,7 @@ FluidbookTabs.prototype = { } }); } + console.log(page,id); if (id === 'none') { this.svg.find('[id^="o"].active').removeClass('active'); @@ -254,7 +271,7 @@ FluidbookTabs.prototype = { } var section = 0; $.each(this.sections, function (k, v) { - if (page >= v) { + if (parseInt(page) >= v) { section = k + 1; } }); -- 2.39.5