]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6786 @7:00
authorsoufiane <soufiane@cubedesigners.com>
Mon, 18 Mar 2024 17:30:08 +0000 (18:30 +0100)
committersoufiane <soufiane@cubedesigners.com>
Mon, 18 Mar 2024 17:30:08 +0000 (18:30 +0100)
resources/linkeditor/js/linkeditor.js
resources/linkeditor/js/linkeditor.links.js
resources/linkeditor/js/linkeditor.previewLinks.js [new file with mode: 0644]
resources/views/fluidbook_publication/link_editor.blade.php

index ca85b81cc9437e02b27f4ff84c11e529f0bf0007..8df7c79ea153a78a57191ab71b6f282612dfce59 100644 (file)
@@ -60,6 +60,7 @@ require('select2');
 import 'select2/dist/css/select2.css';
 import 'select2-bootstrap-theme/dist/select2-bootstrap.css';
 import * as noty from "noty";
+import LinkeditorPreviewLinks from "./linkeditor.previewLinks";
 
 window.MD5 = require("crypto-js/md5");
 
@@ -118,6 +119,7 @@ LinkEditor.prototype = {
         this.popup = new LinkeditorPopup(this);
         this.undo = new LinkeditorUndo(this);
         this.accessControl = new LinkeditorAccessControl(this);
+        this.previewLinks = new LinkeditorPreviewLinks(this);
 
         this.initEvents();
         this.initIcons();
@@ -308,6 +310,7 @@ LinkEditor.prototype = {
             po = o;
             o = o[a[i]];
         }
+
         try {
             return o.apply(po, args);
         } catch (e) {
index 524023e06f6f509383c962541d9280c3eab55da1..83227a3eee973f60e2db0f2ddf4564dd9a8ee57c 100644 (file)
@@ -1,4 +1,5 @@
 import LinkeditorLinksLock from './linkeditor.links.lock';
+import gsap from "gsap";
 
 var LinkeditorLinks = function (linkeditor) {
     this.linkeditor = linkeditor;
@@ -146,6 +147,10 @@ LinkeditorLinks.prototype = {
                 return false;
             }
         });
+        this.key('ctrl+y', function () {
+            $this.preview();
+            return false;
+        });
 
         var commonDragAndDropEvent = function (e) {
             e.originalEvent.dataTransfer.dropEffect = "copy";
@@ -1543,6 +1548,64 @@ LinkeditorLinks.prototype = {
         this.linkeditor.updateFBElements(false);
         this.linkeditor.save.hasChanged();
     },
+
+    preview: function() {
+        $("#linkeditor-fluidbook").toggleClass('white-overlay');
+        let el = $("[data-action='links.preview']")
+        el.toggleClass("active")
+        if(el.hasClass("active")) {
+            this.setPreview()
+        } else {
+            this.clearPreview()
+        }
+    },
+
+    setPreview: function(p) {
+        const links = this.getLinksOfPage(1)
+        for(let link in links) {
+            let linkData = links[link],
+                l = this.getLinkById(linkData.uid),
+                gsapConfig = this.convertAnimationStringToObject(linkData.image_rollover)
+
+            if(linkData.type === '14') {
+                l.html("<div data-id-preview='"+linkData.uid+"'></div>")
+                $("[data-id-preview="+linkData.uid+"]").css({
+                    height: '100%',
+                    backgroundColor: linkData.to,
+                    'z-index': 99
+                })
+
+                /*gsapConfig.forEach(function(conf) {
+                    gsap.to($("[data-id-preview="+linkData.uid+"]"),conf)
+                })*/
+            }
+        }
+    },
+
+    clearPreview: function() {
+      $("[data-id-preview]").remove()
+    },
+
+    convertAnimationStringToObject: function(anim) {
+        let anims = anim.split('---')
+        let o = []
+
+        anims.forEach(function(anim_){
+            let arr = anim_.split('\n')
+            let o_ = {}
+            arr.forEach(function(pair) {
+                let parts = pair.split("=");
+                if(parts[0].length > 0 && parts[1].length > 0) {
+                    let k = parts[0];
+                    let v = parts[1];
+                    o_[k] = v;
+                }
+            })
+            o.push(o_)
+        })
+
+        return o
+    },
 };
 
 export default LinkeditorLinks;
diff --git a/resources/linkeditor/js/linkeditor.previewLinks.js b/resources/linkeditor/js/linkeditor.previewLinks.js
new file mode 100644 (file)
index 0000000..d06fa0a
--- /dev/null
@@ -0,0 +1,13 @@
+function LinkeditorPreviewLinks(linkeditor) {
+    this.linkeditor = linkeditor;
+    this.init()
+}
+
+LinkeditorPreviewLinks.prototype = {
+    init: function () {
+        let links = this.linkeditor.links.getLinksOfPage(1);
+        console.log("links",links)
+    }
+}
+
+export default LinkeditorPreviewLinks;
index 42ca86cf6ec6d4509d7983762da44551e21abbce..369e7357ad7952b4336fcf50856629d97b7d0319 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"
+                       data-tooltip="{{__('Voir un aperçu des liens')}}"></a>
                     <a href="#" data-action="openFluidbook" data-icon="open-fluidbook"
                        data-tooltip="{{__('Ouvrir le fluidbook à la page courante')}}"></a>
-                    <a href="#" data-action="previewLinks" data-icon="preview-links"
-                       data-tooltip="{{__('Voir un aperçu des liens')}}"></a>
                 </nav>
                 <nav id="linkeditor-toolbar-right">
                     <div class="when-selection-3">