]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6788 @3:00
authorsoufiane <soufiane@cubedesigners.com>
Wed, 27 Mar 2024 17:22:00 +0000 (18:22 +0100)
committersoufiane <soufiane@cubedesigners.com>
Wed, 27 Mar 2024 17:22:00 +0000 (18:22 +0100)
app/Http/Controllers/Admin/Operations/FluidbookPublication/LinksOperation.php
resources/linkeditor/js/linkeditor.js
resources/linkeditor/js/linkeditor.links.js
resources/linkeditor/js/linkeditor.zoom.js
resources/linkeditor/style/inc/_toolbar.sass
resources/views/fluidbook_publication/link_editor.blade.php

index 1518c2ed6653d5078c159e14d85bfab084763d08..6f53d877610afd9a8b73a254c86464701d8f8227 100644 (file)
@@ -93,8 +93,6 @@ trait LinksOperation
         $fb = FluidbookPublication::find($id);
         $wdir = $fb->protected_path('fluidbookpublication/working/'.$id).'/';
         $css = [];
-        $w = round($fb->getPageWidth(), 8);
-        $h = round($fb->getPageHeight(), 8);
 
         foreach ($textLinks as $link) {
             if(array_key_exists('image', $link)) {
index 9d0b8bc819d8390d49410ab61158b0aa66da9893..80fdc2b64727fe29b821a52c97433b91416878b2 100644 (file)
@@ -491,6 +491,9 @@ LinkEditor.prototype = {
         }
         this.undo.updateIconsStates();
         this.loader.preloadPages();
+        if($("#preview-links").hasClass("active")) {
+            this.links.setPreview()
+        }
     },
 
     getCurrentPages: function (page) {
index 3652b0396c9ed52148f49b95d6d719b5f350f96d..e1606574f1b72b23726f4ecf5b513190f9870aa0 100644 (file)
@@ -1164,7 +1164,7 @@ LinkeditorLinks.prototype = {
         this.linkeditor.rulers.updateMagnetValues();
         this.updateLayers();
         this.updatePolygonLinks(false);
-        if($(['data-action=links.preview']).hasClass("active")) {
+        if($("#preview-links").hasClass("active")) {
             this.updatePreview(LINKS[id]);
         }
     },
@@ -1562,26 +1562,35 @@ LinkeditorLinks.prototype = {
     },
 
     loadFontSize: function() {
-        $.ajax({
-            url:  '/fluidbook-publication/' + FLUIDBOOK_DATA.id + '/generatefont',
-            type: 'post',
-            data: { links: window.LINKS, rulers: window.RULERS },
-            success: function (response) {
-                FONT_SIZE = JSON.parse(response);
-            },
-            complete: function() {
-                $("#extra-font-face").remove()
-                $("head").append("<style id='extra-font-face'></style>")
-                for(let k in FONT_SIZE) {
-                    $("#extra-font-face").append("@font-face{font-family:"+FONT_SIZE[k]['font']+";src:url('/fluidbook-publication/"+ FLUIDBOOK_DATA.id +"/edit/links/assets/"+FONT_SIZE[k]['hash']+"' ) format('woff');}")
+        if(Object.keys(window.LINKS).length > 0) {
+            $.ajax({
+                url: '/fluidbook-publication/' + FLUIDBOOK_DATA.id + '/generatefont',
+                type: 'post',
+                data: {links: window.LINKS, rulers: window.RULERS},
+                success: function (response) {
+                    FONT_SIZE = JSON.parse(response);
+                },
+                complete: function () {
+                    $("#extra-font-face").remove()
+                    $("head").append("<style id='extra-font-face'></style>")
+                    for (let k in FONT_SIZE) {
+                        $("#extra-font-face").append("@font-face{font-family:" + FONT_SIZE[k]['font'] + ";src:url('/fluidbook-publication/" + FLUIDBOOK_DATA.id + "/edit/links/assets/" + FONT_SIZE[k]['hash'] + "' ) format('woff');}")
+                    }
+                    $("#preview-links").removeClass('disabled');
                 }
-            }
-        });
+            });
+        } else {
+            $("#preview-links").removeClass('disabled');
+        }
     },
 
     updatePreview: function(link) {
-        let linkData = link,
-            gsapConfig = this.convertAnimationStringToObject(linkData.image_rollover)
+        let linkData = link
+
+        let l = this.getLinkById(link.uid)
+        if($('[data-id-preview="'+link.uid+'"]').length < 1) {
+            l.html("<div data-id-preview='" + link.uid + "'></div>")
+        }
 
         $("[data-id-preview="+linkData.uid+"]").css({
             height: '100%',
@@ -1610,12 +1619,13 @@ LinkeditorLinks.prototype = {
                 'background-position': '0 0',
             })
         } else if(linkData.type === '35') {
-            var hash = 'fb_'+window.MD5(link.image).toString().substring(0,10)
+            var hash = 'fb_'+window.MD5(linkData.image).toString().substring(0,10)
             this.setFontSize(linkData, hash)
             $("[data-id-preview=" + linkData.uid + "]").text(linkData.to).css({
                 'font-family': hash,
                 'color': linkData.extra,
             })
+            this.updateFontSize(link)
         }
     },
 
@@ -1623,8 +1633,6 @@ LinkeditorLinks.prototype = {
         const links = this.getLinksOfPage(this.linkeditor.currentPage)
 
         for(let link in links) {
-            let l = this.getLinkById(links[link].uid)
-            l.html("<div data-id-preview='"+links[link].uid+"'></div>")
             this.updatePreview(links[link])
         }
     },
@@ -1645,7 +1653,8 @@ LinkeditorLinks.prototype = {
         }
     },
 
-    updateFontSize: function(zoom, link) {
+    updateFontSize: function(link) {
+        let zoom = this.linkeditor.zoom.zoom
         $("[data-id-preview="+link.uid+"]").css({
             transform: "scale("+zoom+")",
             'transform-origin': 'left top'
index 8dd75017febb2d24159ccae34b335c9e9b070087..a863651080633f5ab381284dab062337a4a4cea9 100644 (file)
@@ -81,6 +81,7 @@ LinkeditorZoom.prototype = {
 
         $("#linkeditor-canvas").scrollTo({left: sx, top: sy});
         this.linkeditor.rulers.updateRulers();
+        this.linkeditor.links.setPreview()
     },
 
 
@@ -128,7 +129,7 @@ LinkeditorZoom.prototype = {
             if (this.zoom === 1) {
                 $this.resetZoomDrag();
             }
-            //$this.linkeditor.links.updateFontSize($this.zoom)
+
             $this.linkeditor.rulers.updateRulers();
         }, 10);
         return true;
@@ -139,6 +140,7 @@ LinkeditorZoom.prototype = {
         var top = this.linkeditor.mobileFirst ? 0 : '50%';
         $("#linkeditor-canvas").scrollTo({top: top, left: '50%'});
         this.resetZoomDrag();
+        this.linkeditor.links.setPreview()
     },
 };
 export default LinkeditorZoom;
index e017ce1ec831aad021111b49e81686797f04ebb7..834724d3178ab4fae6c882c16351d6096116ecba 100644 (file)
             top: 1px
             height: 18px
             width: auto
+
+    #preview-links.disabled
+        pointer-events: none
index 91054e617619c7b28d33c82312febc3c48b6402e..ee82f54b48cff0334b3c44047fadb38a42ef5b61 100644 (file)
                     @endif
                     <a href="#" data-action="toggleWhiteOverlay" data-icon="white-overlay"
                        data-tooltip="{{__('Afficher un overlay blanc semi-opaque au dessus des pages')}}"></a>
-                    <a href="#" data-action="links.preview" data-icon="preview-links"
+                    <a href="#" id="preview-links" class="disabled" data-action="links.preview" data-icon="preview-links"
                        data-tooltip="{{__('Voir un aperçu des liens (Ctrl+Y)')}}" data-key="ctrl+y"></a>
                     <a href="#" data-action="openFluidbook" data-icon="open-fluidbook"
                        data-tooltip="{{__('Ouvrir le fluidbook à la page courante')}}"></a>