]> _ Git - fluidbook-html5.git/commitdiff
wip #7871 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 6 Jan 2026 15:18:42 +0000 (16:18 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 6 Jan 2026 15:18:42 +0000 (16:18 +0100)
js/libs/fluidbook/fluidbook.menu.js
js/libs/fluidbook/menu/fluidbook.pdfform.js [new file with mode: 0644]

index 9546e690c6a625fb3cd6e5bf9def0d1322d282fa..9f2d424e9ca74cffc4b02382aa29e9e42fb67549 100644 (file)
@@ -8,6 +8,7 @@ FluidbookMenu.prototype = {
     init: function () {
         this.closeEventSent = false;
         this.index = new FluidbookIndex(this.fluidbook);
+        this.pdfform = new FluidbookPDFForm(this.fluidbook);
         var $this = this;
 
         // Note: iOS won't catch click events unless the element has a cursor:pointer style
@@ -41,34 +42,6 @@ FluidbookMenu.prototype = {
                 });
             });
         }
-
-
-        $(document).on('click', '.mview[data-menu="pdfform"] .fonctions a.submit', function () {
-            let linkId = $(this).closest('.mview').data('linkid');
-            let doc = $('.mview[data-menu="pdfform"] iframe').get(0).contentDocument;
-            let fields = {};
-            $(doc).find('select,textarea,input').each(function () {
-                if (!$(this).is(':visible')) {
-                    return;
-                }
-                let type = $(this).prop('tagName').toLowerCase();
-                if (type === "input") {
-                    type = $(this).attr('type');
-                }
-
-                let name = $(this).attr('name');
-                if ((type !== 'checkbox' && type !== 'radio')) {
-                    fields[name] = $(this).val();
-                } else if ($(this).is(':checked')) {
-                    fields[name] = ':checked:' + $(this).val();
-                }
-            });
-            let data = {fields: fields};
-            data.linkid = linkId;
-            $this.fluidbook.service.call('pdfform', data, function (data) {
-            }, undefined, 'POST');
-            return false;
-        });
     },
 
     viewMode: function () {
@@ -160,7 +133,7 @@ FluidbookMenu.prototype = {
         } else if (view === 'pdf') {
             this.openPDF(param1, cb);
         } else if (view === 'pdfform') {
-            this.openPDFForm(param1, cb);
+            this.pdfform.open(param1, cb);
         } else if (view === 'o3d') {
             this.openObject3D(param1, cb);
         } else if (view === 'article') {
@@ -202,30 +175,6 @@ FluidbookMenu.prototype = {
         this.fluidbook.displayLoader();
     },
 
-    openPDFForm: function (uid, callback) {
-        let $this = this;
-        var infos = this.fluidbook.settings.pdfLinks[uid];
-        let c = this.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="fonctions">';
-        c += '<span>' + 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>';
-        this.viewWrap(c, 'pdfform', 'data-linkid="' + uid + '"', 'pdfform ' + this.fluidbook.settings.pdfform_style);
-        if (callback != undefined) {
-            callback();
-        }
-
-        $('iframe.pdf.view').each(function () {
-            relayIframeScrollToView($(this));
-        });
-
-        this.fluidbook.displayLoader();
-    },
-
-
     openingView: function (callback, view) {
         var $this = this;
         this.fluidbook.resize.resizeView();
diff --git a/js/libs/fluidbook/menu/fluidbook.pdfform.js b/js/libs/fluidbook/menu/fluidbook.pdfform.js
new file mode 100644 (file)
index 0000000..95cafdf
--- /dev/null
@@ -0,0 +1,60 @@
+function FluidbookPDFForm(fluidbook) {
+    this.fluidbook = fluidbook;
+    this.init();
+}
+
+FluidbookPDFForm.prototype = {
+    init: function () {
+        $(document).on('click', '.mview[data-menu="pdfform"] .fonctions a.submit', function () {
+            let linkId = $(this).closest('.mview').data('linkid');
+            let doc = $('.mview[data-menu="pdfform"] iframe').get(0).contentDocument;
+            let fields = {};
+            $(doc).find('select,textarea,input').each(function () {
+                if (!$(this).is(':visible')) {
+                    return;
+                }
+                let type = $(this).prop('tagName').toLowerCase();
+                if (type === "input") {
+                    type = $(this).attr('type');
+                }
+
+                let name = $(this).attr('name');
+                if ((type !== 'checkbox' && type !== 'radio')) {
+                    fields[name] = $(this).val();
+                } else if ($(this).is(':checked')) {
+                    fields[name] = ':checked:' + $(this).val();
+                }
+            });
+            let data = {fields: fields};
+            data.linkid = linkId;
+            $this.fluidbook.service.call('pdfform', data, function (data) {
+            }, undefined, 'POST');
+            return false;
+        });
+    },
+
+    open: function (uid, callback) {
+        let $this = this;
+        var infos = this.fluidbook.settings.pdfLinks[uid];
+        let c = this.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="fonctions">';
+        c += '<span>' + 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>';
+        this.viewWrap(c, 'pdfform', 'data-linkid="' + uid + '"', 'pdfform ' + this.fluidbook.settings.pdfform_style);
+        if (callback != undefined) {
+            callback();
+        }
+
+        $('iframe.pdf.view').each(function () {
+            relayIframeScrollToView($(this));
+        });
+
+        this.fluidbook.displayLoader();
+    },
+
+
+};
\ No newline at end of file