From 4193f421356a04405a28f2724c062c0d7dbd7c18 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 23 Apr 2020 19:37:22 +0200 Subject: [PATCH] wait #3612 @2 --- _index.html | 2 +- js/libs/fluidbook/fluidbook.js | 66 ++------------------- js/libs/fluidbook/fluidbook.splash.js | 85 +++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 62 deletions(-) create mode 100644 js/libs/fluidbook/fluidbook.splash.js diff --git a/_index.html b/_index.html index 1d662a7f..d3c3c10f 100644 --- a/_index.html +++ b/_index.html @@ -97,7 +97,7 @@
-
+
diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index 739fc118..95bc1b0a 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -41,6 +41,7 @@ Fluidbook.prototype = { this.landingpage = new FluidbookLandingPage(this); } + this.splash = new FluidbookSplash(this); this.contentlock = new FluidbookContentLock(this); this.menu = new FluidbookMenu(this); this.support = new FluidbookSupport(this); @@ -73,6 +74,7 @@ Fluidbook.prototype = { this.slideshow = new FluidbookSlideshow(this); this.printing = new FluidbookPrint(this); + if (this.settings.basket) { this.cart = new FluidbookCart(this); } @@ -209,64 +211,6 @@ Fluidbook.prototype = { }); // See fluidbook.audiodescription.js for specific shortcuts }, - hideSplash: function () { - if ($("#splash").length == 0) { - return; - } - try { - navigator.splashscreen.hide(); - } catch (err) { - } - $(this).trigger('fluidbook.splash.beforehide'); - var $this = this; - if (this.support.transitions3dacc && this.settings.mobileTransitions === 'flip3d' && !this.mobilefirst.enabled) { - $("#main,#viewOverlay,#view").css('visibility', 'visible'); - resize(); - this.networkControl.pause(4000); - setTimeout(function () { - this.fluidbook.pagetransitions.flip3d.performancesTest(function () { - $this.networkControl.resume(); - $this._hideSplash(); - }) - }, 500); - } else { - this._hideSplash(); - } - }, - - - _hideSplash: function () { - var $this = this; - var timeout = 700; - this.resize.resize(false, true); - setTimeout(function () { - $this.__hideSplash(); - }, timeout); - }, - - __hideSplash: function () { - - $("#main,#viewOverlay,#view").css('visibility', 'visible'); - this.resize.resize(false); - this.hideLoader(0, true); - - if (this.support.transitions2d && !this.support.iOS) { - $("#splash").css('opacity', 0).one('transitionend', function () { - $(this).remove(); - }); - } else { - $("#splash").fadeOut(500, function () { - $(this.remove()); - }) - } - - setTimeout(function () { - $("#splash").remove(); - }, 1500); - - this.allowChangePage(); - $(this).trigger('fluidbook.splash.hide'); - }, allowChangePage: function () { var $this = this; @@ -502,10 +446,10 @@ Fluidbook.prototype = { } $this.zoom.resetZoom(); - $this.hideSplash(); + $this.splash.hide(); }, true); } else if (args[1] === 'landing') { - $this.hideSplash(); + $this.splash.hide(); if (this.landingpage !== undefined) { this.landingpage.show(); } @@ -531,7 +475,7 @@ Fluidbook.prototype = { $this.pagetransitions.pageTransition(this.currentPage); } this.menu.openView(view, args[2], args[3], function () { - $this.hideSplash(); + $this.splash.hide(); }); } return; diff --git a/js/libs/fluidbook/fluidbook.splash.js b/js/libs/fluidbook/fluidbook.splash.js new file mode 100644 index 00000000..f2e4db45 --- /dev/null +++ b/js/libs/fluidbook/fluidbook.splash.js @@ -0,0 +1,85 @@ +function FluidbookSplash(fluidbook) { + this.fluidbook = fluidbook; + this.init(); +} + +FluidbookSplash.prototype = { + init: function () { + this.waitForTimer = true; + this.waitForReady = true; + + var $this = this; + this.initTime = Date.now(); + setTimeout(function () { + $this.waitForTimer = false; + $this.hideIfPossible(); + }, parseFloat(this.fluidbook.settings.splashMinimalTime) * 1000); + + }, + + hide: function () { + if ($("#splash").length == 0) { + return; + } + this.waitForReady = false; + try { + navigator.splashscreen.hide(); + } catch (err) { + } + $(this.fluidbook).trigger('fluidbook.splash.beforehide'); + var $this = this; + if (this.fluidbook.support.transitions3dacc && this.fluidbook.settings.mobileTransitions === 'flip3d' && !this.fluidbook.mobilefirst.enabled) { + $("#main,#viewOverlay,#view").css('visibility', 'visible'); + resize(); + this.fluidbook.networkControl.pause(4000); + setTimeout(function () { + this.fluidbook.pagetransitions.flip3d.performancesTest(function () { + $this.fluidbook.networkControl.resume(); + $this.hideIfPossible(); + }) + }, 500); + } else { + this.hideIfPossible(); + } + }, + + hideIfPossible: function () { + if (!this.waitForReady && !this.waitForTimer) { + this._hide(); + } + }, + + _hide: function () { + var $this = this; + var timeout = 700; + this.fluidbook.resize.resize(false, true); + setTimeout(function () { + $this.__hide(); + }, timeout); + }, + + __hide: function () { + + $("#main,#viewOverlay,#view").css('visibility', 'visible'); + this.fluidbook.resize.resize(false); + this.fluidbook.hideLoader(0, true); + + if (this.fluidbook.support.transitions2d && !this.fluidbook.support.iOS) { + $("#splash").css('opacity', 0).one('transitionend', function () { + $(this).remove(); + }); + } else { + $("#splash").fadeOut(500, function () { + $(this.remove()); + }) + } + + setTimeout(function () { + $("#splash").remove(); + }, 1500); + + this.fluidbook.allowChangePage(); + $(this.fluidbook).trigger('fluidbook.splash.hide'); + }, + +} \ No newline at end of file -- 2.39.5