From: Vincent Vanwaelscappel Date: Thu, 14 Jan 2021 08:54:01 +0000 (+0100) Subject: wait #4193 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ea8b5518a84ee38ecae53de358d2b77eb8f46e46;p=fluidbook-html5.git wait #4193 @0.25 --- diff --git a/js/libs/fluidbook/fluidbook.tabs.js b/js/libs/fluidbook/fluidbook.tabs.js index eba401b9..0fd2d90b 100644 --- a/js/libs/fluidbook/fluidbook.tabs.js +++ b/js/libs/fluidbook/fluidbook.tabs.js @@ -79,6 +79,7 @@ FluidbookTabs.prototype = { }, setOptions: function () { + this.hideOnPages = this.fluidbook.settings.tabsHideOnPages; this.hideOnLastPage = this.fluidbook.settings.tabsHideOnLastPage; this.hideOnFirstPage = this.fluidbook.settings.tabsHideOnCover; this.hideOnPortrait = this.fluidbook.settings.tabsHideOnPortrait; @@ -314,38 +315,12 @@ FluidbookTabs.prototype = { } $(this.fluidbook).on('fluidbook.page.change.start', function (e, page) { - if ($this.hideOnFirstPage) { - if (page <= 1) { - $this.changeVisibility('firstpage', false); - } - } - if ($this.hideOnLastPage) { - var last = $this.fluidbook.settings.pages; - if (last % 2 === 1) { - last--; - } - if (page >= last) { - $this.changeVisibility('lastpage', false); - } - } + $this.checkPageVisibility(); $this.changePage(page); }); $(this.fluidbook).on('fluidbook.page.change.end', function (e, page) { - if ($this.hideOnFirstPage) { - if (page > 1) { - $this.changeVisibility('firstpage', true); - } - } - if ($this.hideOnLastPage) { - var last = $this.fluidbook.settings.pages; - if (last % 2 === 1) { - last--; - } - if (page < last) { - $this.changeVisibility('lastpage', true); - } - } + $this.checkPageVisibility(); }); $(document).on('mouseover', '.tablink[data-labelid]', function () { @@ -358,6 +333,19 @@ FluidbookTabs.prototype = { }); }, + checkPageVisibility(){ + var $this=this; + var pages = this.fluidbook.getDisplayedPages(); + var hide = false; + $.each(pages, function (k, p) { + if ($this.hideOnPages.indexOf(p) >= 0) { + hide = true; + return false; + } + }); + this.changeVisibility('firstpage', !hide); + }, + changeVisibility: function (type, visible) { this.visibility[type] = visible; var tabsvisible = true;