]> _ Git - fluidbook-html5.git/commitdiff
wait #5074 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 22 Mar 2022 17:38:24 +0000 (18:38 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 22 Mar 2022 17:38:24 +0000 (18:38 +0100)
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.secure.js
js/libs/fluidbook/fluidbook.slider.js
js/main.js

index be34a2f80450735be3de58bfc6b0b10ac4732b79..f7e7afd8b98d4bfb9ab0031d233f96da8a881c85 100644 (file)
@@ -20,6 +20,8 @@ Fluidbook.BOTTOM = 9;
 Fluidbook.prototype = {
     init: function (settings) {
         this.flags = {};
+        this.secureOKDone = false;
+        this.initEventsWhenSecureOK = false;
         this.canNavigate = false;
         this.shortLoading = false;
         this.nointerface = false;
@@ -159,6 +161,11 @@ Fluidbook.prototype = {
 
         this.initTheme();
         this.initLoading();
+
+        this.secureOKDone = true;
+        if (this.initEventsWhenSecureOK) {
+            initEvents();
+        }
     },
 
     initSettings: function (settings) {
@@ -751,11 +758,11 @@ Fluidbook.prototype = {
     },
 
     hideMenuItems: function () {
-        gsap.to($('#menuList > ul > li, #shareLinks,footer#mobile-credits'),{duration:0.1, autoAlpha: 0});
+        gsap.to($('#menuList > ul > li, #shareLinks,footer#mobile-credits'), {duration: 0.1, autoAlpha: 0});
     },
 
     showMenuItems: function () {
-        gsap.to($('#menuList > ul > li, #shareLinks,footer#mobile-credits'),{duration:0.3,autoAlpha:1});
+        gsap.to($('#menuList > ul > li, #shareLinks,footer#mobile-credits'), {duration: 0.3, autoAlpha: 1});
     },
 
     print: function (button) {
index ed5acfc5616ed8371d1485d02475fba282dcc1ed..4d9b91280fa029ce29ade88fa4f176daed03fc6b 100644 (file)
@@ -63,8 +63,21 @@ FluidbookSecure.prototype = {
     },
 
     checkSecure: function (callback) {
+        var $this=this;
+        // Hybrid protection
+        if (this.fluidbook.settings.secureURL !== 'http://' && this.fluidbook.settings.secureURL !== '' && this.fluidbook.settings.secureClientSidePassword !== '') {
+
+            return this.checkSecureByURL(function (res) {
+                if (res) {
+                    callback();
+                } else {
+                    $this.checkSecureByClientSidePassword(callback);
+                }
+            }, false);
+        }
+
         if (this.fluidbook.settings.secureURL !== 'http://' && this.fluidbook.settings.secureURL !== '') {
-            return this.checkSecureByURL(callback);
+            return this.checkSecureByURL(callback, true);
         }
         if (this.fluidbook.settings.secureClientSidePassword !== '') {
             return this.checkSecureByClientSidePassword(callback);
@@ -73,23 +86,30 @@ FluidbookSecure.prototype = {
         callback();
     },
 
-    checkSecureByURL: function (callback) {
+    checkSecureByURL: function (callback, nokURL) {
+        if (nokURL === undefined) {
+            nokURL = true;
+        }
         var $this = this;
         $.ajax({
             url: $this.fluidbook.settings.secureURL, crossDomain: true, method: 'GET', type: 'json', xhrFields: {
                 withCredentials: true
             }, success: function (data) {
-                var res = data.data[0]['logged-in'];
+                var res = data !== undefined && data.data !== undefined && data.data[0] !== undefined && data.data[0]['logged-in'];
                 if (res !== undefined && res !== null) {
-                    if (res === true) {
-                        callback();
-                    } else if (res === false) {
-                        $this.secureByURLNOK();
+                    if (!nokURL) {
+                        callback(res);
+                    } else {
+                        if (res === true) {
+                            callback(true);
+                        } else if (res === false) {
+                            $this.secureByURLNOK();
+                        }
                     }
                 }
             }, error: function (e) {
                 console.log(e);
-                callback();
+                callback(false);
             }
         });
     },
@@ -100,6 +120,7 @@ FluidbookSecure.prototype = {
     },
 
     checkSecureByClientSidePassword: function (callback) {
+
         var u = window.sessionStorage.getItem('secureUsername');
         var p = window.sessionStorage.getItem('securePassword');
         var ok = false;
index a5253970846b73be6a0a935a14c051b6947dc659..4a9cfb10e0e5a0758179ac7fc9a432afc496ec14 100644 (file)
@@ -157,11 +157,15 @@ FluidbookSlider.prototype = {
 
     resizeSliderLink: function (ww, hh, single) {
         var r = document.getElementById("fluidbook").getBoundingClientRect();
-        var scale = r.width / this.fluidbook.settings.sliderImageDimensions[0];
-        var h = this.fluidbook.settings.sliderImageDimensions[1] * scale;
+        var iw = this.fluidbook.settings.sliderImageDimensions[0];
+        var ih = this.fluidbook.settings.sliderImageDimensions[1];
+        var ah = hh - r.top - r.height;
+        var scale = Math.min(r.width / iw, ah / ih);
+        var h = ih * scale;
+        var w = iw * scale;
         css = {
-            left: r.left,
-            top: (r.top + r.height) + ((hh - r.top - r.height - h) / 2),
+            left: r.left + ((r.width - w) / 2),
+            top: (r.top + r.height) + ((ah - h) / 2),
             transform: "scale(" + scale + ")"
         };
         $("#sliderlinks").css(css);
index 69a331fe5d0dc3366d402a24b9c83d64b31a1416..dfd707812152f0326ec8fba6293c31b35e8856c1 100644 (file)
@@ -275,7 +275,11 @@ try {
             window.fluidbook.ready();
         }
 
-        initEvents();
+        if(this.fluidbook.secureOKDone) {
+            initEvents();
+        }else{
+            this.fluidbook.initEventsWhenSecureOK=true;
+        }
     }
 
     function initEvents() {