]> _ Git - fluidbook-html5.git/commitdiff
fix #2404 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 5 Dec 2018 15:09:49 +0000 (16:09 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 5 Dec 2018 15:09:49 +0000 (16:09 +0100)
js/libs/fluidbook/fluidbook.loader.js

index 1d910e4ae6cb9c8f4cb8a18c2ca5aa7c6955fb82..b4099665ab2e299e6721e104f42c5c5dbf5b9b88 100644 (file)
@@ -115,7 +115,7 @@ FluidbookLoader.prototype = {
 
         var $__callback = function () {
             if ($this.getVersionToLoad(page) === 'textasvector' || $this.getVersionToLoad(page) === 'vector') {
-                $this._loadTexts(page, $_callback);
+                $this.loadTexts(page, $_callback);
             } else {
                 $_callback();
             }
@@ -131,7 +131,7 @@ FluidbookLoader.prototype = {
             this.backgrounds[page] = null;
             $__callback();
         } else {
-            this.backgrounds[page] = this.loadImage(backgroundURL, null, null, null, function () {
+            this.backgrounds[page] = this.loadImage(backgroundURL, null, null, null, page, function () {
                 $__callback();
             });
         }
@@ -192,6 +192,8 @@ FluidbookLoader.prototype = {
         if (this.textures[page] !== undefined && this.textures[page] !== null) {
             delete this.textures[page];
         }
+
+        $("#loadedcontents [data-page='" + page + "']").remove();
     },
     setContentsInDoublePage: function (doublePage, pages, immediate, callback) {
         var $this = this;
@@ -312,11 +314,11 @@ FluidbookLoader.prototype = {
             callback();
             return;
         }
-        if (this.backgrounds[page] != undefined) {
+        if (this.backgrounds[page] !== undefined) {
             callback();
         } else {
             var $this = this;
-            if (window.gal != undefined && !OFFLINEAPP) {
+            if (window.gal !== undefined && !OFFLINEAPP) {
                 window.gal.downloadAndCall('content_' + page, function () {
                     $this.__loadBackground(page, callback);
                 }, 250);
@@ -335,7 +337,7 @@ FluidbookLoader.prototype = {
             callback();
             return false;
         }
-        this.backgrounds[page] = this.loadImage(url, null, null, null, callback);
+        this.backgrounds[page] = this.loadImage(url, null, null, null, page, callback);
     },
     loadTexture: function (page, callback) {
         if (page <= 0 || page > this.fluidbook.datas.pages) {
@@ -420,14 +422,14 @@ FluidbookLoader.prototype = {
             callback();
             return;
         }
-        if (this.getVersionToLoad(pageNr) == 'raster') {
+        if (this.getVersionToLoad(pageNr) === 'raster') {
             callback();
             return;
         }
 
         var $this = this;
 
-        if (this.texts[pageNr] != undefined) {
+        if (this.texts[pageNr] !== undefined) {
             $("#page_" + pageNr + ' .texts').append(this.texts[pageNr]);
             callback();
         } else {
@@ -442,9 +444,7 @@ FluidbookLoader.prototype = {
             callback();
             return;
         }
-        // var w = this.fluidbook.datas.width / 0.75;
-        // var h = this.fluidbook.datas.height / 0.75;
-        this.texts[pageNr] = this.loadImage(this.getTextsURL(pageNr), null, null, 'image/svg+xml', callback);
+        this.texts[pageNr] = this.loadImage(this.getTextsURL(pageNr), null, null, 'image/svg+xml', pageNr, callback);
     },
     loadDatas: function (pageNr, callback) {
         var $this = this;
@@ -453,7 +453,7 @@ FluidbookLoader.prototype = {
         });
     },
     getImage: function (src, width, height, type, callback) {
-        var img = this.loadImage(src, width, height, type, callback);
+        var img = this.loadImage(src, width, height, type, null, callback);
         return $(img).get(0).outerHTML;
     },
     getThumbImage: function (page, div, shade, width) {
@@ -511,7 +511,7 @@ FluidbookLoader.prototype = {
         }).addClass('img');
         return $(div).get(0).outerHTML;
     },
-    loadImage: function (src, width, height, type, cb) {
+    loadImage: function (src, width, height, type, page, cb) {
         var $this = this;
         var callback = function () {
             if (cb && typeof cb == 'function') {
@@ -522,11 +522,6 @@ FluidbookLoader.prototype = {
                     }
                 }, 10)
             }
-            setTimeout(function () {
-                $this.fluidbook.executeWhenNetwork(function () {
-                    $("#loadedcontents").find('[src="' + src + '"]').remove();
-                });
-            }, 30000);
         }
 
         if (src === false) {
@@ -558,9 +553,11 @@ FluidbookLoader.prototype = {
         if (img.complete || img.readyState === 'complete' || img.readyState === 4) {
             callback();
         }
-
         var res = $(img);
-        $("#loadedcontents").append(res);
+        if (page !== null) {
+            $(res).attr('data-page', page);
+            $("#loadedcontents").append(res);
+        }
         return res;
     },
     retryErrorImages: function () {