From f44804411c558d8cb1a745c14676e2bffbb0e517 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 2 Jul 2020 18:09:23 +0200 Subject: [PATCH] fix #3759 @2 --- images/interface.svg | 22 ++++-- js/libs/fluidbook/fluidbook.help.js | 19 +++--- js/libs/fluidbook/fluidbook.interface.js | 87 ++++++++++++++++++++++-- js/libs/fluidbook/fluidbook.js | 10 +-- js/libs/fluidbook/fluidbook.nav.js | 9 ++- js/libs/fluidbook/fluidbook.resize.js | 15 ++-- style/interface.less | 75 ++++++++++++++++++-- 7 files changed, 192 insertions(+), 45 deletions(-) diff --git a/images/interface.svg b/images/interface.svg index d14f49a0..c53dcee2 100644 --- a/images/interface.svg +++ b/images/interface.svg @@ -15,11 +15,23 @@ - - - - - + + + + + + + + + + + + diff --git a/js/libs/fluidbook/fluidbook.help.js b/js/libs/fluidbook/fluidbook.help.js index 478335ee..f2f334d4 100644 --- a/js/libs/fluidbook/fluidbook.help.js +++ b/js/libs/fluidbook/fluidbook.help.js @@ -135,18 +135,19 @@ FluidbookHelp.prototype = { previous = this.fluidbook.l10n.__('previous chapter'); } if (this.fluidbook.mobilefirst.enabled) { - var next = this.fluidbook.l10n.__('next page'); - var previous = this.fluidbook.l10n.__('previous page'); + next = this.fluidbook.l10n.__('next page'); + previous = this.fluidbook.l10n.__('previous page'); } } help += '
'; if (this.fluidbook.interface.arrowsEnabled()) { + var labels = this.fluidbook.interface.getLabels(); help += '
'; - help += ''; - help += '
' + this.fluidbook.l10n.__('last page') + '
'; - help += ''; - help += '
' + this.fluidbook.l10n.__('frontpage') + '
'; + help += ''; + help += '
' + labels.last + '
'; + help += ''; + help += '
' + labels.first + '
'; help += '
'; } if ($("#slider").length > 0) { @@ -221,7 +222,7 @@ FluidbookHelp.prototype = { setTimeout(function () { $this.resize(); - $("body,#previous,#next").addClass('help'); + $("body,#prev-arrows,#next-arrows").addClass('help'); this.fluidbook.showAllButtons(); $this.view.css('opacity', 1); }, 50); @@ -239,7 +240,7 @@ FluidbookHelp.prototype = { if (this.isVisible()) { this.overlay.hide(); this.view.hide(); - $("body,#previous,#next").removeClass('help'); + $("body,#prev-arrows,#next-arrows").removeClass('help'); this.fluidbook.hideUnnecessaryButtons(); if (this.fluidbook.support.isMobile) { $("*").unbind('click', function () { @@ -277,7 +278,7 @@ FluidbookHelp.prototype = { var firstTop; if (this.fluidbook.interface.arrowsEnabled()) { - var arrow = $('#interface #next').get(0).getBoundingClientRect(); // Used for calculating offsets for both #next & #previous + var arrow = $('#interface #next-arrows').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 nextTop = Math.round(arrow.top + arrow.height * 0.35); diff --git a/js/libs/fluidbook/fluidbook.interface.js b/js/libs/fluidbook/fluidbook.interface.js index e07128aa..50cb13ef 100644 --- a/js/libs/fluidbook/fluidbook.interface.js +++ b/js/libs/fluidbook/fluidbook.interface.js @@ -12,22 +12,76 @@ function FluidbookInterface(fluidbook) { } FluidbookInterface.prototype = { + + + init: function () { var $this = this; if (this.arrowsEnabled()) { + var labels=this.getLabels(); var res = ''; if ($('html').hasClass('ltr')) { - res += this.fluidbook.nav.getLink('interface-previous', '#', 'previous', '', '', '', true); - res += this.fluidbook.nav.getLink('interface-next', '#', 'next', '', '', '', true); + res += '
'; + res += this.fluidbook.nav.getLink('interface-next', '#', 'next', '', labels.next, 'arrow-top', true); + res += this.fluidbook.nav.getLink('interface-last', '#', 'last', '', labels.last, 'arrow-bottom', true); + res += '
'; + res += '
'; + res += this.fluidbook.nav.getLink('interface-prev', '#', 'previous', '', labels.previous, 'arrow-top', true); + res += this.fluidbook.nav.getLink('interface-first', '#', 'first', '', labels.first, 'arrow-bottom', true); + res += '
'; } else { - res += this.fluidbook.nav.getLink('interface-previous', '#', 'next', '', '', '', true); - res += this.fluidbook.nav.getLink('interface-next', '#', 'previous', '', '', '', true); + res += '
'; + res += this.fluidbook.nav.getLink('interface-next', '#', 'previous', '', labels.previous, 'arrow-top', true); + res += this.fluidbook.nav.getLink('interface-last', '#', 'first', '', labels.first, 'arrow-bottom', true); + res += '
'; + res += '
'; + res += this.fluidbook.nav.getLink('interface-prev', '#', 'next', '', labels.next, 'arrow-top', true); + res += this.fluidbook.nav.getLink('interface-first', '#', 'last', '', labels.last, 'arrow-bottom', true); + res += '
'; } $('#interface').append(res); - $(document).on('click', '#next', goNextPage); - $(document).on('click', '#previous', goPreviousPage); + $(document).on('click', '#next', function () { + if ($this.fluidbook.help.isVisible()) { + return false; + } + $this.fluidbook.interface.resetTimeout(); + if ($this.fluidbook.pad.enabled) { + $this.fluidbook.goNextChapter(); + } else { + $this.fluidbook.goNextPage(); + } + return false; + }); + $(document).on('click', '#previous', function () { + if ($this.fluidbook.help.isVisible()) { + return; + } + $this.fluidbook.interface.resetTimeout(); + if ($this.fluidbook.pad.enabled) { + $this.fluidbook.goPreviousChapter(); + } else { + $this.fluidbook.goPreviousPage(); + } + return false; + }); + $(document).on('click', '#first', function () { + if ($this.fluidbook.help.isVisible()) { + return false; + } + $this.fluidbook.interface.resetTimeout(); + $this.fluidbook.goFirstPage(); + return false; + }); + $(document).on('click', '#last', function () { + if ($this.fluidbook.help.isVisible()) { + return false; + } + $this.fluidbook.interface.resetTimeout(); + $this.fluidbook.goLastPage(); + return false; + }); this.initArrowsVisibilityManagement(); } @@ -37,6 +91,25 @@ FluidbookInterface.prototype = { }); }, + getLabels: function () { + var next = this.fluidbook.l10n.__('next double page'); + var previous = this.fluidbook.l10n.__('previous double page'); + if (this.fluidbook.pad.enabled) { + next = this.fluidbook.l10n.__('next chapter'); + previous = this.fluidbook.l10n.__('previous chapter'); + } + if (this.fluidbook.mobilefirst.enabled) { + next = this.fluidbook.l10n.__('next page'); + previous = this.fluidbook.l10n.__('previous page'); + } + return { + next: next, + previous: previous, + first: this.fluidbook.l10n.__('frontpage'), + last: this.fluidbook.l10n.__('last page') + } + }, + arrowsEnabled: function () { switch (this.fluidbook.settings.arrowsEnabled) { case '0': @@ -156,7 +229,7 @@ FluidbookInterface.prototype = { getInterfaceSelector: function () { var selector = ''; if (this.arrowsEnabled()) { - selector = '#next,#previous' + selector = '#next-arrows,#prev-arrows' } if (this.fluidbook.pad.enabled) { selector = 'header,#interface'; diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index e83c2b30..50313f60 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -535,15 +535,15 @@ Fluidbook.prototype = { var visibility = this.getButtonsVisibility(page); if (visibility.next) { - $("#next").removeClass('hidden'); + $("#next-arrows").removeClass('hidden'); } else { - $("#next").addClass('hidden'); + $("#next-arrows").addClass('hidden'); } if (visibility.previous) { - $("#previous").removeClass('hidden'); + $("#prev-arrows").removeClass('hidden'); } else { - $("#previous").addClass('hidden'); + $("#prev-arrows").addClass('hidden'); } }, updateShadows: function (page, animationDuration) { @@ -595,7 +595,7 @@ Fluidbook.prototype = { } , showAllButtons: function () { - $("#next,#previous").addClass('help').show(); + $("#next-arrows,#prev-arrows").addClass('help').show(); }, setPageNumbers: function () { diff --git a/js/libs/fluidbook/fluidbook.nav.js b/js/libs/fluidbook/fluidbook.nav.js index b2cdf4c2..e19c0c3e 100644 --- a/js/libs/fluidbook/fluidbook.nav.js +++ b/js/libs/fluidbook/fluidbook.nav.js @@ -180,13 +180,12 @@ FluidbookNav.prototype = { } // Only the horizontal icon menu should have the tooltips - if (navType === 'horizontalNav') { - if (help !== undefined && help !== '') { + if (help !== undefined && help !== '') { + if (navType === 'horizontalNav') { res += ' data-tooltip="' + this.fluidbook.l10n.__(help) + '"'; - res += ' aria-label="' + this.fluidbook.l10n.__(help) + '"'; } + res += ' aria-label="' + this.fluidbook.l10n.__(help) + '"'; } - res += '>'; if (showIcon) { @@ -887,7 +886,7 @@ FluidbookNav.prototype = { loopIndex = 0, html = '
    '; - var $this=this; + var $this = this; // Loop through all chapters and build new ULs based on level/depth chapters.forEach(function (chapter) { diff --git a/js/libs/fluidbook/fluidbook.resize.js b/js/libs/fluidbook/fluidbook.resize.js index f942885c..373ae3b9 100644 --- a/js/libs/fluidbook/fluidbook.resize.js +++ b/js/libs/fluidbook/fluidbook.resize.js @@ -58,11 +58,11 @@ FluidbookResize.prototype = { }); if (this.fluidbook.interface.arrowsEnabled()) { - $("#next").transform({ + $("#next-arrows").transform({ origin: [right, '50%'] }); - $("#previous").transform({ + $("#prev-arrows").transform({ origin: [left, '50%'] }); } @@ -232,10 +232,10 @@ FluidbookResize.prototype = { } if (this.fluidbook.interface.arrowsEnabled()) { - $("#next").transform({ + $("#next-arrows").transform({ scale: cssInterfaceScale, }); - $("#previous").transform({ + $("#prev-arrows").transform({ scale: cssInterfaceScale, }); } @@ -280,7 +280,6 @@ FluidbookResize.prototype = { } if (timeout > 0) { - //$("#next,#previous").hide(); clearTimeout(this.navresizeTimeout); this.navresizeTimeout = setTimeout(function () { $this.resizeNav(interfaceScale) @@ -325,8 +324,8 @@ FluidbookResize.prototype = { if (this.fluidbook.interface.arrowsEnabled()) { try { - data.arrowLeftRect = $("#previous").get(0).getBoundingClientRect(); - data.arrowRightRect = $("#next").get(0).getBoundingClientRect(); + data.arrowLeftRect = $("#prev-arrows").get(0).getBoundingClientRect(); + data.arrowRightRect = $("#next-arrows").get(0).getBoundingClientRect(); } catch (e) { } @@ -338,7 +337,7 @@ FluidbookResize.prototype = { var $this = this; if (this.fluidbook.interface.arrowsEnabled()) { var topNext = (this.hh - (100 * interfaceScale)) / 2; - $("#next,#previous").css({ + $("#next-arrows,#prev-arrows").css({ top: topNext }).show(); } diff --git a/style/interface.less b/style/interface.less index 127a739d..35f44250 100644 --- a/style/interface.less +++ b/style/interface.less @@ -5,7 +5,7 @@ position: static; } -#next, #previous { +#next-arrows, #prev-arrows { width: 53px; height: 107px; background-size: 53px 107px; @@ -16,9 +16,72 @@ z-index: 21; color: @arrows-color; background-color: @arrows-background; + + a { + position: absolute; + left: 0; + width: 100%; + + &:hover { + svg { + transform: translateX(5px); + } + } + + svg { + transition: transform 250ms; + position: absolute; + } + + &.arrow-top { + top: 0; + height: 65px; + + svg { + width: 20px; + height: 36.1px; + left: 18px; + top: 22px; + } + } + + &.arrow-bottom { + top: 65px; + height: 42px; + + svg { + width: 13.2px; + height: 15px; + left: 19px; + top: 7px; + } + } + } +} + +#prev-arrows { + a { + &:hover { + svg { + transform: translateX(-5px); + } + } + + &.arrow-top{ + svg{ + left: 17px; + } + } + + &.arrow-bottom{ + svg{ + left:22px; + } + } + } } -#next, #previous, #down, #splash { +#next-arrows, #prev-arrows, #down, #splash { transition: opacity 400ms ease-in-out; .ios & { @@ -26,25 +89,25 @@ } } -#next.hidden.help, #previous.hidden.help { +#next-arrows.hidden.help, #prev-arrows.hidden.help { transition: none; opacity: 1; } -#next.hidden, #previous.hidden { +#next-arrows.hidden, #prev-arrows.hidden { opacity: 0; cursor: default; pointer-events: none; } -.rtl #previous, .ltr #next { +.rtl #prev-arrows, .ltr #next-arrows { border-top-left-radius: 1px; border-bottom-left-radius: 1px; right: 0px; transform-origin: 100% 0; } -.rtl #next, .ltr #previous { +.rtl #next-arrows, .ltr #prev-arrows { border-top-right-radius: 1px; border-bottom-right-radius: 1px; left: 0px; -- 2.39.5