]> _ Git - fluidbook-html5.git/commitdiff
wip #2132 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 10 Jul 2018 17:41:02 +0000 (19:41 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 10 Jul 2018 17:41:02 +0000 (19:41 +0200)
js/libs/fluidbook/fluidbook.bookmarks.js
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.loader.js
js/libs/fluidbook/fluidbook.search.js
js/libs/fluidbook/fluidbook.slider.js
js/libs/fluidbook/fluidbook.sound.js
js/libs/fluidbook/forms/fluidbook.form.bourbon.js
js/libs/fluidbook/menu/fluidbook.index.js

index b4a9537b655dd9251a938bff36b259232bcf252e..01e26f6d1a8b6acc4534b3e4f42aa4183b316cad 100644 (file)
@@ -120,7 +120,7 @@ FluidbookBookmarks.prototype = {
         return g.join(',');
     },
     addGroup: function (from, nb, name) {
-        var to = Math.min(from + (nb - 1), this.fluidbook.datas.pages);
+        var to = Math.min(from + (nb - 1), this.fluidbook.getMaxPage());
         for (var i = from; i <= to; i++) {
             this._pagesToGroup[i] = this._groups;
         }
@@ -129,7 +129,7 @@ FluidbookBookmarks.prototype = {
         this._groups++;
     },
     completeGroups: function () {
-        for (var i = 1; i <= this.fluidbook.datas.pages; i++) {
+        for (var i = 1; i <= this.fluidbook.getMaxPage(); i++) {
             if (this._pagesToGroup[i] == undefined || this._pagesToGroup[i] == null) {
                 this._pagesToGroup[i] = this._groups;
                 this._groupOrder.push(this._groups);
@@ -173,7 +173,7 @@ FluidbookBookmarks.prototype = {
     },
     getPagesOfGroup: function (groupId) {
         var res = [];
-        for (var i = 1; i <= this.fluidbook.datas.pages; i++) {
+        for (var i = 1; i <= this.fluidbook.getMaxPage(); i++) {
             if (this._pagesToGroup[i] == groupId) {
                 res.push(i);
             }
@@ -191,7 +191,7 @@ FluidbookBookmarks.prototype = {
         var res = [];
         var nb;
         var groupId;
-        for (var i = 1; i <= this.fluidbook.datas.pages;) {
+        for (var i = 1; i <= this.fluidbook.getMaxPage();) {
             if (this.isBookmarked(i) || !onlyBookmarked) {
                 groupId = this.getGroupOfPage(i);
                 nb = this.getPagesNumberInGroup(groupId);
@@ -351,7 +351,7 @@ FluidbookBookmarks.prototype = {
 
         var bookmarks = "";
         for (var i = pageNr; i <= to; i++) {
-            if (i > 0 && i <= this.fluidbook.datas.pages) {
+            if (i > 0 && i <= this.fluidbook.getMaxPage()) {
                 var side;
                 if (allwaysAtRight) {
                     side = 'right';
index 5359ecccbc06cca799636a0ed7e734c3830088b5..13acf3e5a27ce4eaa7745413069713e04a885dbc 100644 (file)
@@ -58,7 +58,7 @@ Fluidbook.prototype = {
         this.sound = new FluidbookSound(this);
         this.slideshow = new FluidbookSlideshow(this);
 
-        if(this.datas.basket) {
+        if (this.datas.basket) {
             this.cart = new FluidbookCart(this);
         }
         if (this.datas.form == 'bulle') {
@@ -90,6 +90,8 @@ Fluidbook.prototype = {
         }
         $('html').addClass(this.datas.mobileLVersion);
         this.currentPage = -1;
+        this.maxPage = this.getMaxPage();
+
         this.resize = new FluidbookResize(this);
         this.stats = new FluidbookStats(this);
         this.stats.track(10);
@@ -97,6 +99,20 @@ Fluidbook.prototype = {
         this.initTheme();
         this.initKeyboardShortcuts();
     },
+
+    setMaxPage: function (p) {
+        this.maxPage = p;
+        this.updateMaxPage();
+    },
+
+    getMaxPage: function () {
+        return this.maxPage;
+    },
+
+    updateMaxPage() {
+
+    },
+
     initTheme: function () {
         if (this.datas.arrowsTheme) {
             $('html').addClass('sharp');
@@ -251,7 +267,7 @@ Fluidbook.prototype = {
             return;
         }
         this.transitionAxis = 'x';
-        this.setCurrentPage(this.datas.pages);
+        this.setCurrentPage(this.getMaxPage());
     },
     goNextChapter: function () {
         if (this.transitionning) {
@@ -300,7 +316,7 @@ Fluidbook.prototype = {
         this.setCurrentPage(this.normalizePage(prev));
     },
     normalizePage: function (page) {
-        page = Math.max(1, Math.min(page, this.datas.pages));
+        page = Math.max(1, Math.min(page, this.getMaxPage()));
         if (!this.displayOnePage && page % 2 == 1) {
             page--;
         }
@@ -315,7 +331,7 @@ Fluidbook.prototype = {
         var args = window.location.hash.split('/');
 
         if (args.length <= 1 || args[1] == '' || args[1] == undefined) {
-            if (this.landingpage!==undefined && this.landingpage.hasLandingPage) {
+            if (this.landingpage !== undefined && this.landingpage.hasLandingPage) {
                 window.location.hash = '/landing';
                 return;
             }
@@ -339,7 +355,7 @@ Fluidbook.prototype = {
             if (page != $this.currentPage) {
                 $($this).trigger('changePage', [page]);
             }
-            if(this.landingpage!==undefined) {
+            if (this.landingpage !== undefined) {
                 this.landingpage.hide();
             }
             this.menu.closeView(function () {
@@ -354,7 +370,7 @@ Fluidbook.prototype = {
 
         else if (args[1] == 'landing') {
             $this.hideSplash();
-            if(this.landingpage!==undefined) {
+            if (this.landingpage !== undefined) {
                 this.landingpage.show();
             }
         }
@@ -538,7 +554,7 @@ Fluidbook.prototype = {
         if (center) {
             if (newPage <= 1) {
                 res.center = -1;
-            } else if (this.datas.pages % 2 == 0 && newPage == this.datas.pages) {
+            } else if (this.getMaxPage() % 2 == 0 && newPage == this.getMaxPage()) {
                 res.center = 1;
             }
         }
@@ -585,7 +601,7 @@ Fluidbook.prototype = {
                 $("#previous").removeClass('hidden');
             }
 
-            if (page >= this.datas.pages) {
+            if (page >= this.getMaxPage()) {
                 $("#next").addClass('hidden');
             } else {
                 $("#next").removeClass('hidden');
@@ -598,7 +614,7 @@ Fluidbook.prototype = {
                 $("#previous:hidden").fadeIn(speed);
             }
 
-            if (page >= this.datas.pages) {
+            if (page >= this.getMaxPage()) {
                 $("#next:visible").fadeOut(speed);
             } else {
                 $("#next:hidden").fadeIn(speed);
@@ -623,9 +639,9 @@ Fluidbook.prototype = {
         if (this.displayOnePage) {
             right = true;
         } else {
-            if ((page <= 1 && this.l10n.dir == 'ltr') || (page >= this.datas.pages && this.l10n.dir == 'rtl')) {
+            if ((page <= 1 && this.l10n.dir == 'ltr') || (page >= this.getMaxPage() && this.l10n.dir == 'rtl')) {
                 left = false;
-            } else if ((page <= 1 && this.l10n.dir == 'rtl') || (page >= this.datas.pages && this.l10n.dir == 'ltr')) {
+            } else if ((page <= 1 && this.l10n.dir == 'rtl') || (page >= this.getMaxPage() && this.l10n.dir == 'ltr')) {
                 right = false;
             }
         }
@@ -758,7 +774,7 @@ Fluidbook.prototype = {
         }
         this.transitionning = false;
         if (this.pad.enabled) {
-            if (this.currentPage == this.datas.pages) {
+            if (this.currentPage == this.getMaxPage()) {
                 $("#down").css('opacity', 0);
             } else {
                 $("#down").css('opacity', 1);
index 4c23141d8ea26842f9aaadc0700f2d4bac0f4af7..724df37df84680652f650c40abc4289df9743ef1 100644 (file)
@@ -30,7 +30,7 @@ FluidbookLoader.prototype = {
 
         var $callback = callback;
         var $page = $pages.shift();
-        if ($page > this.fluidbook.datas.pages || $page < 1) {
+        if ($page > this.fluidbook.getMaxPage() || $page < 1) {
             $this.preloadPagesBeforeTransition($pages, $callback);
             return;
         }
@@ -91,7 +91,7 @@ FluidbookLoader.prototype = {
             numPreloadAfter = 3;
             numPreloadBefore = 1;
         }
-        var max = Math.min(page + numPreloadAfter, this.fluidbook.datas.pages);
+        var max = Math.min(page + numPreloadAfter, this.fluidbook.getMaxPage());
         var min = Math.max(1, page - numPreloadBefore);
         this.toPreload = [];
         for (var i = min; i <= max; i++) {
@@ -102,7 +102,7 @@ FluidbookLoader.prototype = {
         this.preloadPages();
     },
     cleanPreloaded: function () {
-        for (var i = 1; i <= this.fluidbook.datas.pages; i++) {
+        for (var i = 1; i <= this.fluidbook.getMaxPage(); i++) {
             if (this.backgrounds[i] != undefined && this.toPreload.indexOf(i) == -1) {
                 this.deletePage(i);
             }
@@ -188,7 +188,7 @@ FluidbookLoader.prototype = {
         return this.loadImage('images/shadows/pages/' + position + '.png', this.fluidbook.datas.width / 4, this.fluidbook.datas.height);
     },
     loadLeftPage: function (page, doublePage, callback) {
-        if (page > 0 && page <= this.fluidbook.datas.pages) {
+        if (page > 0 && page <= this.fluidbook.getMaxPage()) {
             this.loadPage(page, doublePage, 'left', callback);
         } else {
             $(doublePage).find('.left').remove();
@@ -196,7 +196,7 @@ FluidbookLoader.prototype = {
         }
     },
     loadRightPage: function (page, doublePage, callback) {
-        if (!this.fluidbook.displayOnePage && page <= this.fluidbook.datas.pages && page > 0) {
+        if (!this.fluidbook.displayOnePage && page <= this.fluidbook.getMaxPage() && page > 0) {
             this.loadPage(page, doublePage, 'right', callback);
         } else {
             $(doublePage).find('.right').remove();
index 3a607970e22fe903348a78f749bda11416f10466..e5e959c8c737fbd41763b273dd4ac71eaed0710b 100644 (file)
@@ -333,7 +333,7 @@ FluidbookSearch.prototype = {
             }
             pageNrs.push(pageNr);
             pageNr++;
-            if (pageNr < this.fluidbook.datas.pages) {
+            if (pageNr < this.fluidbook.getMaxPage()) {
                 pageNrs.push(pageNr);
             }
         }
@@ -512,7 +512,7 @@ FluidbookSearch.prototype = {
         var hits = [];
 
         // Create a list of all pages so we can record which ones have a hit on the search term
-        for (var i = 0; i <= this.fluidbook.datas.pages; i++) {
+        for (var i = 0; i <= this.fluidbook.getMaxPage(); i++) {
             hits[i] = 0;
         }
         // Map result hits to pages
index 04e431435e6ed2ed503873ad0f99e3c7381b8568..229707040d88d62ccb472dca626dd0136e697a54 100644 (file)
@@ -108,7 +108,7 @@ FluidbookSlider.prototype = {
             pageMin = 0;
         }
 
-        return Math.min(this.fluidbook.datas.pages, Math.max(pageMin, page));
+        return Math.min(this.fluidbook.getMaxPage(), Math.max(pageMin, page));
 
     },
 
@@ -138,9 +138,9 @@ FluidbookSlider.prototype = {
 
     updateSnaps: function (single) {
         if (single) {
-            this.snapsCount = this.fluidbook.datas.pages;
+            this.snapsCount = this.fluidbook.getMaxPage();
         } else {
-            this.snapsCount = Math.floor(this.fluidbook.datas.pages / 2) + 1;
+            this.snapsCount = Math.floor(this.fluidbook.getMaxPage() / 2) + 1;
         }
         this.cursorWidth = Math.max(30, this.sliderWidth / this.snapsCount);
         this.snapsWidth = (this.sliderWidth - this.cursorWidth) / (this.snapsCount - 1);
@@ -165,7 +165,7 @@ FluidbookSlider.prototype = {
     getCursorXByPage: function (page) {
         var left;
         if (this.fluidbook.l10n.rtl) {
-            page = this.fluidbook.datas.pages - page;
+            page = this.fluidbook.getMaxPage() - page;
         }
         if (this.fluidbook.resize.orientation == 'portrait') {
             left = this.snapsWidth * (page - 1);
@@ -190,7 +190,7 @@ FluidbookSlider.prototype = {
             if (page > 0) {
                 left = page;
             }
-            if (page <= this.fluidbook.datas.pages) {
+            if (page <= this.fluidbook.getMaxPage()) {
                 right = page + 1;
             }
         }
@@ -230,7 +230,7 @@ FluidbookSlider.prototype = {
 
     setThumb: function (thumb, page, shade) {
         thumb.find('.bookmark').attr('data-page', page);
-        if (page > 0 && page <= this.fluidbook.datas.pages) {
+        if (page > 0 && page <= this.fluidbook.getMaxPage()) {
             thumb.css('visibility', 'visible');
             this.fluidbook.loader.getThumbImage(page, thumb.find('.img'), shade);
             thumb.find('a').attr('href', '#/page/' + page);
index 0c6b73f7c65424904d67546043bd9e4cdd14232b..63a4d50ab55a2f12d89f830505f02aebef4d5965 100644 (file)
@@ -80,7 +80,7 @@ FluidbookSound.prototype = {
             page--;
         }
 
-        var last = this.fluidbook.datas.pages;
+        var last = this.fluidbook.getMaxPage();
         if (last % 2 == 1) {
             last++;
         }
index 20b31e6bbfede1bea3fc0136f06bc7556ca24c77..b2292a486e26c96545043464e3f2bfcab67e6f52 100644 (file)
@@ -26,7 +26,7 @@ FluidbookBourbonForm.prototype = {
         view += '<form class="cart-bourbon-suggest" action="" method="post">';
         view += '<div>';
         view += '<label>Page number';
-        view += '<input type="text" id="bourbon-suggestion-page" data-parsley-type="integer" name="page" value="' + this.fluidbook.currentPage + '" min="0" max="' + this.fluidbook.datas.pages + '" tabindex="100" required>';
+        view += '<input type="text" id="bourbon-suggestion-page" data-parsley-type="integer" name="page" value="' + this.fluidbook.currentPage + '" min="0" max="' + this.fluidbook.getMaxPage() + '" tabindex="100" required>';
         view += '</label>';
         view += '<label>Suggestion type';
         view += '<select id="bourbon-suggestion-type"><option>TYPO / WORDING</option><option>CLARIFICATION REQUEST</option><option>IMPROVEMENT SUGGESTION (Gaps, Ideas, etc)</option></select>';
index 8a2232d6446b33810f8d4ba5017e7b26781779b7..424d26e230002908930ad61774d1aa5069c3b91b 100644 (file)
@@ -27,7 +27,7 @@ FluidbookIndex.prototype = {
             var c = '';
             var s1, s2;
 
-            for (var i = 0; i <= this.fluidbook.datas.pages; i += 2) {
+            for (var i = 0; i <= this.fluidbook.getMaxPage(); i += 2) {
                 var pages = [];
                 j = i + 1;
                 ix1 = '';
@@ -62,7 +62,7 @@ FluidbookIndex.prototype = {
                     s2 = 'left'
                 }
 
-                if (j <= this.fluidbook.datas.pages) {
+                if (j <= this.fluidbook.getMaxPage()) {
                     ix2 += '<div class="thumb ' + s1 + '"><a href="#/page/' + j + '">' + this.fluidbook.loader.getThumbImage(j, null, true) + '</a><span class="number">' + this.fluidbook.physicalToVirtual(j) + '</span>';
                     if (this.fluidbook.bookmarks.enabled) {
                         ix2 += this.fluidbook.bookmarks.getBookmarkForPage(j, true);