From bf0f6b3dcfde39f483870418a5476adcf57399ab Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 21 Jun 2017 20:37:17 +0200 Subject: [PATCH] wip #1392 @2 --- js/libs/fluidbook/fluidbook.menu.js | 33 ++++++++++++++++++++------ js/libs/fluidbook/fluidbook.tooltip.js | 19 +++++++++++---- style/fluidbook.less | 23 +++++++++++------- 3 files changed, 55 insertions(+), 20 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.menu.js b/js/libs/fluidbook/fluidbook.menu.js index c3018e23..e66d8864 100644 --- a/js/libs/fluidbook/fluidbook.menu.js +++ b/js/libs/fluidbook/fluidbook.menu.js @@ -9,10 +9,17 @@ FluidbookMenu.prototype = { var $this = this; $(document).on('click', ".mview .back", function () { + var currentHash = window.location.hash; window.location.hash = '/page/' + $this.fluidbook.currentPage; + if (window.location.hash == currentHash) { + $this.closeView(function () { + }, true); + } + return false; }); + }, viewMode: function () { @@ -79,6 +86,8 @@ FluidbookMenu.prototype = { this.openChapters(cb); } else if (view == 'archives') { this.openArchives($("#nav #archives").data('tooltip'), cb); + } else if (view == 'text') { + this.openText(param1, cb); } else { this['open' + camelView](param1, param2, cb); } @@ -100,8 +109,9 @@ FluidbookMenu.prototype = { var from = {y: -200, opacity: 0}; var to = { y: 0, opacity: 1, onComplete: function () { - //console.log('end opening view'); - callback(); + if (callback != undefined) { + callback(); + } $this.fluidbook.hideLoader(); resize(); } @@ -110,7 +120,6 @@ FluidbookMenu.prototype = { from.y = 0; } TweenMax.fromTo($(mview), 0.5, from, to); - }, displayResults: function (data, group, callback) { @@ -189,8 +198,7 @@ FluidbookMenu.prototype = { if (callback != undefined) { callback(); } - } - , + }, openVideo: function (video, callback) { var a = $('a[href="#/video/' + video + '"]'); var markup = decodeURIComponent($(a).attr('data-video')); @@ -389,8 +397,15 @@ FluidbookMenu.prototype = { if (callback != undefined) { callback(); } - } - , + }, + openText: function (text, callback) { + var t = '
' + this.closeButton() + '

'; + t += '
' + text + '
'; + $("#view").append('
' + t + '
'); + if (callback != undefined) { + callback(); + } + }, closeView: function (callback, all, animate) { this.hideOverlay(); var $this = this; @@ -455,6 +470,10 @@ FluidbookMenu.prototype = { forceHeight = true; } break; + case 'text': + w = 600; + fullscreen = (w >= ww * 0.9); + break; case 'index': fullscreen = true; break; diff --git a/js/libs/fluidbook/fluidbook.tooltip.js b/js/libs/fluidbook/fluidbook.tooltip.js index 38839dc6..06313a9f 100644 --- a/js/libs/fluidbook/fluidbook.tooltip.js +++ b/js/libs/fluidbook/fluidbook.tooltip.js @@ -18,16 +18,15 @@ FluidbookTooltip.prototype = { $("#tooltip").transform({scale: 1 / zoom}).css({'marginTop': 20 / zoom, 'marginLeft': -10 / zoom}); }); - if (Modernizr.ftouch) { $(document).on('touchstart', 'a[data-tooltip-touch][data-tooltip]', function (e) { $this.updateMousePosition(e); - return $this.eventTriggered(this); + $this.eventTriggered(this); }); } else { $(document).on('mouseover', 'a[data-tooltip]', function (e) { $this.updateMousePosition(e); - return $this.eventTriggered(this); + $this.eventTriggered(this); }); } $("body").append('
'); @@ -67,10 +66,13 @@ FluidbookTooltip.prototype = { offsetX = 26 - w; } + var top = this.mouseY + offsetY; var left = this.mouseX + offsetX; + var maxx = this.fluidbook.resize.ww - w; + var maxy = this.fluidbook.resize.hh - h; - $("#tooltip").attr('data-pos-x', x).attr('data-pos-y', y).css({top: Math.max(1, top), left: Math.max(1, left)}); + $("#tooltip").attr('data-pos-x', x).attr('data-pos-y', y).css({top: Math.max(1, Math.min(top, maxy)), left: Math.max(1, Math.min(left, maxx))}); }, eventTriggered: function (target) { @@ -109,7 +111,7 @@ FluidbookTooltip.prototype = { t.css('maxWidth', 250).html(text).show() var nbchars = t.text().length; - var maxWidth = Math.max(250, Math.min(750, nbchars*1.2)); + var maxWidth = Math.min(this.fluidbook.resize.ww, Math.max(250, Math.min(750, nbchars * 1.2))); for (var w = 250; w <= maxWidth; w += 25) { if ((t.height() * 1.5) > t.width()) { @@ -119,6 +121,13 @@ FluidbookTooltip.prototype = { } } + if (t.outerHeight() > this.fluidbook.resize.hh / 2) { + t.hide(); + this.fluidbook.menu.__openView('text', text, function () { + }); + return false; + } + return true; }, hideTooltip: function () { diff --git a/style/fluidbook.less b/style/fluidbook.less index 8916c698..93bb4e20 100644 --- a/style/fluidbook.less +++ b/style/fluidbook.less @@ -55,7 +55,6 @@ a { -o-box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); - -ms-touch-action: double-tap-zoom pinch-zoom; -ms-scroll-chaining: chained; -webkit-font-smoothing: antialiased; @@ -74,17 +73,15 @@ b, strong, h1, h2, h3, h4, h5, h6 { font-weight: 600; } -.pan, .pan * { - -ms-touch-action: auto; - touch-action: auto; -} - html { user-select: text; -moz-user-select: text; -webkit-user-select: text; -o-user-select: text; -ms-user-select: text; + &.ios { + position: fixed; + } } body { @@ -213,6 +210,7 @@ body, html { /* Pages */ .background, .texts { + pointer-events: none; position: absolute; top: 0px; left: 0px; @@ -239,6 +237,10 @@ body, html { /* Espaces forcés */ +#currentDoublePage{ + pointer-events: none; +} + .page { overflow: hidden; position: absolute; @@ -736,8 +738,6 @@ html.ios body.portrait #interface { .link.multimedia { position: absolute; z-index: 1 !important; - -ms-touch-action: manipulation; - touch-action: manipulation; &.notinteractive { pointer-events: none; @@ -1424,6 +1424,13 @@ ul.chapters.shareList a.level0 img { display: block; } +/* texts */ +.mview .text { + padding: 20px; + white-space: pre-line; + text-align: left; +} + /* Chapters */ ul.chapters { -- 2.39.5