]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5618 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 30 Nov 2022 12:04:35 +0000 (13:04 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 30 Nov 2022 12:04:35 +0000 (13:04 +0100)
app/SubForms/Link/Base.php
app/SubForms/Link/Tooltip.php
resources/linkeditor/js/linkeditor.js
resources/linkeditor/js/linkeditor.resize.js
resources/linkeditor/js/linkeditor.zoom.js
resources/linkeditor/style/links.sass
resources/linkeditor/style/style.sass

index d1d22c27031068c297f34bc38a154bbdb6ac28c8..b605273213bedc3c217a65be42060744ddac8e55 100644 (file)
@@ -195,6 +195,7 @@ class Base extends Form
     public function addTypeField()
     {
         $this->addField('type', LinkType::class, __('Type de lien'));
+        $this->addUIDField();
     }
 
     public function addDestinationField()
@@ -219,7 +220,7 @@ class Base extends Form
         if ($this->_integration) {
             $this->addField('inline', MultimediaIntegration::class, __('Intégration'));
         }
-        $this->addUIDField();
+
         if ($this->_addedContents) {
             $this->addField('header_contents', FormSection::class, __('Contenus superposés'));
             $this->addField('image', FilesOrURL::class, __('Image'), $this->getFilesOrURLEntry() + ['accept' => self::$_acceptImage]);
index ebc00e76754aec2c46dca8212181944e1a4c622c..3a5d66789059f8084bcdd535b7fa643e2bfcb2df 100644 (file)
@@ -24,6 +24,5 @@ class Tooltip extends Base
         $this->addField('header_tooltip', FormSection::class, __('Paramètres'));
         $this->addField('tooltip', Textarea::class, __('Texte de l\'infobulle'));
         $this->addField('display_area', Checkbox::class, __('Afficher la zone de couleur au survol'), ['default' => true]);
-        $this->addUIDField();
     }
 }
index 1269db68a0190fdcce22bcf4036ec4eb9e6a9ed8..ef6918d0c7ed661e36e9de64018c0b90c4cf8a7c 100644 (file)
@@ -72,6 +72,7 @@ LinkEditor.prototype = {
         this.initEvents();
         this.initIcons();
         this.panels.init();
+        this.zoom.reset();
     },
 
     initIcons: function () {
@@ -89,10 +90,8 @@ LinkEditor.prototype = {
         // Disable scroll by spacebar
         $(window).on('keydown', function (e) {
             if (e.keyCode == 32) {
-                if ($this.zoom.zoom !== 1) {
-                    $("#linkeditor-main").addClass('grab');
-                    return false;
-                }
+                $("#linkeditor-main").addClass('grab');
+                return false;
             } else if (e.keyCode == 18) {
                 $("#linkeditor-main").addClass('duplicate');
                 return false;
@@ -115,7 +114,7 @@ LinkEditor.prototype = {
             if ($(this).hasClass('duplicate')) {
                 $this.links.duplicateLinkClick();
                 return;
-            } else if ($(this).hasClass('grab') && $this.zoom.zoom > 1) {
+            } else if ($(this).hasClass('grab')) {
                 $this.zoom.zoomdragging = {
                     x: $this.mx,
                     y: $this.my,
@@ -124,9 +123,12 @@ LinkEditor.prototype = {
                 };
                 $(this).addClass('grabbing');
             } else {
-                $this.zoom.resetZoomDrag();
-                $this.links.createLinkDrag();
-                deselectAll = false;
+                // Check if the user is not clicking the scrollbar
+                if ($this.mx < $this.canvasRect.right - 20 && $this.my < $this.canvasRect.bottom - 20) {
+                    $this.zoom.resetZoomDrag();
+                    $this.links.createLinkDrag();
+                    deselectAll = false;
+                }
             }
             if (deselectAll) {
                 $this.form.saveFormDataInLink();
@@ -260,7 +262,6 @@ LinkEditor.prototype = {
         this.links.moveDragLink();
         this.links.moveResizeLink();
         this.zoom.updateMousePosition();
-
     },
 
     setMouseCoordinates: function (e) {
index 62b45c89662a0e42d6818c8d5b3b9950a06e85fa..043d528965fc56ab1becdf740de09ada799dc5aa 100644 (file)
@@ -36,8 +36,8 @@ LinkeditorResize.prototype = {
         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);
-        var left = (this.linkeditor.canvasRect.width - this.linkeditor.fw * this.linkeditor.fs) / 2;
-        var top = (this.linkeditor.canvasRect.height - this.linkeditor.fh * this.linkeditor.fs) / 2;
+        var left = ((this.linkeditor.canvasRect.width * 2) - this.linkeditor.fw * this.linkeditor.fs) / 2;
+        var top = ((this.linkeditor.canvasRect.height * 2) - this.linkeditor.fh * this.linkeditor.fs) / 2;
         $("#linkeditor-fluidbook").css({left: left, top: top, transform: 'scale(' + this.linkeditor.fs + ')'});
     },
 };
index 6fd7f7965524e714a2e894b54a1ac7804155d723..750de7d20f25d9a342c63174b4ae24a93fff05fd 100644 (file)
@@ -11,6 +11,7 @@ LinkeditorZoom.prototype = {
         this.zoomdragging = false;
 
         $("#linkeditor-main").on('wheel', function (e) {
+            var step = $this.zoom >= 1 ? 0.25 : 0.1;
             $this.linkeditor.setMouseCoordinates(e);
             let delta = e.originalEvent.deltaY;
             if (delta === 0) {
@@ -20,11 +21,11 @@ LinkeditorZoom.prototype = {
             e.stopImmediatePropagation();
             e.preventDefault();
             if (delta < 0) {
-                if ($this.setZoom($this.zoom + 0.25)) {
+                if ($this.setZoom($this.zoom + step)) {
                     $this.moveZoom(e);
                 }
             } else {
-                $this.setZoom($this.zoom - 0.25);
+                $this.setZoom($this.zoom - step);
             }
             return false;
         });
@@ -39,7 +40,7 @@ LinkeditorZoom.prototype = {
     },
 
     updateMousePosition: function () {
-        if (!$("#linkeditor-main").hasClass('grab') || this.zoom === 1) {
+        if (!$("#linkeditor-main").hasClass('grab')) {
             this.resetZoomDrag();
         }
         if (this.zoomdragging !== false) {
@@ -49,9 +50,6 @@ LinkeditorZoom.prototype = {
 
     resetZoomDrag: function () {
         $("#linkeditor-main").removeClass('grab').removeClass('grabbing');
-        if (this.zoom === 1) {
-            $("#linkeditor-canvas").scrollTo({left: 0, top: 0});
-        }
         this.zoomdragging = false;
     },
 
@@ -72,18 +70,38 @@ LinkeditorZoom.prototype = {
         this.linkeditor.rulers.updateRulers();
     },
 
-    setZoom: function (z) {
+
+    normalizeZoom: function (z) {
+        return Math.max(0.5, Math.min(8, z));
+    },
+
+    setZoom: function (z, force) {
         let $this = this;
-        z = Math.max(1, Math.min(6, z));
-        if (z === this.zoom) {
+        z = this.normalizeZoom(z);
+        if (force !== true && z === this.zoom) {
             return false;
         }
         this.zoom = z;
+        let cw2 = this.linkeditor.canvasRect.width * 2;
+        let ch2 = this.linkeditor.canvasRect.height * 2;
+        let zh = ch2;
+        if (this.zoom < 1) {
+            zh *= this.zoom;
+        }
         $("#linkeditor-canvas").attr('data-z', this.zoom);
-        $("#linkeditor-zoom").css({transform: 'scale(' + this.zoom + ')', overflow: 'visible'});
+        $("#linkeditor-zoom").css({
+            transform: 'scale(' + this.zoom + ')', overflow: 'visible',
+            width: cw2,
+            maxWidth: cw2,
+            minWidth: cw2,
+            height: zh,
+            minHeight: zh,
+            maxHeight: zh
+        });
+
 
         setTimeout(function () {
-            $("#linkeditor-zoom").css({overflow: 'hidden'});
+            //$("#linkeditor-zoom").css({overflow: 'hidden'});
             if (this.zoom === 1) {
                 $this.resetZoomDrag();
             }
@@ -95,6 +113,7 @@ LinkeditorZoom.prototype = {
 
     reset: function () {
         this.setZoom(1);
+        $("#linkeditor-canvas").scrollTo({top: '50%', left: '50%'});
         this.resetZoomDrag();
     },
 };
index 3b95a023f0d78eb4a57e00206a819950395b47dc..92ab99b4ae50fb4a7306d440d475e50a61a76bd1 100644 (file)
@@ -2,6 +2,8 @@
 
 #linkeditor-links
     .link
+        #linkeditor-main.grab &
+            pointer-events: none
         box-sizing: border-box
         position: absolute
         border: currentColor solid 1px
index b5b0524e57b232c237750062934ff34b8e6d7dde..1235de403026b311ec1745694da361e40b53ee0d 100644 (file)
@@ -66,14 +66,13 @@ body, #linkeditor, html
             overflow: hidden
 
             #linkeditor-zoom
-                width: 100%
-                height: 100%
-                max-width: 100%
-                max-height: 100%
-                min-height: 100%
-                min-width: 100%
+                width: 200%
+                height: 200%
+                max-width: 200%
+                max-height: 200%
+                min-height: 200%
+                min-width: 200%
                 transform-origin: 0 0
-                overflow: hidden
 
             #linkeditor-canvas
                 background-color: #505050