]> _ Git - fluidbook-html5.git/commitdiff
#fluidbook_apps : fix zoom problem in ios
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 16 Dec 2015 09:57:03 +0000 (09:57 +0000)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 16 Dec 2015 09:57:03 +0000 (09:57 +0000)
fix problem with multimedia links to visibles on background

_index.html
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.nav.js
js/libs/fluidbook/fluidbook.touch.js
js/libs/fluidbook/fluidbook.viewport.js
style/fluidbook.css

index fc88196b33c5aee189768fb8955e9299465e0fb2..04f6051a18db09d787ef7de53a092493f2515ad4 100644 (file)
@@ -3,7 +3,6 @@
 <head>
        <title><!-- $titre --></title>
        <meta charset="utf-8">
-       <meta name="HandheldFriendly" content="True">
        <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=IE8">
        <meta http-equiv="Content-Security-Policy"
              content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
index 27a7c0aa0ce04a2b3b9f58513f9a4620f8fac5a2..f3ee6fcdb2a13f3836b108df2645202317391802 100644 (file)
@@ -31,7 +31,8 @@ Fluidbook.prototype = {
             this.touch = new FluidbookTouch(this);
         }
         this.background = new FluidbookBackground(this);
-        this.viewport = new FluidbookViewport(this.support)
+        this.viewport = new FluidbookViewport();
+        this.viewport.updateViewport();
         this.l10n = new FluidbookL10N(this, $_GET['lang']);
         this.video = new FluidbookVideo(this);
         this.bookmarks = new FluidbookBookmarks(this);
@@ -62,7 +63,6 @@ Fluidbook.prototype = {
         else {
             $("body").addClass('desktop');
         }
-
         if (this.pad.enabled) {
             $("body").addClass('pad');
         }
index d3236edc1069aa7a79f9425d63338e72c3e715f5..57df132fa3996aca9ddefba38e7a58459d8a3a61 100644 (file)
@@ -90,6 +90,7 @@ FluidbookNav.prototype = {
                 }
                 try {
                     if (homeURL != '') {
+                        fb('app home : ' + window.localStorage.getItem('apphome'))
                         this.addLink('nav-home', window.localStorage.getItem('apphome'), 'home', 'home');
                     }
                 } catch (err) {
index 6c64b34a837313b845a77f28b076844de335aca5..9c9144793b0e6470a0fcb87df3427efd18fd5cf8 100644 (file)
 function FluidbookTouch(fluidbook) {
-       this.fluidbook = fluidbook;
-       this.scale = 1;
+    this.fluidbook = fluidbook;
+    this.scale = 1;
 
-       this.startX = 0;
-       this.startY = 0;
-       this.offsetX = 0;
-       this.offsetY = 0;
+    this.startX = 0;
+    this.startY = 0;
+    this.offsetX = 0;
+    this.offsetY = 0;
 
-       this.triggerOffset = 0.05;
-       this.triggered = false;
-       this.gesturing = false;
+    this.triggerOffset = 0.05;
+    this.triggered = false;
+    this.gesturing = false;
 
-       this.init();
+    this.init();
 }
 
 FluidbookTouch.prototype = {
-       init: function() {
-               this.reset();
-
-               $(document).on('touchstart', $.proxy(this.start, this));
-               $(document).on('touchend', $.proxy(this.end, this));
-               $(document).on('touchmove', $.proxy(this.move, this));
-               $(document).on('touchcancel', $.proxy(this.cancel, this));
-               $(document).on('gesturestart', $.proxy(this.gesturestart, this));
-               $(document).on('gesturechange', $.proxy(this.gesturechange, this));
-               $(document).on('gestureend', $.proxy(this.gestureend, this));
-
-               $(document).on('MSPointerDown', $.proxy(this.msdown, this));
-               $(document).on('MSPointerUp', $.proxy(this.msup, this));
-               $(document).on('MSPointerMove', $.proxy(this.msmove, this));
-       },
-       msdown: function(event) {
-               var e = event.originalEvent;
-               if (e.pointerType != e.MSPOINTER_TYPE_TOUCH) {
-                       return true;
-               }
-               this._start(e.screenX, e.screenY);
-               return true;
-       },
-       msup: function(event) {
-               var e = event.originalEvent;
-               if (e.pointerType != e.MSPOINTER_TYPE_TOUCH) {
-                       return true;
-               }
-               this._end();
-       },
-       msmove: function(event) {
-               var e = event.originalEvent;
-               if (e.pointerType != e.MSPOINTER_TYPE_TOUCH) {
-                       return true;
-               }
-               return this._move(e.screenX, e.screenY);
-       },
-       allowMove: function() {
-               return !(this.fluidbook.support.getZoomLevel() <= 1 && !this.fluidbook.viewMode());
-       },
-       allowSlide: function() {
-               return !(this.gesturing || this.fluidbook.support.getZoomLevel() > 1 || this.fluidbook.viewMode() || this.fluidbook.help.isVisible());
-       },
-       reset: function() {
-               this.startX = 0;
-               this.startY = 0;
-               this.offsetX = 0;
-               this.offsetY = 0;
-               this.triggered = false;
-       },
-       gesturestart: function(event) {
-               if (this.fluidbook.pad.enabled) {
-                       return false;
-               }
-               var e = event.originalEvent;
-               this.enableUserScale();
-               this.gesturing = true;
-               return true;
-       },
-       gesturechange: function(event) {
-               if (this.fluidbook.pad.enabled) {
-                       return false;
-               }
-               var e = event.originalEvent;
-               this.gesturing = true;
-               return true;
-       },
-       gestureend: function(event) {
-               if (this.fluidbook.pad.enabled) {
-                       return false;
-               }
-
-               var e = event.originalEvent;
-               this.gesturing = false;
-
-               if (DetectZoom.zoom() > 1) {
-                       $('html').addClass('nopan');
-               } else {
-                       $('html').removeClass('nopan');
-               }
-               return true;
-       },
-       start: function(event) {
-               var e = event.originalEvent;
-               var touches = e.touches;
-
-               if (touches.length > 1) {
-                       this.enableUserScale();
-                       return true;
-               }
-
-               this._start(touches[0].pageX, touches[0].pageY);
-               return true;
-       },
-       end: function(event) {
-               var e = event.originalEvent;
-               var touches = e.touches;
-
-               if (touches.length == 0) {
-                       this._end();
-               }
-               return true;
-       },
-       testOffset: function() {
-               if (this.triggered) {
-                       return false;
-               }
-               if (this.allowMove()) {
-                       return false;
-               }
-               if (!this.fluidbook.pad.enabled) {
-                       if (Math.abs(this.offsetX) < Math.abs(this.offsetY)) {
-                               return false;
-                       }
-                       if (this.allowSlide()) {
-                               if (this.offsetX < -this.triggerOffset) {
-                                       if (this.fluidbook.l10n.dir == 'ltr') {
-                                               this.fluidbook.goNextPage();
-                                       } else {
-                                               this.fluidbook.goPreviousPage();
-                                       }
-
-                                       return true;
-                               } else if (this.offsetX > this.triggerOffset) {
-                                       if (this.fluidbook.l10n.dir == 'ltr') {
-                                               this.fluidbook.goPreviousPage();
-                                       } else {
-                                               this.fluidbook.goNextPage();
-                                       }
-                                       return true;
-                               }
-                       }
-               } else {
-                       // Mode mag pad
-                       if (this.allowSlide()) {
-                               var offset = this.offsetX;
-                               var way = 'x';
-                               if (Math.abs(this.offsetX) < Math.abs(this.offsetY)) {
-                                       offset = this.offsetY;
-                                       way = 'y';
-                               }
-
-                               if (Math.abs(offset) < this.triggerOffset) {
-                                       return false;
-                               }
-
-                               if (offset < -this.triggerOffset) {
-                                       if (way == 'x') {
-                                               this.fluidbook.goNextChapter();
-                                       } else {
-                                               this.fluidbook.goNextChapterPage();
-                                       }
-                               } else {
-                                       if (way == 'x') {
-                                               this.fluidbook.goPreviousChapter();
-                                       } else {
-                                               this.fluidbook.goPreviousChapterPage();
-                                       }
-                               }
-                               return true;
-                       }
-               }
-               return false;
-       },
-       cancel: function(event) {
-               this.end(event);
-               return true;
-       },
-       move: function(event) {
-               var e = event.originalEvent;
-
-               var touches = e.touches;
-
-               if (touches.length > 1) {
-                       return true;
-               }
-
-               return this._move(touches[0].pageX, touches[0].pageY);
-       },
-       _start: function(x, y) {
-               this.startX = x;
-               this.startY = y;
-       },
-       _move: function(x, y) {
-               if (!isNaN(this.startX)) {
-                       this.offsetX = (x - this.startX) / $(window).width();
-               }
-
-               if (!isNaN(this.startY)) {
-                       this.offsetY = (y - this.startY) / $(window).height();
-               }
-
-               this.testOffset();
-               return this.allowMove();
-       },
-       _end: function() {
-               this.testOffset();
-               this.reset();
-       },
-       enableUserScale: function() {
-               if (this.fluidbook.pad.enabled) {
-                       this.fluidbook.viewport.maxScale = 1;
-                       this.fluidbook.viewport.userScalable = false;
-               } else {
-                       this.fluidbook.viewport.maxScale = 3;
-                       this.fluidbook.viewport.userScalable = true;
-               }
-               this.fluidbook.viewport.updateViewport();
-       }
+    init: function () {
+        this.reset();
+
+        $(document).on('touchstart', $.proxy(this.start, this));
+        $(document).on('touchend', $.proxy(this.end, this));
+        $(document).on('touchmove', $.proxy(this.move, this));
+        $(document).on('touchcancel', $.proxy(this.cancel, this));
+        $(document).on('gesturestart', $.proxy(this.gesturestart, this));
+        $(document).on('gesturechange', $.proxy(this.gesturechange, this));
+        $(document).on('gestureend', $.proxy(this.gestureend, this));
+
+        $(document).on('MSPointerDown', $.proxy(this.msdown, this));
+        $(document).on('MSPointerUp', $.proxy(this.msup, this));
+        $(document).on('MSPointerMove', $.proxy(this.msmove, this));
+    },
+    msdown: function (event) {
+        var e = event.originalEvent;
+        if (e.pointerType != e.MSPOINTER_TYPE_TOUCH) {
+            return true;
+        }
+        this._start(e.screenX, e.screenY);
+        return true;
+    },
+    msup: function (event) {
+        var e = event.originalEvent;
+        if (e.pointerType != e.MSPOINTER_TYPE_TOUCH) {
+            return true;
+        }
+        this._end();
+    },
+    msmove: function (event) {
+        var e = event.originalEvent;
+        if (e.pointerType != e.MSPOINTER_TYPE_TOUCH) {
+            return true;
+        }
+        return this._move(e.screenX, e.screenY);
+    },
+    allowMove: function () {
+        return !(this.fluidbook.support.getZoomLevel() <= 1 && !this.fluidbook.viewMode());
+    },
+    allowSlide: function () {
+        return !(this.gesturing || this.fluidbook.support.getZoomLevel() > 1 || this.fluidbook.viewMode() || this.fluidbook.help.isVisible());
+    },
+    reset: function () {
+        this.startX = 0;
+        this.startY = 0;
+        this.offsetX = 0;
+        this.offsetY = 0;
+        this.triggered = false;
+    },
+    gesturestart: function (event) {
+        if (this.fluidbook.pad.enabled) {
+            return false;
+        }
+        var e = event.originalEvent;
+        this.enableUserScale();
+        this.gesturing = true;
+        return true;
+    },
+    gesturechange: function (event) {
+        if (this.fluidbook.pad.enabled) {
+            return false;
+        }
+        var e = event.originalEvent;
+        this.gesturing = true;
+        return true;
+    },
+    gestureend: function (event) {
+        if (this.fluidbook.pad.enabled) {
+            return false;
+        }
+
+        var e = event.originalEvent;
+        this.gesturing = false;
+
+        if (DetectZoom.zoom() > 1) {
+            $('html').addClass('nopan');
+        } else {
+            $('html').removeClass('nopan');
+        }
+        return true;
+    },
+    start: function (event) {
+        var e = event.originalEvent;
+        var touches = e.touches;
+
+        if (touches.length > 1) {
+            this.enableUserScale();
+            return true;
+        }
+
+        this._start(touches[0].pageX, touches[0].pageY);
+        return true;
+    },
+    end: function (event) {
+        var e = event.originalEvent;
+        var touches = e.touches;
+
+        if (touches.length == 0) {
+            this._end();
+        }
+        return true;
+    },
+    testOffset: function () {
+        if (this.triggered) {
+            return false;
+        }
+        if (this.allowMove()) {
+            return false;
+        }
+        if (!this.fluidbook.pad.enabled) {
+            if (Math.abs(this.offsetX) < Math.abs(this.offsetY)) {
+                return false;
+            }
+            if (this.allowSlide()) {
+                if (this.offsetX < -this.triggerOffset) {
+                    if (this.fluidbook.l10n.dir == 'ltr') {
+                        this.fluidbook.goNextPage();
+                    } else {
+                        this.fluidbook.goPreviousPage();
+                    }
+
+                    return true;
+                } else if (this.offsetX > this.triggerOffset) {
+                    if (this.fluidbook.l10n.dir == 'ltr') {
+                        this.fluidbook.goPreviousPage();
+                    } else {
+                        this.fluidbook.goNextPage();
+                    }
+                    return true;
+                }
+            }
+        } else {
+            // Mode mag pad
+            if (this.allowSlide()) {
+                var offset = this.offsetX;
+                var way = 'x';
+                if (Math.abs(this.offsetX) < Math.abs(this.offsetY)) {
+                    offset = this.offsetY;
+                    way = 'y';
+                }
+
+                if (Math.abs(offset) < this.triggerOffset) {
+                    return false;
+                }
+
+                if (offset < -this.triggerOffset) {
+                    if (way == 'x') {
+                        this.fluidbook.goNextChapter();
+                    } else {
+                        this.fluidbook.goNextChapterPage();
+                    }
+                } else {
+                    if (way == 'x') {
+                        this.fluidbook.goPreviousChapter();
+                    } else {
+                        this.fluidbook.goPreviousChapterPage();
+                    }
+                }
+                return true;
+            }
+        }
+        return false;
+    },
+    cancel: function (event) {
+        this.end(event);
+        return true;
+    },
+    move: function (event) {
+        var e = event.originalEvent;
+
+        var touches = e.touches;
+
+        if (touches.length > 1) {
+            return true;
+        }
+
+        return this._move(touches[0].pageX, touches[0].pageY);
+    },
+    _start: function (x, y) {
+        this.startX = x;
+        this.startY = y;
+    },
+    _move: function (x, y) {
+        if (!isNaN(this.startX)) {
+            this.offsetX = (x - this.startX) / $(window).width();
+        }
+
+        if (!isNaN(this.startY)) {
+            this.offsetY = (y - this.startY) / $(window).height();
+        }
+
+        this.testOffset();
+        return this.allowMove();
+    },
+    _end: function () {
+        this.testOffset();
+        this.reset();
+    },
+    enableUserScale: function () {
+        if (this.fluidbook.pad.enabled) {
+            this.fluidbook.viewport.maxScale = 1;
+            this.fluidbook.viewport.userScalable = false;
+        } else {
+            this.fluidbook.viewport.maxScale = 3;
+            this.fluidbook.viewport.userScalable = true;
+        }
+        this.fluidbook.viewport.updateViewport();
+    }
 };
 
index b24158cd62b3d1518ffb3100c81acd0c47642029..4cb839a4729abfbe6958b67909c4555737a3b470 100644 (file)
@@ -1,27 +1,29 @@
-function FluidbookViewport(support){
-       this.support=support;
-       this.width=null;
-       this.height=null;
-       this.minScale=1;
-       this.maxScale=3;
-       this.initialScale=1;
-       this.userScalable=false;
-       this.meta=$('meta[name="viewport"]');
+function FluidbookViewport() {
+    this.width = 'device-width';
+    this.height = null;
+    this.minScale = 1;
+    this.maxScale = 10;
+    this.initialScale = 0;
+    this.userScalable = false;
+    this.meta = $('meta[name="viewport"]');
 }
 
-FluidbookViewport.prototype={
-       updateViewport:function(){
-               var w='';
-               if(this.width!=null){
-                       w='width='+this.width+', ';
-               }
-               var h='';
-               if(this.height!=null){
-                       h='height='+this.height+', ';
-               }
-               var us=this.userScalable==true?'1':'0';
-               
-               var value=w+h+'initial-scale='+this.initialScale+', minimum-scale='+Math.max(0.25,this.minScale)+', maximum-scale='+Math.min(10,this.maxScale)+', user-scalable='+us;
-               this.meta.attr('content',value);
-       }
+FluidbookViewport.prototype = {
+    updateViewport: function () {
+        var w = '';
+        if (this.width != null) {
+            w = 'width=' + this.width + ', ';
+        }
+        var h = '';
+        if (this.height != null) {
+            h = 'height=' + this.height + ', ';
+        }
+        var is = '';
+        if (this.initialScale > 0) {
+            var is = 'initial-scale=' + this.initialScale + ', ';
+        }
+        var us = this.userScalable == true ? '1' : '0';
+        var value = w + h + is + 'minimum-scale=' + Math.max(0.25, this.minScale) + ', maximum-scale=' + Math.min(10, this.maxScale) + ', user-scalable=' + us + ", shrink-to-fit=no";
+        this.meta.attr('content', value);
+    }
 }
\ No newline at end of file
index 48c748019cd8c4267c692656ca82c84195a21e7e..c11b28064fdebb2edd96a6aca88b7dbb979f7dc0 100644 (file)
@@ -144,6 +144,8 @@ body {
 
 #background .links {
        position: absolute;
+       width: 100%;
+       height: 100%;
 }
 
 #background .links .link {