]> _ Git - fluidbook-html5.git/commitdiff
wip #2132 @6
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 11 Jul 2018 15:46:13 +0000 (17:46 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 11 Jul 2018 15:46:13 +0000 (17:46 +0200)
js/libs/fluidbook/fluidbook.bookmarks.js
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.menu.js
js/libs/fluidbook/fluidbook.search.js
js/libs/fluidbook/fluidbook.slider.js
js/libs/fluidbook/menu/fluidbook.chapters.js
js/libs/fluidbook/menu/fluidbook.index.js
js/libs/scorm/scorm.js

index 01e26f6d1a8b6acc4534b3e4f42aa4183b316cad..3bb3efdd0dceefc1d64949a5df4a38c209392233 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.getMaxPage());
+        var to = Math.min(from + (nb - 1), this.fluidbook.pages);
         for (var i = from; i <= to; i++) {
             this._pagesToGroup[i] = this._groups;
         }
@@ -129,13 +129,15 @@ FluidbookBookmarks.prototype = {
         this._groups++;
     },
     completeGroups: function () {
-        for (var i = 1; i <= this.fluidbook.getMaxPage(); i++) {
+        for (var i = 1; i <= this.fluidbook.pages; i++) {
             if (this._pagesToGroup[i] == undefined || this._pagesToGroup[i] == null) {
                 this._pagesToGroup[i] = this._groups;
                 this._groupOrder.push(this._groups);
                 this._groups++;
             }
         }
+
+        console.log(this._pagesToGroup);
     },
     getPreviousGroup: function (group) {
         var o = this.getOrderGroup(group);
@@ -173,7 +175,7 @@ FluidbookBookmarks.prototype = {
     },
     getPagesOfGroup: function (groupId) {
         var res = [];
-        for (var i = 1; i <= this.fluidbook.getMaxPage(); i++) {
+        for (var i = 1; i <= this.fluidbook.pages; i++) {
             if (this._pagesToGroup[i] == groupId) {
                 res.push(i);
             }
@@ -269,6 +271,7 @@ FluidbookBookmarks.prototype = {
             cornersOnly = false;
         }
         var pages = this.getLinkedPages(page);
+        console.log(pages);
         for (i in pages) {
             var page = pages[i];
             if (!cornersOnly) {
index 13acf3e5a27ce4eaa7745413069713e04a885dbc..8b9f0618cd3e7faaa0044d7b1e28df000b3bcd2a 100644 (file)
@@ -90,7 +90,10 @@ Fluidbook.prototype = {
         }
         $('html').addClass(this.datas.mobileLVersion);
         this.currentPage = -1;
-        this.maxPage = this.getMaxPage();
+        this.maxPage = this.datas.pages;
+        if (this.datas.maxPages > 0) {
+            this.maxPage = Math.min(this.datas.maxPages, this.datas.pages);
+        }
 
         this.resize = new FluidbookResize(this);
         this.stats = new FluidbookStats(this);
@@ -101,7 +104,11 @@ Fluidbook.prototype = {
     },
 
     setMaxPage: function (p) {
-        this.maxPage = p;
+        if (p === undefined) {
+            p = this.datas.pages;
+        }
+
+        this.maxPage = Math.min(p, this.datas.pages);
         this.updateMaxPage();
     },
 
@@ -109,8 +116,14 @@ Fluidbook.prototype = {
         return this.maxPage;
     },
 
-    updateMaxPage() {
-
+    updateMaxPage: function () {
+        if (this.currentPage > this.maxPage) {
+            this.setCurrentPage(this.maxPage);
+        } else {
+            this.reloadCurrentPage();
+        }
+        this.hideUnnecessaryButtons();
+        resize();
     },
 
     initTheme: function () {
@@ -353,7 +366,7 @@ Fluidbook.prototype = {
                 this.transitionAxis = 'x';
             }
             if (page != $this.currentPage) {
-                $($this).trigger('changePage', [page]);
+                $($this).trigger('fluidbook.page.navigation', [page]);
             }
             if (this.landingpage !== undefined) {
                 this.landingpage.hide();
@@ -404,7 +417,6 @@ Fluidbook.prototype = {
         return;
     },
     pageTransition: function (pageNr) {
-
         $(this).trigger('fluidbook.beforePageTransition');
 
         this.tooltip.hideTooltip();
@@ -419,15 +431,12 @@ Fluidbook.prototype = {
         if (pageNr == this.normalizePage(this.currentPage) || this.currentPage == -1 || !this.support.transitions2d || this.datas.mobileTransitions == 'none') {
             return this.pageTransition1D(pageNr);
         }
-
         if (this.displayOnePage) {
             return this.pageTransition2DPortrait(pageNr);
         }
-
         if (!this.support.transitions3d || this.datas.mobileTransitions == 'slide') {
             return this.pageTransition2D(pageNr);
         }
-
         return this.pageTransition3D(pageNr);
     },
     pageTransition3D: function (pageNr) {
@@ -869,7 +878,12 @@ Fluidbook.prototype = {
         var $this = this;
         var pdf;
         var pdfName;
-        if (this.datas.pdfName.substr(0, 4) == 'http') {
+
+        console.log('open PDF : ' + this.datas.pages + " || " + this.getMaxPage());
+
+        if (this.datas.pages != this.getMaxPage()) {
+            pdf = 'https://workshop.fluidbook.com/s/e/' + this.datas.cid + '/1-' + this.getMaxPage();
+        } else if (this.datas.pdfName.substr(0, 4) == 'http') {
             pdf = this.datas.pdfName;
         } else {
             pdf = this.relativeToAbsolute('data/' + this.datas.pdfName);
index 9e42ce78e8fc12db83fd8c1c8ccc01c000330e05..873a347aee94faf4644e3fe4c73e30b69992c39c 100644 (file)
@@ -374,6 +374,7 @@ FluidbookMenu.prototype = {
         }
 
         $("#view").append('<div id="' + menuId + '" class="mview' + color + '" data-menu="chapters">' + view + '</div>');
+        this.fluidbook.chapters.removeItemsAfterMaxPage();
         if (callback != undefined) {
             callback();
         }
index e5e959c8c737fbd41763b273dd4ac71eaed0710b..7783e85010a8727de9b8f1f0afd20cdc8ec3fb84 100644 (file)
@@ -112,7 +112,7 @@ FluidbookSearch.prototype = {
         this.resultPages = [];
 
         var q, v, k, kk, word, wordata, page, occurences, p;
-
+        var maxPage = this.fluidbook.getMaxPage();
 
         for (kk in words) {
             q = words[kk];
@@ -133,6 +133,9 @@ FluidbookSearch.prototype = {
                 for (page in v.p) {
                     var occurences = v.p[page];
                     page = parseInt(page);
+                    if (page > maxPage) {
+                        continue;
+                    }
                     if ((page % 2) == 1) {
                         page--;
                     }
@@ -182,6 +185,7 @@ FluidbookSearch.prototype = {
         var terms = [];
         var total = 0;
         var doublesPages = [];
+        var maxPage = this.fluidbook.getMaxPage();
 
         for (var p in TEXTS) {
             var t = TEXTS[p];
@@ -197,6 +201,9 @@ FluidbookSearch.prototype = {
                 continue;
             }
             page = parseInt(p);
+            if (page > maxPage) {
+                continue;
+            }
             if ((page % 2) == 1) {
                 page--;
             }
@@ -425,10 +432,8 @@ FluidbookSearch.prototype = {
         });
     },
     displaySearchHints: function (hints) {
-
         var $this = this;
 
-        //this.hideSearchHints();
         if (hints.length == 0) {
             return;
         }
@@ -454,9 +459,6 @@ FluidbookSearch.prototype = {
         this.kill();
     },
     hideSearchHints: function () {
-        // this.killLastSearchHint();
-        // $("#searchHints").html('');
-        // $("#searchHints").hide();
         this.menuSearchHints.html('').hide(); // Clear and hide all hints
     },
 
index 229707040d88d62ccb472dca626dd0136e697a54..80a40603f037888be71415d66506a712d1bb20c1 100644 (file)
@@ -109,16 +109,15 @@ FluidbookSlider.prototype = {
         }
 
         return Math.min(this.fluidbook.getMaxPage(), Math.max(pageMin, page));
-
     },
 
     resize: function (ww, hh, single) {
-
         if (single) {
             this.sliderWidth = ww / 2;
         } else {
             this.sliderWidth = this.fluidbook.resize.getScreenFluidbookWidth() * 0.4;
         }
+
         this.sliderWidth = Math.round(this.sliderWidth);
         var bottom = 26;
         if (single) {
index 10b7b595e142457cc74c90eb5db2239bb6d88cfc..bbc8d5f21eb91b83052504befd10952afa8f5a77 100644 (file)
@@ -21,6 +21,7 @@ FluidbookChapters.prototype = {
         if (this.html[sub] == null) {
             this.makeView(sub);
         }
+
         return {sub: sub, view: this.html[sub], title: this.titles[sub], color: this.colors[sub]};
     },
     makeView: function (sub) {
@@ -143,9 +144,11 @@ FluidbookChapters.prototype = {
         var href;
         var level = chapter.level - baseLevel;
 
+        var p = '';
         if (chapter.page != '') {
-            var p = this.fluidbook.virtualToPhysical(chapter.page);
+            p = this.fluidbook.virtualToPhysical(chapter.page);
             if (p === false) {
+                p='';
                 href = this.cascade ? 'href="#"' : "nohref";
             } else {
                 href = 'href="#/page/' + p + '"';
@@ -154,9 +157,9 @@ FluidbookChapters.prototype = {
             href = this.cascade ? 'href="#"' : "nohref";
         }
         if (this.style == 'classic') {
-            res += '<li data-level="' + level + '"><a ' + href + ' class="level' + level + '">';
+            res += '<li data-level="' + level + '" data-page="' + p + '"><a ' + href + ' class="level' + level + '">';
         } else if (this.style == 'ina') {
-            res += '<li style="background-color:#' + color + ';" data-level="' + level + '"><a ' + href + ' class="nodark level' + level + '">';
+            res += '<li style="background-color:#' + color + ';" data-level="' + level + '" data-page="' + p + '"><a ' + href + ' class="nodark level' + level + '">';
         }
         res += '<span>' + chapter.label + '</span>';
         if (href != 'nohref') {
@@ -181,6 +184,28 @@ FluidbookChapters.prototype = {
         res += '</a></li>';
 
         return res;
-    }
+    },
+
+    removeItemsAfterMaxPage: function () {
+
+        var max = this.fluidbook.getMaxPage();
+        $('.mview[data-menu="chapters"] ul.chapters li[data-page]').each(function () {
+            var p = parseInt($(this).data('page'));
+            if (isNaN(p)) {
+                return;
+            }
+            if (p > max) {
+                $(this).remove();
+            }
+        });
+
+        for(var i=0;i<=10;i++) {
+            $('.mview[data-menu="chapters"] ul.chapters li[data-page=""]').each(function () {
+                if ($(this).find('ul li').length == 0) {
+                    $(this).remove();
+                }
+            });
+        }
+    },
 };
 
index 424d26e230002908930ad61774d1aa5069c3b91b..7badda997c9e2b0f0ee7a5e67f47d0bf955b6cc8 100644 (file)
@@ -8,6 +8,7 @@ FluidbookIndex.prototype = {
         this.normalHTML = '';
         this.padHTML = '';
     },
+
     getView: function (group) {
         if (this.fluidbook.pad.enabled) {
             return this.getPadView(group);
@@ -15,11 +16,12 @@ FluidbookIndex.prototype = {
             return this.getNormalView();
         }
     },
+
     getPadView: function (group) {
         return this.fluidbook.bookmarks.getIndex(true, group);
     },
-    getNormalView: function () {
 
+    getNormalView: function () {
         if (this.normalHTML == '') {
             this.normalHTML += '<div class="content"><div id="indexView">';
             var j = 0;
index 7c99737ef46d18bcab094d437125cd96ccc3470b..edd4a396b22c098eee190f7db881dab56d35d46b 100644 (file)
@@ -82,7 +82,7 @@ function initScormEvents() {
         console.log(err);
     }
 
-    $(fluidbook).on('changePage', function (e, page) {
+    $(fluidbook).on('fluidbook.page.navigation', function (e, page) {
         setScormValue('location', 'page_' + page);
     });