]> _ Git - fluidbook-html5.git/commitdiff
wip #5228 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 5 May 2022 19:22:06 +0000 (21:22 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 5 May 2022 19:22:06 +0000 (21:22 +0200)
js/libs/fluidbook/fluidbook.cache.js
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.links.js
js/libs/fluidbook/fluidbook.menu.js

index 300c99ae11a23c7e68c3513ada259ddd496e7a20..5f79a00b96d166860a969714dd71d83432c1f826 100644 (file)
@@ -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();
         }
index f26c7a1396a773b9fe18e0c4650f2af339ca09cd..2149be6ce553d3c2dbd2169b4440fad5a8f79c99 100644 (file)
@@ -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();
index 0473e4ca317344193b2e4e2c3d41be2e2a2cb15f..835934031d949b25d52ebfb928b00a26515c2f79 100644 (file)
@@ -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;
         });
 
index f26f34e66617ba9aa378ab2831ecbe78bb0157e3..791c422281fd13fcb462bd7ae40ba790f70ba0e6 100644 (file)
@@ -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) {