]> _ Git - fluidbook-html5.git/commitdiff
wait #4193 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 14 Jan 2021 08:54:01 +0000 (09:54 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 14 Jan 2021 08:54:01 +0000 (09:54 +0100)
js/libs/fluidbook/fluidbook.tabs.js

index eba401b9a59ca8357cb8335b4d3750f799915b02..0fd2d90b6d6563cc72e056fe489bb998797284a4 100644 (file)
@@ -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;