]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5447 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 17 Mar 2023 08:55:07 +0000 (09:55 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 17 Mar 2023 08:55:07 +0000 (09:55 +0100)
resources/linkeditor/js/linkeditor.links.js
resources/views/fluidbook_publication/link_editor.blade.php

index 32e73799d9c79fffb583731c2396011b2149dc53..170e8187748cc961c028e4b0d9dc544238fb992e 100644 (file)
@@ -228,6 +228,29 @@ LinkeditorLinks.prototype = {
                         };
                     }
                 }
+                if (hasSelection && !multiple) {
+                    res.items = $.extend(res.items, {
+                        'sep_extends': '---------',
+                        'cover_1': {
+                            isHtmlName: true,
+                            name: TRANSLATIONS.cover_page_1,
+                            callback: function () {
+                                $this.coverPage(1);
+                            },
+                        }
+                    });
+                    if (!$this.linkeditor.single) {
+                        res.items = $.extend(res.items, {
+                            'cover_double_1': {
+                                isHtmlName: true,
+                                name: TRANSLATIONS.cover_doublepage_1,
+                                callback: function () {
+                                    $this.coverPage(1, true);
+                                },
+                            }
+                        });
+                    }
+                }
                 if (hasSelection) {
                     res.items = $.extend(res.items, {
                         'sep0': '---------',
@@ -991,6 +1014,30 @@ LinkeditorLinks.prototype = {
             max = Math.max(max, parseFloat($(this).attr('fb-' + b)) + parseFloat($(this).attr('fb-' + l)));
         });
         return {min: min, max: max, side: b, length: l};
+    },
+
+    coverPage(margin, double) {
+        if (double === undefined) {
+            double = true;
+        }
+        if (margin === undefined) {
+            margin = 0;
+        }
+        var link = this.getCurrentSelection().eq(0);
+        var rect = {
+            x: -margin,
+            y: -margin,
+            width: this.linkeditor.fw + margin * 2,
+            height: this.linkeditor.ph + margin * 2,
+        };
+        if (!this.linkeditor.single && !double) {
+            if (parseFloat($(link).attr('fb-left')) > this.linkeditor.pw) {
+                rect.x = this.linkeditor.pw - margin;
+            }
+            rect.width = this.linkeditor.pw + margin * 2;
+        }
+        link.attr('fb-left', rect.x).attr('fb-top', rect.y).attr('fb-width', rect.width).attr('fb-height', rect.height);
+        this.linkeditor.hasChanged();
     }
 };
 
index d03cb146abbce968ccd7e26ae04ca33190e20b89..1618fadee9e3e35e6ab916ee5844380a628b8e82 100644 (file)
@@ -56,6 +56,8 @@
         'cut'=>__('Couper'),
         'paste_here'=>__('Coller ici'),
         'paste_in_place'=>__('Coller en place'),
+        'cover_page_1'=>__('Recouvrir la page avec une marge de :margin',['margin'=>'1px']),
+        'cover_doublepage_1'=>__('Recouvrir la double-page avec une marge de :margin',['margin'=>'1px']),
     ];
 
     $rulers=!count($rulers)?'{}':json_encode($rulers);