]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5639 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 13 Dec 2022 11:12:18 +0000 (12:12 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 13 Dec 2022 11:12:18 +0000 (12:12 +0100)
app/Models/FluidbookPublication.php
resources/linkeditor/js/linkeditor.js
resources/linkeditor/js/linkeditor.loader.js
resources/linkeditor/js/linkeditor.resize.js
resources/linkeditor/js/linkeditor.zoom.js
resources/views/fluidbook_publication/link_editor.blade.php

index 05bf5431db79e3fb4320650931a63dba880c89b0..172f414534f805fc2e68609007c2a3540b77a6e5 100644 (file)
@@ -304,14 +304,22 @@ class FluidbookPublication extends ToolboxSettingsModel
         return $document->getPageSize($this->composition[$page][1]);
     }
 
+    /**
+     * @param $page
+     * @return float
+     */
     public function getPageWidth($page = 1)
     {
-        return $this->getDocumentSize($page)[0];
+        return (float)$this->getDocumentSize($page)[0];
     }
 
+    /**
+     * @param $page
+     * @return float
+     */
     public function getPageHeight($page = 1)
     {
-        return $this->getDocumentSize($page)[1];
+        return (float)$this->getDocumentSize($page)[1];
     }
 
     public function getFinalPath($theme = null, $version = 'online')
index 9d729d24d6b96dbd2c673e67d642aeb46b448705..267fe243b4e13c87ffcb24e412d0d4177af3c784 100644 (file)
@@ -123,7 +123,9 @@ LinkEditor.prototype = {
         // Disable scroll by spacebar
         $(window).on('keydown', function (e) {
             if (e.keyCode == 32) {
-                $("#linkeditor-main").addClass('grab');
+                if (!$this.mobileFirst) {
+                    $("#linkeditor-main").addClass('grab');
+                }
                 return false;
             } else if (e.keyCode == 18) {
                 $("#linkeditor-main").addClass('duplicate');
@@ -279,6 +281,13 @@ LinkEditor.prototype = {
         this.form.updateFormData();
     },
 
+    getCurrentPageHeight: function () {
+        if (this.mobileFirst) {
+            return FLUIDBOOK_DATA.page_dimensions[this.currentPage][1];
+        }
+        return FLUIDBOOK_DATA.height;
+    },
+
     fluidbookTo: function (dim, name, rect) {
         switch (rect) {
             case 'editor':
@@ -332,10 +341,10 @@ LinkEditor.prototype = {
             this.loader.loadPage(this.currentPage + 1, 'right');
         }
         $("#linkeditor-page-field input").val(this.currentPage);
+        this.resize.resize();
         if (this.mobileFirst) {
             this.zoom.reset();
         }
-        this.resize.resize();
         this.loader.preloadPages();
     },
 
index 3c8049c200a9c7e565da192cbfa7fdf5f53d0a39..6b9f4976cacccf9cd320ebe0b7bdd8b1a2040d8b 100644 (file)
@@ -13,6 +13,11 @@ LinkeditorLoader.prototype = {
     loadPage: function (p, side) {
         var container = $("#linkeditor-page-" + side);
         $(container).attr('data-page', p);
+        if (this.linkeditor.mobileFirst) {
+            let h = FLUIDBOOK_DATA.page_dimensions[p][1];
+            $("#linkeditor-fluidbook").css('height', h);
+            $(container).css('height', h);
+        }
 
         if (p === 0 || p > FLUIDBOOK_DATA.settings.pages) {
             $(container).html('');
index 516a9cde585089494154e217a0662b6f5d007c7a..ea21c457a6599e7a67d5718b45261c79013c4d54 100644 (file)
@@ -8,6 +8,9 @@ LinkeditorResize.prototype = {
         var $this = this;
         $(window).on('resize', function () {
             $this.resize();
+            setTimeout(function () {
+                $this.resize();
+            }, 100);
         });
         this.updateWindowDimensions();
     },
@@ -40,7 +43,12 @@ LinkeditorResize.prototype = {
         this.linkeditor.editorRect = $("#linkeditor-editor").get(0).getBoundingClientRect();
         var aw = this.linkeditor.canvasRect.width - 30;
         var ah = this.linkeditor.canvasRect.height - 30;
-        this.linkeditor.fs = Math.min(aw / this.linkeditor.fw, ah / this.linkeditor.fh);
+
+        if (this.linkeditor.mobileFirst) {
+            this.linkeditor.fs = 620 / this.linkeditor.fw;
+        } else {
+            this.linkeditor.fs = Math.min(aw / this.linkeditor.fw, ah / this.linkeditor.fh);
+        }
 
         let left, top;
 
@@ -49,7 +57,7 @@ LinkeditorResize.prototype = {
             top = ((this.linkeditor.canvasRect.height * 2) - this.linkeditor.fh * this.linkeditor.fs) / 2;
         } else {
             left = (this.linkeditor.canvasRect.width - this.linkeditor.fw * this.linkeditor.fs) / 2;
-            top = 100;
+            top = 75;
         }
         $("#linkeditor-fluidbook").css({left: left, top: top, transform: 'scale(' + this.linkeditor.fs + ')'});
     },
index 1322740b72ba6585de95b18b255b3d2de6bc900f..d9579838b754f1d8b5d718a4514e9cdd45cb2329 100644 (file)
@@ -74,13 +74,13 @@ LinkeditorZoom.prototype = {
 
 
     normalizeZoom: function (z) {
+        if (this.linkeditor.mobileFirst) {
+            return 1;
+        }
         return Math.max(0.5, Math.min(8, z));
     },
 
     setZoom: function (z, force) {
-        if (!this.linkeditor.mobileFirst) {
-            z = 1;
-        }
         let $this = this;
         z = this.normalizeZoom(z);
 
@@ -89,7 +89,8 @@ LinkeditorZoom.prototype = {
         let cw2, ch2, zh;
         if (this.linkeditor.mobileFirst) {
             cw2 = this.linkeditor.canvasRect.width;
-            zh = parseFloat(FLUIDBOOK_DATA.pages_max_height) + 200;
+            zh = (this.linkeditor.getCurrentPageHeight() * this.linkeditor.fs) + 150;
+            console.log(zh);
         } else {
             cw2 = this.linkeditor.canvasRect.width * 2;
             ch2 = this.linkeditor.canvasRect.height * 2;
@@ -110,7 +111,6 @@ LinkeditorZoom.prototype = {
             maxHeight: zh
         });
 
-
         setTimeout(function () {
             if (this.zoom === 1) {
                 $this.resetZoomDrag();
index d389f72c743c10e02f31cee4dde4d4b1195c74c9..b2f6aed6e6855b4d85af7c76b96bc37cb647085f 100644 (file)
@@ -6,9 +6,11 @@
     $fbdata['settings']['width']=$fbdata['width']=$fluidbook->getPageWidth();
     $fbdata['settings']['height']=$fbdata['height']=$fluidbook->getPageHeight();
     $fbdata['settings']['pages']=$fbdata['pages']=$fluidbook->getPagesNumber();
+    $fbdata['page_dimensions']=[];
     $mh = 0;
     for($i=1;$i<=$fbdata['pages'];$i++){
-        $mh = max($mh, $fluidbook->getPageHeight($i));
+        $fbdata['page_dimensions'][$i]=[$fluidbook->getPageWidth($i),$fluidbook->getPageHeight($i)];
+        $mh = max($mh,$fbdata['page_dimensions'][$i][1]);
     }
     $fbdata['pages_max_height']=$mh;