From e35767b7260e8e9114674c35124f8f35242b7e5e Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 5 May 2022 21:22:06 +0200 Subject: [PATCH] wip #5228 @3 --- js/libs/fluidbook/fluidbook.cache.js | 9 +++++-- js/libs/fluidbook/fluidbook.js | 6 +++-- js/libs/fluidbook/fluidbook.links.js | 1 + js/libs/fluidbook/fluidbook.menu.js | 37 +++++++++++++++++++++++++--- 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.cache.js b/js/libs/fluidbook/fluidbook.cache.js index 300c99ae..5f79a00b 100644 --- a/js/libs/fluidbook/fluidbook.cache.js +++ b/js/libs/fluidbook/fluidbook.cache.js @@ -1,6 +1,7 @@ -function FluidbookCache(options) { +function FluidbookCache(fluidbook) { + this.fluidbook=fluidbook; this._cache = {}; - this.options = options; + this.options = fluidbook.settings; this._prefix = 'fluidbook.' + this.options.id + '.'; this._support = false; this._date = this.options.cacheDate; @@ -11,6 +12,10 @@ function FluidbookCache(options) { FluidbookCache.prototype = { init: function () { + var $this = this; + this.fluidbook.keyboard.keyShortcut('⌘+alt+c, ctrl+alt+c', function () { + $this.clear(); + }); if (this._support) { this.checkValidity(); } diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index f26c7a13..2149be6c 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -84,7 +84,7 @@ Fluidbook.prototype = { this.displayOnePage = this.alwaysDisplayOnePage = this.settings.mobileNavigationType === 'portrait' || (this.pad && this.pad.enabled) || this.mobilefirst.enabled; this.zoom = new FluidbookZoom(this); this.zoom.resetZoom(); - this.cache = new FluidbookCache(this.settings); + this.cache = new FluidbookCache(this); this.service = new FluidbookService(this, this.settings.id); this.loader = new FluidbookLoader(this); if (!this.mobilefirst.enabled) { @@ -138,6 +138,7 @@ Fluidbook.prototype = { this.refw = 0; this.refh = 0; + this.refh = 0; this.searchString = ''; this.vectorTexts = !this.support.imagesVersion; this.indexHTML = ''; @@ -149,7 +150,7 @@ Fluidbook.prototype = { } else { $("body").addClass('desktop'); } - if(this.settings.correctCenter){ + if (this.settings.correctCenter) { $('body').addClass('correct-center'); } if (this.pad.enabled) { @@ -487,6 +488,7 @@ Fluidbook.prototype = { } $this.zoom.resetZoom(); $this.splash.hide(); + $this.menu.closeViewCallbackEvent(true); }, true); } else if (args[1] === 'landing') { $this.splash.hide(); diff --git a/js/libs/fluidbook/fluidbook.links.js b/js/libs/fluidbook/fluidbook.links.js index 0473e4ca..83593403 100644 --- a/js/libs/fluidbook/fluidbook.links.js +++ b/js/libs/fluidbook/fluidbook.links.js @@ -87,6 +87,7 @@ FluidbookLinks.prototype = { var id = $(this).closest('[data-id]').attr('data-id'); $this.fluidbook.contentlock.addAction(id, 'click'); $this.fluidbook.gamify.linkClicked(id); + $($this.fluidbook).trigger('fluidbook.link.click', [id]); return true; }); diff --git a/js/libs/fluidbook/fluidbook.menu.js b/js/libs/fluidbook/fluidbook.menu.js index f26f34e6..791c4222 100644 --- a/js/libs/fluidbook/fluidbook.menu.js +++ b/js/libs/fluidbook/fluidbook.menu.js @@ -6,6 +6,7 @@ function FluidbookMenu(fluidbook) { FluidbookMenu.prototype = { init: function () { + this.closeEventSent = false; this.index = new FluidbookIndex(this.fluidbook); var $this = this; @@ -600,20 +601,47 @@ FluidbookMenu.prototype = { } }, + closeViewCallbackEvent: function (all) { + var $this = this; + if (this.closeEventSent) { + return; + } + this.closeEventSent = true; + $(this.fluidbook).trigger('fluidbook.view.close'); + if (all) { + $(this.fluidbook).trigger('fluidbook.view.close.all'); + } + setTimeout(function () { + $this.closeEventSent = false; + }, 1000); + }, + closeView: function (callback, all, animate) { + var $this = this; + all = all || $("#view .mview").length <= 1; + + var cb; if (callback === undefined) { - callback = function () { + cb = function () { + $this.closeViewCallbackEvent(all); + }; + } else { + cb = function () { + callback(); + $this.closeViewCallbackEvent(all); }; } - if (all || $("#view .mview").length <= 1) { + if (all) { var currentHash = window.location.hash; window.location.hash = '#/page/' + this.fluidbook.currentPage; if (window.location.hash == currentHash) { - this._closeView(callback, true, animate); + this._closeView(cb, true, animate); + } else { + setTimeout(cb, 1000); } } else { - this._closeView(callback, all, animate); + this._closeView(cb, all, animate); } }, @@ -668,6 +696,7 @@ FluidbookMenu.prototype = { quickCloseView: function () { $("#view .mview").remove(); + $this.closeViewCallbackEvent(true); }, resize: function (ww, hh) { -- 2.39.5