]> _ Git - fluidbook-html5.git/commitdiff
wip #1445 @5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 12 Jun 2017 15:16:09 +0000 (17:16 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 12 Jun 2017 15:16:09 +0000 (17:16 +0200)
images/cur-zoom-in.cur [new file with mode: 0644]
images/cur-zoom-out.cur [new file with mode: 0644]
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.links.js
js/libs/fluidbook/fluidbook.loader.js
js/libs/fluidbook/fluidbook.menu.js
js/libs/fluidbook/fluidbook.slider.js
js/libs/fluidbook/menu/fluidbook.index.js
style/fluidbook.less
style/slider.less

diff --git a/images/cur-zoom-in.cur b/images/cur-zoom-in.cur
new file mode 100644 (file)
index 0000000..a8359dc
Binary files /dev/null and b/images/cur-zoom-in.cur differ
diff --git a/images/cur-zoom-out.cur b/images/cur-zoom-out.cur
new file mode 100644 (file)
index 0000000..a3cf1f8
Binary files /dev/null and b/images/cur-zoom-out.cur differ
index a0f9c0819dd0304136a3258a4308f70b7f9fb86e..1c9847c44a6d6180169be9ffc69bbc21b61243df 100644 (file)
@@ -311,7 +311,6 @@ Fluidbook.prototype = {
             }
             this.menu.closeView(function () {
                 if (page != $this.currentPage) {
-                    console.log()
                     $this.pageTransition(page);
                     $this.stats.track(0, page);
                 }
index db986a5192fde3810bd6dbf3a85c5c4ae31752cd..33f6cea75e95235a0c9244125b3fe0a91815a5ef 100644 (file)
@@ -86,7 +86,6 @@ FluidbookLinks.prototype = {
 
         // If the interface is zoomed in, we must zoom out first
         if (this.fluidbook.zoom.zoom > 1) {
-            console.log('zooming out before opening zoom box');
             //currentScale = this.fluidbook.desktop.desktopScale; // Get current scale so the size of the popup can be calculated correctly
 
             // Wait for clickZoom out to finish before trying again to open zoom link
index 8162f4358ee7b238b4fe35cc9e999c21cd200b98..69751d334b541a298b665bb101a6312ee84c1246 100644 (file)
@@ -257,8 +257,9 @@ FluidbookLoader.prototype = {
         return $(img).get(0).outerHTML;
     },
     getThumbImage: function (page, div) {
+        var returnHTML = false;
         if (div == undefined) {
-            var div = $('<div />');
+            div = $('<div />');
         }
         var h = this.fluidbook.datas.thumbHeight;
         var s = Math.floor(page / 100);
@@ -273,8 +274,8 @@ FluidbookLoader.prototype = {
             backgroundImage: 'url("data/thumbnails/s' + s + '.jpg")',
             backgroundPositionX: -left,
             backgroundPositionY: -top
-        });
-        return div;
+        }).addClass('img');
+        return $(div).get(0).outerHTML;
     },
     loadImage: function (src, width, height, type, callback) {
         var img = new Image();
index 88f1134fa071f60bc52e554c8e8dc157a1929491..f9ba875c7c441ac4ca81ae7cf8796422364a2bdd 100644 (file)
@@ -524,7 +524,6 @@ FluidbookMenu.prototype = {
                 }
 
                 var s = Math.min(w / nw, h / nh);
-                console.log('scale : ' + s);
                 if (iframe.is('img')) {
                     s = Math.min(1, s);
                 }
index 51cc21b1105b187874f1f6138ed527e4d57d45e0..861b78a38450041dd915c7ca611a84bf6713da41 100644 (file)
@@ -9,7 +9,7 @@ function FluidbookSlider(fluidbook) {
 
 FluidbookSlider.prototype = {
     init: function () {
-        $("#interface").append('<div id="slider"><div id="sliderthumb"><div class="doubleThumb"><div class="thumb left"><a href="#"><img src=""></a><span class="number"></span><a href="#" class="bookmark left"></a></div><div class="thumb right"><a href="#"><img src="data/thumbnails/p3.jpg"></a><span class="number"></span><a href="#" class="bookmark right"></a></div></div></div><div id="sliderback"><div class="visible"></div></div><div id="slidercursor"><div class="visible"></div></div></div>');
+        $("#interface").append('<div id="slider"><div id="sliderthumb"><div class="doubleThumb"><div class="thumb left"><a href="#"><div class="img"></div></a><span class="number"></span><a href="#" class="bookmark left"></a></div><div class="thumb right"><a href="#"><div class="img"></div></a><span class="number"></span><a href="#" class="bookmark right"></a></div></div></div><div id="sliderback"><div class="visible"></div></div><div id="slidercursor"><div class="visible"></div></div></div>');
         var $this = this;
         $(this.fluidbook).on('fluidbook.page.change.end', function (e, page) {
             $this.updateCursorPosition();
@@ -56,12 +56,16 @@ FluidbookSlider.prototype = {
         if (gotoPage == undefined) {
             gotoPage = true;
         }
-
-        var page = Math.floor(pos / this.snapsWidth);
-        if (this.fluidbook.resize.orientation != 'portrait') {
-            page *= 2;
+        var page;
+        if (this.fluidbook.resize.orientation == 'portrait') {
+            page = Math.floor(pos / (this.sliderWidth / this.snapsCount)) + 1;
+            pageMin = 1;
+        } else {
+            page = Math.floor(pos / (this.sliderWidth / this.snapsCount)) * 2;
+            pageMin = 0;
         }
-        page = Math.min(this.fluidbook.datas.pages, Math.max(0, page));
+        
+        page = Math.min(this.fluidbook.datas.pages, Math.max(pageMin, page));
 
         if (gotoPage) {
             this.fluidbook.setCurrentPage(page);
@@ -89,25 +93,21 @@ FluidbookSlider.prototype = {
         $("#slider")
             .css({width: this.sliderWidth, left: (ww - this.sliderWidth) / 2, top: hh - bottom})
             .transform({scaleY: this.fluidbook.resize.interfaceScale});
+        $("#sliderthumb").transform({scaleX: this.fluidbook.resize.interfaceScale});
         this.updateSnaps(single);
-        this.cursorWidth = Math.max(30, this.snapsWidth);
+
         $("#slidercursor").css('width', this.cursorWidth);
         this.updateCursorPosition();
     },
 
     updateSnaps: function (single) {
-
         if (single) {
             this.snapsCount = this.fluidbook.datas.pages;
         } else {
-            var total = this.fluidbook.datas.pages;
-            if (total % 2 == 0) {
-                this.snapsCount = this.fluidbook.datas.pages / 2 + 1;
-            } else {
-                this.snapsCount = Math.ceil(this.fluidbook.datas.pages / 2);
-            }
+            this.snapsCount = Math.floor(this.fluidbook.datas.pages / 2) + 1;
         }
-        this.snapsWidth = this.sliderWidth / this.snapsCount;
+        this.cursorWidth = Math.max(30, this.sliderWidth / this.snapsCount);
+        this.snapsWidth = (this.sliderWidth - this.cursorWidth) / (this.snapsCount - 1);
     },
 
     updateCursorPosition: function (page) {
@@ -116,19 +116,17 @@ FluidbookSlider.prototype = {
         }
         var left;
         if (this.fluidbook.resize.orientation == 'portrait') {
-            left = this.snapsWidth * (Math.max(1, page) - 1);
+            left = this.snapsWidth * (page - 1);
         } else {
-            var current = page;
-            if (current % 2 == 1 && page != this.fluidbook.datas.pages) {
-                current--;
-            }
-            left = this.snapsWidth * (current / 2);
+            var current = Math.floor(page / 2);
+            left = this.snapsWidth * current;
         }
-        $("#slidercursor").css('left', left);
+        var x = Math.max(0, Math.min(left, this.sliderWidth - this.cursorWidth));
+        $("#slidercursor").css('left', x);
 
         if ($("#sliderthumb").is(':visible')) {
             this.updateThumb(page);
-            $("#sliderthumb").css('left', left + (this.cursorWidth / 2) - (230 / 2));
+            $("#sliderthumb").css('left', x + (this.cursorWidth / 2) - ($("#sliderthumb").outerWidth() / 2));
         }
     },
 
@@ -152,9 +150,9 @@ FluidbookSlider.prototype = {
         }
 
         if (single) {
-            $("#sliderthumb .doubleThumb").addClass('single');
+            $("#sliderthumb").addClass('single');
         } else {
-            $("#sliderthumb .doubleThumb").removeClass('single');
+            $("#sliderthumb").removeClass('single');
             if (left == 0 || right == 0) {
                 $("#sliderthumb .doubleThumb").addClass('simple');
                 if (left == 0) {
@@ -172,14 +170,17 @@ FluidbookSlider.prototype = {
         }
 
 
-        if (left != 0) {
-            var t=$("#sliderthumb .doubleThumb").find('.thumb.left');
-        }
-
-        if (right == 0) {
+        this.setThumb($("#sliderthumb .doubleThumb").find('.thumb.left'), left);
+        this.setThumb($("#sliderthumb .doubleThumb").find('.thumb.right'), right);
+    },
 
+    setThumb: function (thumb, page) {
+        if (page > 0 && page <= this.fluidbook.datas.pages) {
+            thumb.css('visibility', 'visible');
+            this.fluidbook.loader.getThumbImage(page, thumb.find('.img'));
+            thumb.find('.number').text(this.fluidbook.physicalToVirtual(page));
         } else {
-
+            thumb.css('visibility', 'hidden');
         }
-    },
-};
\ No newline at end of file
+    }
+};
index d66c02bd83d6f8d8b2dd837aa4ada7a5577bf82b..88d204237f9bca10ca193f31da06afba3b5f385d 100644 (file)
@@ -1,87 +1,87 @@
 function FluidbookIndex(fluidbook) {
-       this.fluidbook = fluidbook;
-       this.init();
+    this.fluidbook = fluidbook;
+    this.init();
 }
 
 FluidbookIndex.prototype = {
-       init: function() {
-               this.normalHTML = '';
-               this.padHTML = '';
-       },
-       getView: function(group) {
-               if (this.fluidbook.pad.enabled) {
-                       return this.getPadView(group);
-               } else {
-                       return this.getNormalView();
-               }
-       },
-       getPadView: function(group) {
-               return this.fluidbook.bookmarks.getIndex(true, group);
-       },
-       getNormalView: function() {
+    init: function () {
+        this.normalHTML = '';
+        this.padHTML = '';
+    },
+    getView: function (group) {
+        if (this.fluidbook.pad.enabled) {
+            return this.getPadView(group);
+        } else {
+            return this.getNormalView();
+        }
+    },
+    getPadView: function (group) {
+        return this.fluidbook.bookmarks.getIndex(true, group);
+    },
+    getNormalView: function () {
 
-               if (this.normalHTML == '') {
-                       this.normalHTML += '<div class="content"><div id="indexView">';
-                       var j = 0;
-                       var ix1 = '', ix2 = '', ix = '';
-                       var c = '';
-                       var s1, s2;
+        if (this.normalHTML == '') {
+            this.normalHTML += '<div class="content"><div id="indexView">';
+            var j = 0;
+            var ix1 = '', ix2 = '', ix = '';
+            var c = '';
+            var s1, s2;
 
-                       for (var i = 0; i <= this.fluidbook.datas.pages; i += 2) {
-                               var pages = [];
-                               j = i + 1;
-                               ix1 = '';
-                               ix2 = '';
-                               c = '';
+            for (var i = 0; i <= this.fluidbook.datas.pages; i += 2) {
+                var pages = [];
+                j = i + 1;
+                ix1 = '';
+                ix2 = '';
+                c = '';
 
-                               if (this.fluidbook.l10n.dir == 'ltr') {
-                                       s1 = 'left';
-                                       s2 = 'right'
-                               } else {
-                                       s1 = 'right';
-                                       s2 = 'left'
-                               }
+                if (this.fluidbook.l10n.dir == 'ltr') {
+                    s1 = 'left';
+                    s2 = 'right'
+                } else {
+                    s1 = 'right';
+                    s2 = 'left'
+                }
 
-                               if (i > 0) {
-                                       ix1 += '<div class="thumb ' + s1 + '"><a href="#/page/' + i + '">' + this.fluidbook.loader.getImage('data/thumbnails/p' + i + '.jpg') + '</a><span class="number">' + this.fluidbook.physicalToVirtual(i) + '</span>';
-                                       if (this.fluidbook.bookmarks.enabled) {
-                                               ix1 += this.fluidbook.bookmarks.getBookmarkForPage(i, true);
-                                       }
-                                       pages.push(i);
-                                       ix1 += '</div>';
+                if (i > 0) {
+                    ix1 += '<div class="thumb ' + s1 + '"><a href="#/page/' + i + '">' + this.fluidbook.loader.getThumbImage(i) + '</a><span class="number">' + this.fluidbook.physicalToVirtual(i) + '</span>';
+                    if (this.fluidbook.bookmarks.enabled) {
+                        ix1 += this.fluidbook.bookmarks.getBookmarkForPage(i, true);
+                    }
+                    pages.push(i);
+                    ix1 += '</div>';
 
-                               } else {
-                                       c = ' simple ' + s2;
-                               }
+                } else {
+                    c = ' simple ' + s2;
+                }
 
-                               if (this.fluidbook.l10n.dir == 'rtl') {
-                                       s1 = 'left';
-                                       s2 = 'right'
-                               } else {
-                                       s1 = 'right';
-                                       s2 = 'left'
-                               }
+                if (this.fluidbook.l10n.dir == 'rtl') {
+                    s1 = 'left';
+                    s2 = 'right'
+                } else {
+                    s1 = 'right';
+                    s2 = 'left'
+                }
 
-                               if (j < this.fluidbook.datas.pages) {
-                                       ix2 += '<div class="thumb ' + s1 + '"><a href="#/page/' + j + '">' + this.fluidbook.loader.getImage('data/thumbnails/p' + j + '.jpg') + '</a><span class="number">' + this.fluidbook.physicalToVirtual(j) + '</span>';
-                                       if (this.fluidbook.bookmarks.enabled) {
-                                               ix2 += this.fluidbook.bookmarks.getBookmarkForPage(j, true);
-                                       }
-                                       ix2 += '</div>';
-                                       pages.push(j);
-                               } else {
-                                       c = ' simple ' + s2;
-                               }
-                               ix = ix1 + ix2;
-                               this.normalHTML += '<div class="doubleThumb' + c + '" page="' + i + '" data-pages="' + pages.join(',') + '">' + ix;
-                               this.normalHTML += '</div>';
-                       }
-                       for (i = 0; i < 5; i++) {
-                               this.normalHTML += '<div class="padding"></div>';
-                       }
-                       this.normalHTML += '</div></div>';
-               }
+                if (j < this.fluidbook.datas.pages) {
+                    ix2 += '<div class="thumb ' + s1 + '"><a href="#/page/' + j + '">' + this.fluidbook.loader.getThumbImage(j) + '</a><span class="number">' + this.fluidbook.physicalToVirtual(j) + '</span>';
+                    if (this.fluidbook.bookmarks.enabled) {
+                        ix2 += this.fluidbook.bookmarks.getBookmarkForPage(j, true);
+                    }
+                    ix2 += '</div>';
+                    pages.push(j);
+                } else {
+                    c = ' simple ' + s2;
+                }
+                ix = ix1 + ix2;
+                this.normalHTML += '<div class="doubleThumb' + c + '" page="' + i + '" data-pages="' + pages.join(',') + '">' + ix;
+                this.normalHTML += '</div>';
+            }
+            for (i = 0; i < 5; i++) {
+                this.normalHTML += '<div class="padding"></div>';
+            }
+            this.normalHTML += '</div></div>';
+        }
 
-               return this.normalHTML;
-       }
+        return this.normalHTML;
+    }
 }
index 32a1f36e79622c9403e1da48bc2debdc987a08a2..1d0c8e4912c64fe9b43c357526afcf737eb5c939 100644 (file)
@@ -175,13 +175,11 @@ body, html {
 /* Desktop devices */
 
 .desktop #links {
-       cursor: url("../images/cur-zoom-in.png");
-       cursor: zoom-in;
+       cursor: url("images/cur-zoom-in.cur"), url("../images/cur-zoom-in.cur"), zoom-in;
 }
 
 .desktop.zoomed #links {
-       cursor: url("../images/cur-zoom-out.png");
-       cursor: zoom-out;
+       cursor: url("images/cur-zoom-out.cur"), url("../images/cur-zoom-out.cur"), zoom-out;
 }
 
 #links .link {
@@ -1019,8 +1017,8 @@ form input[type="text"], form input[type="email"] {
                                left: 50px;
                        }
                }
-
        }
+
        .overlay {
                background-color: rgba(0, 0, 0, 0.5);
                position: absolute;
@@ -1059,7 +1057,7 @@ form input[type="text"], form input[type="email"] {
        left: 0px;
        font-size: 12px;
 
-       img {
+       .img {
                width: 100px;
                height: @thumb-height;
                background: #fff;
index 78d56c43594d93786ca794116a9bb3c1219d2b27..720621be0f53c57534707a1610e0ee92a9b7291d 100644 (file)
@@ -1,3 +1,6 @@
+@slider-background: rgba(0, 0, 0, 0.1);
+@slider-thumb-background: rgba(0, 0, 0, 0.2);
+
 #slider {
        position: absolute;
        height: 6px;
@@ -20,8 +23,9 @@
        }
 
        &.drag {
-               z-index: 12;
+
        }
+       z-index: 12;
 
        #sliderback {
                position: absolute;
@@ -31,7 +35,7 @@
                z-index: 0;
                height: 46px;
                .visible {
-                       background-color: rgba(0, 0, 0, 0.1);
+                       background-color: @slider-background;
                }
        }
 
        }
 
        @sliderthumb-height: unit(@thumb-height+40, px);
-       @sliderthumb-top: unit(-1*(@sliderthumb-height+30), px);
+       @sliderthumb-top: unit(-1*(@sliderthumb-height+24), px);
 
        #sliderthumb {
                position: absolute;
                top: @sliderthumb-top;
                left: 0;
-               background-color: @menu-background;
-               padding: 10px;
+               background-color: @slider-thumb-background;
+               padding: 15px;
                //display: none;
                width: 230px;
                height: @sliderthumb-height;
+
+               &.single {
+                       width: 130px;
+                       &:after {
+                               left: 53px;
+                       }
+               }
+
+               &:after {
+                       content: "";
+                       position: absolute;
+                       bottom: -16px;
+                       left: 103px;
+                       width: 0;
+                       height: 0;
+                       border-left: 12px solid transparent;
+                       border-right: 12px solid transparent;
+                       border-top: 16px solid @slider-thumb-background;
+                       display: block;
+               }
+
+               .doubleThumb {
+                       position: relative;
+               }
+
+               .number {
+                       color: #fff;
+               }
        }
        &.drag {
                #sliderthumb {