]> _ Git - fluidbook-html5.git/commitdiff
#901
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 12 Jun 2017 13:42:08 +0000 (15:42 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 12 Jun 2017 13:42:08 +0000 (15:42 +0200)
js/libs/fluidbook/fluidbook.loader.js

index fb5d3740ed826174d7c2f2191e13a6fb1e64d643..8162f4358ee7b238b4fe35cc9e999c21cd200b98 100644 (file)
@@ -256,6 +256,26 @@ FluidbookLoader.prototype = {
         var img = this.loadImage(src, width, height, type, callback);
         return $(img).get(0).outerHTML;
     },
+    getThumbImage: function (page, div) {
+        if (div == undefined) {
+            var div = $('<div />');
+        }
+        var h = this.fluidbook.datas.thumbHeight;
+        var s = Math.floor(page / 100);
+        var row = Math.floor((page - 1) / 10);
+        var col = (page - 1) % 10;
+        if (col < 0) {
+            col += 10;
+        }
+        var left = col * 100;
+        var top = row * h;
+        $(div).css({
+            backgroundImage: 'url("data/thumbnails/s' + s + '.jpg")',
+            backgroundPositionX: -left,
+            backgroundPositionY: -top
+        });
+        return div;
+    },
     loadImage: function (src, width, height, type, callback) {
         var img = new Image();
         var $this = this;