]> _ Git - fluidbook-html5.git/commitdiff
wip #3000 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 4 Sep 2019 16:41:30 +0000 (18:41 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 4 Sep 2019 16:41:30 +0000 (18:41 +0200)
js/libs/fluidbook/fluidbook.help.js
js/libs/fluidbook/fluidbook.interface.js
js/libs/fluidbook/fluidbook.resize.js

index 05f5f57957a84eeab9e88e3045cdca4ef0063a58..105a5ccd7ade7d745a3cd8dfcc2f9a0fe2021b84 100644 (file)
@@ -100,7 +100,7 @@ FluidbookHelp.prototype = {
         help += '</div>';
 
         // Interface
-        if (this.fluidbook.interface.arrowsEnabled) {
+        if (this.fluidbook.interface.arrowsEnabled()) {
             var next = this.fluidbook.l10n.__('next double page');
             var previous = this.fluidbook.l10n.__('previous double page');
             if (this.fluidbook.pad.enabled) {
@@ -114,7 +114,7 @@ FluidbookHelp.prototype = {
         }
 
         help += '<div class="interface">';
-        if (this.fluidbook.interface.arrowsEnabled) {
+        if (this.fluidbook.interface.arrowsEnabled()) {
             help += '<div class="next">' + next + '</div>';
             help += '<div class="last">' + this.fluidbook.l10n.__('last page') + '</div>';
             help += '<div class="previous">' + previous + '</div>';
@@ -227,7 +227,7 @@ FluidbookHelp.prototype = {
         var firstTop;
 
 
-        if (this.fluidbook.interface.arrowsEnabled) {
+        if (this.fluidbook.interface.arrowsEnabled()) {
             var arrow = $('#interface #next').get(0).getBoundingClientRect(); // Used for calculating offsets for both #next & #previous
             // The arrow element contains both arrows in a single image
             // so we calculate the top position of the labels by percentage
index d0435ac82b6e398a66bfa288e16d4ae5c25d7384..5a1a319d9d7885b9989bee243eb8f62c6c50cce4 100644 (file)
@@ -6,8 +6,6 @@ function FluidbookInterface(fluidbook) {
     this.visibleTime = 5000;
     this.interfaceVisible = false;
 
-    this.arrowsEnabled = this.fluidbook.datas.arrowsEnabled;
-
     this.maskToggleEventsTimeout = Date.now();
 
     this.init();
@@ -17,7 +15,7 @@ FluidbookInterface.prototype = {
     init: function () {
         var $this = this;
 
-        if (this.arrowsEnabled) {
+        if (this.arrowsEnabled()) {
             var res = '';
             if ($('html').hasClass('ltr')) {
                 res += this.fluidbook.nav.getLink('interface-previous', '#', 'previous', '', '', '', true);
@@ -39,6 +37,19 @@ FluidbookInterface.prototype = {
         });
     },
 
+    arrowsEnabled: function () {
+        switch (this.fluidbook.datas.arrowsEnabled) {
+            case '0':
+                return false;
+            case '1':
+                return true;
+            case '2':
+                return !this.fluidbook.input.hasTouch;
+            default:
+                return true;
+        }
+    },
+
     checkHidden: function () {
         if (!this.autoHideArrows()) {
             this.displayInterface();
@@ -53,7 +64,7 @@ FluidbookInterface.prototype = {
     },
 
     autoHideArrows: function () {
-        var res = this.arrowsEnabled && (this.fluidbook.resize===undefined || this.fluidbook.resize.reduceHorizontalMargins()) && this.areArrowsOverlapingPublication() && ($("#helpView:visible").length === 0);
+        var res = this.arrowsEnabled() && (this.fluidbook.resize === undefined || this.fluidbook.resize.reduceHorizontalMargins()) && this.areArrowsOverlapingPublication() && ($("#helpView:visible").length === 0);
         return res;
     },
 
@@ -144,7 +155,7 @@ FluidbookInterface.prototype = {
 
     getInterfaceSelector: function () {
         var selector = '';
-        if (this.arrowsEnabled) {
+        if (this.arrowsEnabled()) {
             selector = '#next,#previous'
         }
         if (this.fluidbook.pad.enabled) {
index 3f3d883ad24f06f659616b0d14306ad31908d76d..25b0787bae6417e3b0532abc473bca7937ee0089 100644 (file)
@@ -55,7 +55,7 @@ FluidbookResize.prototype = {
             origin: [right, '100%']
         });
 
-        if(this.fluidbook.interface.arrowsEnabled) {
+        if(this.fluidbook.interface.arrowsEnabled()) {
             $("#next").transform({
                 origin: [right, '50%']
             });
@@ -226,7 +226,7 @@ FluidbookResize.prototype = {
             }
         }
 
-        if(this.fluidbook.interface.arrowsEnabled) {
+        if(this.fluidbook.interface.arrowsEnabled()) {
             $("#next").transform({
                 scale: cssInterfaceScale,
             });
@@ -318,7 +318,7 @@ FluidbookResize.prototype = {
 
         };
 
-        if(this.fluidbook.interface.arrowsEnabled) {
+        if(this.fluidbook.interface.arrowsEnabled()) {
             try {
                 data.arrowLeftRect = $("#previous").get(0).getBoundingClientRect();
                 data.arrowRightRect = $("#next").get(0).getBoundingClientRect();
@@ -331,15 +331,14 @@ FluidbookResize.prototype = {
     },
     resizeNav: function (interfaceScale) {
         var $this = this;
-        if(this.fluidbook.interface.arrowsEnabled) {
+        if(this.fluidbook.interface.arrowsEnabled()) {
             var topNext = (this.hh - (100 * interfaceScale)) / 2;
             $("#next,#previous").css({
                 top: topNext
-            });
-            $("#next,#previous").show();
+            }).show();
         }
 
-        if ($("#afterSearch:visible").length == 1) {
+        if ($("#afterSearch:visible").length === 1) {
             setTimeout(function () {
                 $this.resizeAfterSearch();
             }, 10);