From: Vincent Vanwaelscappel Date: Tue, 13 Dec 2022 11:12:18 +0000 (+0100) Subject: wait #5639 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=27bedfed1ae87bfa980a4d6f35bebddf75dd8f0d;p=fluidbook-toolbox.git wait #5639 @2 --- diff --git a/app/Models/FluidbookPublication.php b/app/Models/FluidbookPublication.php index 05bf5431d..172f41453 100644 --- a/app/Models/FluidbookPublication.php +++ b/app/Models/FluidbookPublication.php @@ -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') diff --git a/resources/linkeditor/js/linkeditor.js b/resources/linkeditor/js/linkeditor.js index 9d729d24d..267fe243b 100644 --- a/resources/linkeditor/js/linkeditor.js +++ b/resources/linkeditor/js/linkeditor.js @@ -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(); }, diff --git a/resources/linkeditor/js/linkeditor.loader.js b/resources/linkeditor/js/linkeditor.loader.js index 3c8049c20..6b9f4976c 100644 --- a/resources/linkeditor/js/linkeditor.loader.js +++ b/resources/linkeditor/js/linkeditor.loader.js @@ -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(''); diff --git a/resources/linkeditor/js/linkeditor.resize.js b/resources/linkeditor/js/linkeditor.resize.js index 516a9cde5..ea21c457a 100644 --- a/resources/linkeditor/js/linkeditor.resize.js +++ b/resources/linkeditor/js/linkeditor.resize.js @@ -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 + ')'}); }, diff --git a/resources/linkeditor/js/linkeditor.zoom.js b/resources/linkeditor/js/linkeditor.zoom.js index 1322740b7..d9579838b 100644 --- a/resources/linkeditor/js/linkeditor.zoom.js +++ b/resources/linkeditor/js/linkeditor.zoom.js @@ -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(); diff --git a/resources/views/fluidbook_publication/link_editor.blade.php b/resources/views/fluidbook_publication/link_editor.blade.php index d389f72c7..b2f6aed6e 100644 --- a/resources/views/fluidbook_publication/link_editor.blade.php +++ b/resources/views/fluidbook_publication/link_editor.blade.php @@ -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;