From bd7413c958e798f0325fd934ba5ea8e89f6ff8ec Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 6 Sep 2022 16:02:07 +0200 Subject: [PATCH] wip #5431 @0.25 --- js/libs/fluidbook/fluidbook.js | 131 ++++++++++++--------------------- 1 file changed, 47 insertions(+), 84 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index 1d27b760..b648afcf 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -308,38 +308,32 @@ Fluidbook.prototype = { } catch (err) { } }); - }, - initPage: function (pageNr, doublePage, position) { + }, initPage: function (pageNr, doublePage, position) { if ($("#page_" + pageNr).length > 0) { return; } $(doublePage).find('.' + position).remove(); var page = '
'; $(doublePage).append(page); - }, - hidePage: function (position) { + }, hidePage: function (position) { $("#pages ." + position).hide(); - }, - canChangePage: function () { + }, canChangePage: function () { try { return this.pagetransitions.canChangePage(); } catch (e) { } return false; - }, - initVideos: function () { + }, initVideos: function () { this.video.initVideos(); - }, - getNextOffset: function () { + }, getNextOffset: function () { var offset = 2; if (this.displayOnePage) { offset = 1; } this.transitionAxis = 'x'; return offset; - }, - goNextPage: function () { + }, goNextPage: function () { if (!this.canChangePage()) { return; } @@ -350,15 +344,13 @@ Fluidbook.prototype = { this.transitionAxis = 'x'; this.setCurrentPage(this.normalizePage(this.currentPage) + this.getNextOffset()); } - }, - goFirstPage: function () { + }, goFirstPage: function () { if (!this.canChangePage()) { return; } this.transitionAxis = 'x'; this.setCurrentPage(1); - }, - goPreviousPage: function () { + }, goPreviousPage: function () { if (!this.canChangePage()) { return; } @@ -369,15 +361,13 @@ Fluidbook.prototype = { this.transitionAxis = 'x'; this.setCurrentPage(this.normalizePage(this.currentPage) - this.getNextOffset()); } - }, - goLastPage: function () { + }, goLastPage: function () { if (!this.canChangePage()) { return; } this.transitionAxis = 'x'; this.setCurrentPage(this.contentlock.getMaxPage()); - }, - goNextChapter: function () { + }, goNextChapter: function () { if (!this.canChangePage()) { return; } @@ -387,8 +377,7 @@ Fluidbook.prototype = { } this.transitionAxis = 'x'; this.setCurrentPage(this.normalizePage(next)); - }, - goPreviousChapter: function () { + }, goPreviousChapter: function () { if (!this.canChangePage()) { return; } @@ -398,8 +387,7 @@ Fluidbook.prototype = { } this.transitionAxis = 'x'; this.setCurrentPage(this.normalizePage(prev)); - }, - goNextChapterPage: function () { + }, goNextChapterPage: function () { if (!this.canChangePage()) { return; } @@ -410,8 +398,7 @@ Fluidbook.prototype = { } this.transitionAxis = 'y'; this.setCurrentPage(this.normalizePage(next)); - }, - goPreviousChapterPage: function () { + }, goPreviousChapterPage: function () { if (!this.canChangePage()) { return; } @@ -422,18 +409,15 @@ Fluidbook.prototype = { } this.transitionAxis = 'y'; this.setCurrentPage(this.normalizePage(prev)); - }, - normalizePage: function (page) { + }, normalizePage: function (page) { page = Math.max(1, Math.min(page, this.contentlock.getMaxPage())); if (!this.displayOnePage && page % 2 === 1) { page--; } return page; - }, - setCurrentPage: function (page) { + }, setCurrentPage: function (page) { window.location.hash = "#/page/" + this.normalizePage(page); - }, - changeAddress: function () { + }, changeAddress: function () { var hash = window.location.hash; if ($('.mview[data-hash="' + hash + '"]').length > 0) { return; @@ -600,25 +584,20 @@ Fluidbook.prototype = { window.location.hash = "/page/" + page; } } - }, - getButtonsVisibility: function (page) { + }, getButtonsVisibility: function (page) { if (page === undefined) { page = this.currentPage; } var max = this.contentlock.getMaxPage(); - if (this.contentlock.getMaxPage() % 2 === 1 && - this.settings.mobileNavigationType !== 'portrait' && - this.settings.mobileNavigationType !== 'mobilefirst' && - this.resize.orientation !== 'portrait') { + if (this.contentlock.getMaxPage() % 2 === 1 && this.settings.mobileNavigationType !== 'portrait' && this.settings.mobileNavigationType !== 'mobilefirst' && this.resize.orientation !== 'portrait') { max--; } var next = page < max; var previous = (page > 1); return {previous: previous, next: next}; - }, - hideUnnecessaryButtons: function (page) { + }, hideUnnecessaryButtons: function (page) { var speed = 500; if (page === undefined) { page = this.currentPage; @@ -696,9 +675,7 @@ Fluidbook.prototype = { if (s_out.length > 0) { $(s).children(s_out.join(',')).addClass('hidden'); } - } - , - showAllButtons: function () { + }, showAllButtons: function () { $("#next-arrows,#prev-arrows").addClass('help').show(); }, @@ -706,8 +683,7 @@ Fluidbook.prototype = { $("#pagesnumbers .left").html(this.getPageNumberOfSide('left', true)); $("#pagesnumbers .right").html(this.getPageNumberOfSide('right', true)); $("#pagesnumbers").removeClass('hidden'); - }, - getPhysicalPageNumberOfSide: function (side, strict) { // Side should be 'left' or 'right' + }, getPhysicalPageNumberOfSide: function (side, strict) { // Side should be 'left' or 'right' if (undefined === strict) { strict = false; } @@ -720,8 +696,7 @@ Fluidbook.prototype = { pageSide = $("#currentDoublePage").find('.page').eq(0); } return $(pageSide).data('page'); - }, - getDisplayedPages: function () { + }, getDisplayedPages: function () { var res = []; var left = this.getPhysicalPageNumberOfSide('left', true); var right = this.getPhysicalPageNumberOfSide('right', true); @@ -744,8 +719,7 @@ Fluidbook.prototype = { return ''; } return this.physicalToVirtual(physical); - }, - clickLogo: function () { + }, clickLogo: function () { if (this.settings.url_link.indexOf('#') === 0) { window.location.hash = this.settings.url_link; } else { @@ -763,17 +737,13 @@ Fluidbook.prototype = { var rand = Math.round(Math.random() * 100000); this.waiters.push(rand); return rand; - }, - waiterActive: function (id) { + }, waiterActive: function (id) { return this.waiters.indexOf(id) > -1; - }, - resetWaiters: function () { + }, resetWaiters: function () { this.waiters = []; - }, - physicalToVirtual: function (page) { + }, physicalToVirtual: function (page) { return this.settings.numerotation[page - 1]; - }, - virtualToPhysical: function (page) { + }, virtualToPhysical: function (page) { if (page === undefined) { return false; } @@ -793,12 +763,10 @@ Fluidbook.prototype = { }, print: function (button) { - this.stats.track(3); return this.openPDF(button, true); }, downloadPDF: function (button) { - this.stats.track(7); return this.openPDF(button, false) }, @@ -807,6 +775,9 @@ Fluidbook.prototype = { var pdf; var pdfName; + var statsEventType = print ? 3 : 7; + this.stats.track(statsEventType); + if (this.settings.pages != this.contentlock.getMaxPage()) { pdf = 'https://workshop.fluidbook.com/s/e/' + this.settings.cid + '/1-' + this.contentlock.getMaxPage(); } else if (this.settings.pdfName.substr(0, 4) === 'http') { @@ -825,6 +796,9 @@ Fluidbook.prototype = { print = false; } + var statsEventType = print ? 3 : 7; + this.stats.track(statsEventType); + var $this = this; if (this.settings.phonegap != false) { if (type == undefined) { @@ -859,9 +833,7 @@ Fluidbook.prototype = { if (this.settings.phonegap != false) { this.displayLoader(); $.ajax({ - url: url, - type: 'HEAD', - success: function (data) { + url: url, type: 'HEAD', success: function (data) { f(); $this.hideLoader(1, true); }, @@ -879,8 +851,7 @@ Fluidbook.prototype = { fs = LocalFileSystem.PERSISTENT; } - var requestFileSystem = window.requestFileSystem || - window.webkitRequestFileSystem; + var requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem; requestFileSystem(fs, 0, function (fileSystem) { console.log('fs requested'); @@ -889,23 +860,18 @@ Fluidbook.prototype = { var filePath = fileEntry.toURL().replace("dummy.html", "") + localname; var fileTransfer = new FileTransfer(); var uri = encodeURI(url); - fileTransfer.download( - uri, - filePath, - function (entry) { - console.log('file donwloaded'); - if (callback !== undefined) { - if (callbackArgs === undefined) { - callbackArgs = []; - } - callbackArgs[0] = entry.toURL(); - callback.apply($this, callbackArgs); + fileTransfer.download(uri, filePath, function (entry) { + console.log('file donwloaded'); + if (callback !== undefined) { + if (callbackArgs === undefined) { + callbackArgs = []; } - }, - function (error) { - console.log('file error'); + callbackArgs[0] = entry.toURL(); + callback.apply($this, callbackArgs); } - ); + }, function (error) { + console.log('file error'); + }); }); }, function () { @@ -1021,8 +987,7 @@ Fluidbook.prototype = { $("#currentDoublePage").css({ translateX: offset }); - }, - displayLoader: function () { + }, displayLoader: function () { $("#loader").addClass('show'); if (!this.support.isMobile) { $('body').addClass('loading'); @@ -1207,9 +1172,7 @@ Fluidbook.prototype = { if (window.confirm('An error occured: ' + e.name + '. Do you want to send a report ?')) { var subject = '[Fluidbook error report] ' + e.message; var o = { - name: e.name, - message: e.message, - stack: e.stack, + name: e.name, message: e.message, stack: e.stack, } window.location = 'mailto:tech@fluidbook.com?subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(JSON.stringify(o)); } -- 2.39.5