]> _ Git - fluidbook-html5.git/commitdiff
wip #7871 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 7 Jan 2026 10:32:35 +0000 (11:32 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 7 Jan 2026 10:32:42 +0000 (11:32 +0100)
js/libs/fluidbook/fluidbook.menu.js
js/libs/fluidbook/menu/fluidbook.pdfform.js

index 15e25cd4d2ebf79e81cf24c16e9b953dfaa79a8e..3d1368cddbdf822ff098eac79f8b21b048288466 100644 (file)
@@ -9,6 +9,8 @@ FluidbookMenu.prototype = {
         this.closeEventSent = false;
         this.index = new FluidbookIndex(this.fluidbook);
         this.pdfform = new FluidbookPDFForm(this.fluidbook);
+        console.log(this.pdfform);
+
         var $this = this;
 
         // Note: iOS won't catch click events unless the element has a cursor:pointer style
index 8cfde80f3d82ee2d7e51882c7ff1b4be7f983273..9151970d462ed42e81ed77a887dcc60edc6cca9c 100644 (file)
@@ -1,5 +1,8 @@
+/* __('please fill your email') */
+
 function FluidbookPDFForm(fluidbook) {
     this.fluidbook = fluidbook;
+    this.linkinfos = {};
     this.init();
 }
 
@@ -30,27 +33,38 @@ FluidbookPDFForm.prototype = {
             let data = {fields: fields};
             data.linkid = linkId;
             $this.fluidbook.service.call('pdfform', data, function (data) {
-                $this.confirmation();
+                console.log(data);
+                if (data.ok) {
+                    $this.confirmation();
+                } else if (data.error) {
+                    $this.error(data.error);
+                }
             }, undefined, 'POST');
+            $this.fluidbook.hideLoader(10);
             return false;
         });
     },
 
     confirmation: function () {
-        $this.fluidbook.hideLoader();
+        this.fluidbook.hideLoader();
         $('.mview.pdfform .content').html('<div class="confirmation">' + this.fluidbook.settings.pdfform_confirm + '</div>');
         $('.mview.pdfform').attr('data-max-width', 500);
         this.fluidbook.resize.resize();
     },
 
+    error: function (message) {
+        this.fluidbook.hideLoader();
+        this.fluidbook.tooltip.displayTooltipDuring(this.fluidbook.l10n.__(message), 3, 'error');
+    },
+
     open: function (uid, callback) {
         let $this = this;
-        var infos = this.fluidbook.settings.pdfLinks[uid];
+        this.linkinfos = this.fluidbook.settings.pdfLinks[uid];
         let c = this.fluidbook.menu.getCaption('', 'nocaption', 'nocaption');
         c += '<div class="content">';
-        c += '<div class="pdf-holder"><iframe class="pdf view ' + infos.interface + '" data-width="' + infos.width + '" data-height="' + infos.height + '" data-total-height="' + infos.totalHeight + '" frameborder="0" scrolling="no" src="pdfjs/web/viewer.' + this.fluidbook.settings.htmlExtension + '?&file=../../data/links/' + infos.file + '#zoom=page-width"></iframe></div>';
+        c += '<div class="pdf-holder"><iframe class="pdf view ' + this.linkinfos.interface + '" data-width="' + this.linkinfos.width + '" data-height="' + this.linkinfos.height + '" data-total-height="' + this.linkinfos.totalHeight + '" frameborder="0" scrolling="no" src="pdfjs/web/viewer.' + this.fluidbook.settings.htmlExtension + '?&file=../../data/links/' + this.linkinfos.file + '#zoom=page-width"></iframe></div>';
         c += '<div class="fonctions">';
-        c += '<span>' + this.fluidbook.settings.pdfform_text + '</span>';
+        c += '<span>' + this.replaceContents(this.fluidbook.settings.pdfform_text) + '</span>';
         c += '<a role="button" class="submit" href="#">' + (this.fluidbook.settings.pdfform_button ? this.fluidbook.settings.pdfform_button : this.fluidbook.l10n.__('send')) + '</a>';
         c += '</div>';
         c += '</div>';
@@ -66,5 +80,9 @@ FluidbookPDFForm.prototype = {
         this.fluidbook.displayLoader();
     },
 
+    replaceContents: function (c) {
+        c = c.replace('%recipient%', this.linkinfos.recipient ? this.linkinfos.recipient : this.fluidbook.settings.pdfform_to);
+        return c;
+    },
 
 };
\ No newline at end of file