From 99a1b3cbfc15c77ba5f22f74afa382e28427308b Mon Sep 17 00:00:00 2001 From: soufiane Date: Wed, 27 Mar 2024 18:22:00 +0100 Subject: [PATCH] wait #6788 @3:00 --- .../FluidbookPublication/LinksOperation.php | 2 - resources/linkeditor/js/linkeditor.js | 3 ++ resources/linkeditor/js/linkeditor.links.js | 51 +++++++++++-------- resources/linkeditor/js/linkeditor.zoom.js | 4 +- resources/linkeditor/style/inc/_toolbar.sass | 3 ++ .../link_editor.blade.php | 2 +- 6 files changed, 40 insertions(+), 25 deletions(-) diff --git a/app/Http/Controllers/Admin/Operations/FluidbookPublication/LinksOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookPublication/LinksOperation.php index 1518c2ed6..6f53d8776 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookPublication/LinksOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookPublication/LinksOperation.php @@ -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)) { diff --git a/resources/linkeditor/js/linkeditor.js b/resources/linkeditor/js/linkeditor.js index 9d0b8bc81..80fdc2b64 100644 --- a/resources/linkeditor/js/linkeditor.js +++ b/resources/linkeditor/js/linkeditor.js @@ -491,6 +491,9 @@ LinkEditor.prototype = { } this.undo.updateIconsStates(); this.loader.preloadPages(); + if($("#preview-links").hasClass("active")) { + this.links.setPreview() + } }, getCurrentPages: function (page) { diff --git a/resources/linkeditor/js/linkeditor.links.js b/resources/linkeditor/js/linkeditor.links.js index 3652b0396..e1606574f 100644 --- a/resources/linkeditor/js/linkeditor.links.js +++ b/resources/linkeditor/js/linkeditor.links.js @@ -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("") - 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("") + 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("
") + } $("[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("
") 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' diff --git a/resources/linkeditor/js/linkeditor.zoom.js b/resources/linkeditor/js/linkeditor.zoom.js index 8dd75017f..a86365108 100644 --- a/resources/linkeditor/js/linkeditor.zoom.js +++ b/resources/linkeditor/js/linkeditor.zoom.js @@ -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; diff --git a/resources/linkeditor/style/inc/_toolbar.sass b/resources/linkeditor/style/inc/_toolbar.sass index e017ce1ec..834724d31 100644 --- a/resources/linkeditor/style/inc/_toolbar.sass +++ b/resources/linkeditor/style/inc/_toolbar.sass @@ -123,3 +123,6 @@ top: 1px height: 18px width: auto + + #preview-links.disabled + pointer-events: none diff --git a/resources/views/fluidbook_publication/link_editor.blade.php b/resources/views/fluidbook_publication/link_editor.blade.php index 91054e617..ee82f54b4 100644 --- a/resources/views/fluidbook_publication/link_editor.blade.php +++ b/resources/views/fluidbook_publication/link_editor.blade.php @@ -308,7 +308,7 @@ @endif - -- 2.39.5