]> _ Git - fluidbook-html5.git/commitdiff
try #2640 @0:15
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 19 Mar 2019 15:44:20 +0000 (16:44 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 19 Mar 2019 15:44:20 +0000 (16:44 +0100)
js/libs/fluidbook/fluidbook.js

index 3aa0a0c78de8dbd45975dc4a99c1b3aca43b5bc7..f710d93d3f323dd6685ace4270128e2987973602 100644 (file)
@@ -411,14 +411,25 @@ Fluidbook.prototype = {
             defaultStartPage = FLUIDBOOK_START_PAGE;
         }
 
-
         if (args.length <= 1 || args[1] == '' || args[1] == undefined) {
             if (this.landingpage !== undefined && this.landingpage.hasLandingPage) {
                 window.location.hash = '/landing';
                 return;
             }
             return this.setCurrentPage(defaultStartPage);
-        } else if (args[1] === 'closeview') {
+        }
+
+        // Handle flash URL. See #2640
+        if (args.length > 1) {
+            var a1 = args[1];
+            if (a1.match(/^[0-9]*$/)) {
+                args = ['#', 'page', a1];
+            }
+        }
+
+        console.log(args);
+
+        if (args[1] === 'closeview') {
             return this.setCurrentPage(this.currentPage);
         } else if (args[1] === 'page') {
             if (fluidbook.datas.pageLabels[args[2]] !== undefined) {
@@ -483,12 +494,14 @@ Fluidbook.prototype = {
             });
         }
         return;
-    },
+    }
+    ,
 
 
     reloadCurrentPage: function () {
         this.pageTransition(this.currentPage);
-    },
+    }
+    ,
 
     readingPage: function (side) {
         if (!this.displayOnePage) {
@@ -505,7 +518,8 @@ Fluidbook.prototype = {
                 window.location.hash = "/page/" + page;
             }
         }
-    },
+    }
+    ,
     hideUnnecessaryButtons: function (page) {
         var speed = 500;
         if (page == undefined) {
@@ -548,7 +562,8 @@ Fluidbook.prototype = {
                 $("#next:visible").fadeOut(speed);
             }
         }
-    },
+    }
+    ,
     updateShadows: function (page, animationDuration) {
         if (animationDuration === undefined) {
             animationDuration = 0;
@@ -598,15 +613,18 @@ Fluidbook.prototype = {
             $(s).children(s_out.join(',')).addClass('hidden');
         }
 
-    },
+    }
+    ,
     showAllButtons: function () {
         $("#next,#previous").addClass('help').show();
-    },
+    }
+    ,
     setPageNumbers: function () {
         $("#pagesnumbers .left").html(this.getPageNumberOfSide('left'));
         $("#pagesnumbers .right").html(this.getPageNumberOfSide('right'));
         $("#pagesnumbers").removeClass('hidden');
-    },
+    }
+    ,
     getPhysicalPageNumberOfSide: function (side) { // Side should be 'left' or 'right'
         var pageSide = $("#currentDoublePage").find('.' + side);
         if (pageSide.length == 0) {
@@ -614,14 +632,16 @@ Fluidbook.prototype = {
         }
 
         return $(pageSide).data('page');
-    },
+    }
+    ,
     getPageNumberOfSide: function (side) {
         var physical = this.getPhysicalPageNumberOfSide(side);
         if (!physical || physical === 1) {
             return '';
         }
         return this.physicalToVirtual(physical);
-    },
+    }
+    ,
     clickLogo: function () {
         if (this.datas.url_link == '' || this.datas.url_link == 'http://') {
             return;
@@ -632,7 +652,8 @@ Fluidbook.prototype = {
         } else {
             this.wopen(this.datas.url_link, '_blank');
         }
-    },
+    }
+    ,
 
     addWaiter: function (reset) {
         if (reset == undefined) {
@@ -644,16 +665,20 @@ Fluidbook.prototype = {
         var rand = Math.round(Math.random() * 100000);
         this.waiters.push(rand);
         return rand;
-    },
+    }
+    ,
     waiterActive: function (id) {
         return this.waiters.indexOf(id) > -1;
-    },
+    }
+    ,
     resetWaiters: function () {
         this.waiters = [];
-    },
+    }
+    ,
     physicalToVirtual: function (page) {
         return this.datas.numerotation[page - 1];
-    },
+    }
+    ,
     virtualToPhysical: function (page) {
         if (page === undefined) {
             return false;
@@ -663,25 +688,30 @@ Fluidbook.prototype = {
             return false;
         }
         return i + 1;
-    },
+    }
+    ,
 
     hideMenuItems: function () {
         $('#menuList > ul > li, #shareLinks').fadeOut(100);
-    },
+    }
+    ,
 
     showMenuItems: function () {
         $('#menuList > ul > li, #shareLinks').fadeIn(300);
-    },
+    }
+    ,
 
     print: function (button) {
         this.stats.track(3);
         return this.openPDF(button, true);
-    },
+    }
+    ,
 
     downloadPDF: function (button) {
         this.stats.track(7);
         return this.openPDF(button, false)
-    },
+    }
+    ,
 
     openPDF: function (button, print) {
         var $this = this;
@@ -699,7 +729,8 @@ Fluidbook.prototype = {
         pdfName = e.pop();
 
         this._openFile(pdf, button, 'pdf', pdfName, print);
-    },
+    }
+    ,
 
     _openFile: function (url, e, type, localname, print) {
 
@@ -729,7 +760,8 @@ Fluidbook.prototype = {
                 w.print();
             }, 2000);
         }
-    },
+    }
+    ,
     _downloadFilePhonegap: function (url, localname, fs, callback, callbackArgs) {
         console.log('download file phonegap');
         var $this = this;
@@ -768,7 +800,8 @@ Fluidbook.prototype = {
         }, function () {
 
         });
-    },
+    }
+    ,
 
     _openFilePhonegap: function (url, e, type) {
         var $this = this;
@@ -859,19 +892,22 @@ Fluidbook.prototype = {
             return true;
         }
         return false;
-    },
+    }
+    ,
 
     relativeToAbsolute: function (relative) {
         var a = document.createElement('a');
         a.href = relative;
         return a.cloneNode(false).href;
-    },
+    }
+    ,
 
     alertInternetRequired: function () {
         navigator.notification.alert('', function () {
 
         }, this.l10n.__('an internet connection is required for this action'));
-    },
+    }
+    ,
 
     touchOffset: function (offset) {
         offset *= $("#currentDoublePage").width();
@@ -879,13 +915,15 @@ Fluidbook.prototype = {
         $("#currentDoublePage").css({
             translateX: offset
         });
-    },
+    }
+    ,
     displayLoader: function () {
         $("#loader").addClass('show');
         if (!this.support.isMobile) {
             $('body').addClass('loading');
         }
-    },
+    }
+    ,
 
     hideLoader: function (delay, force) {
         if (force == undefined) {
@@ -901,7 +939,8 @@ Fluidbook.prototype = {
         setTimeout(function () {
             $this._hideLoader(force);
         }, delay * 1000);
-    },
+    }
+    ,
 
     _hideLoader: function (force) {
         if (force == undefined) {
@@ -914,7 +953,8 @@ Fluidbook.prototype = {
         if (!this.support.isMobile) {
             $('body').removeClass('loading');
         }
-    },
+    }
+    ,
 
     wopen: function (url, target, options, print) {
         var win;
@@ -995,18 +1035,21 @@ Fluidbook.prototype = {
 
         }
         return w;
-    },
+    }
+    ,
 
     setFlag: function (name, value) {
         if (value === undefined) {
             value = true;
         }
         this.flags[name] = value;
-    },
+    }
+    ,
 
     hasFlag: function (name) {
         return this.flags[name] === true;
-    },
+    }
+    ,
 
     hasFlags: function (names) {
         var res = true;
@@ -1019,7 +1062,8 @@ Fluidbook.prototype = {
             return true;
         });
         return res;
-    },
+    }
+    ,
 
     pauseNetwork: function (during) {
         clearTimeout(this.networkPauseTimeout);
@@ -1034,7 +1078,8 @@ Fluidbook.prototype = {
             $this.networkPause = false;
             $this.flushNetworkQueue();
         }, during + 500)
-    },
+    }
+    ,
 
     executeWhenNetwork: function (f) {
         if (this.networkPause) {
@@ -1042,11 +1087,13 @@ Fluidbook.prototype = {
             return;
         }
         f();
-    },
+    }
+    ,
 
     unlockCurrentPage: function () {
         this.contentlock.unlockCurrentPage();
-    },
+    }
+    ,
 
     flushNetworkQueue: function () {
         if (this.networkPauseQueue.length === 0 || this.networkPause) {
@@ -1060,7 +1107,8 @@ Fluidbook.prototype = {
         setTimeout(function () {
             $this.flushNetworkQueue();
         }, 100);
-    },
+    }
+    ,
 
     bugreport: function (e) {
         if (window.confirm('An error occured: ' + e.name + '. Do you want to send a report ?')) {
@@ -1072,5 +1120,6 @@ Fluidbook.prototype = {
             }
             window.location = 'mailto:tech@fluidbook.com?subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(JSON.stringify(o));
         }
-    },
+    }
+    ,
 }