From 7310336489f30a569de8477ec2f4ec04d2cac29a Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 4 Sep 2019 18:41:30 +0200 Subject: [PATCH] wip #3000 @1 --- js/libs/fluidbook/fluidbook.help.js | 6 +++--- js/libs/fluidbook/fluidbook.interface.js | 21 ++++++++++++++++----- js/libs/fluidbook/fluidbook.resize.js | 13 ++++++------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.help.js b/js/libs/fluidbook/fluidbook.help.js index 05f5f579..105a5ccd 100644 --- a/js/libs/fluidbook/fluidbook.help.js +++ b/js/libs/fluidbook/fluidbook.help.js @@ -100,7 +100,7 @@ FluidbookHelp.prototype = { help += ''; // 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 += '
'; - if (this.fluidbook.interface.arrowsEnabled) { + if (this.fluidbook.interface.arrowsEnabled()) { help += ''; help += '
' + this.fluidbook.l10n.__('last page') + '
'; help += ''; @@ -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 diff --git a/js/libs/fluidbook/fluidbook.interface.js b/js/libs/fluidbook/fluidbook.interface.js index d0435ac8..5a1a319d 100644 --- a/js/libs/fluidbook/fluidbook.interface.js +++ b/js/libs/fluidbook/fluidbook.interface.js @@ -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) { diff --git a/js/libs/fluidbook/fluidbook.resize.js b/js/libs/fluidbook/fluidbook.resize.js index 3f3d883a..25b0787b 100644 --- a/js/libs/fluidbook/fluidbook.resize.js +++ b/js/libs/fluidbook/fluidbook.resize.js @@ -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); -- 2.39.5