]> _ Git - fluidbook-html5.git/commitdiff
wip #7871 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 5 Jan 2026 18:42:49 +0000 (19:42 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 5 Jan 2026 18:42:49 +0000 (19:42 +0100)
js/libs/fluidbook/fluidbook.menu.js

index 1a6d78c0e3dabddfaa12af58a0bed85e903e6338..ad0fbbd0584749ac53c1ddf76c508b33b433663a 100644 (file)
@@ -41,6 +41,34 @@ 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 () {
@@ -131,13 +159,15 @@ FluidbookMenu.prototype = {
             this.openDownload(cb);
         } else if (view === 'pdf') {
             this.openPDF(param1, cb);
+        } else if (view === 'pdfform') {
+            this.openPDFForm(param1, cb);
         } else if (view === 'o3d') {
             this.openObject3D(param1, cb);
         } else if (view === 'article') {
             this.fluidbook.articles.openArticle(param1, cb);
-        } else if(view==='accessibility'){
+        } else if (view === 'accessibility') {
             this.fluidbook.accessibility.openMenu(cb);
-        }else {
+        } else {
             this['open' + camelView](param1, param2, cb);
         }
 
@@ -172,6 +202,28 @@ 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 += '<a role="button" class="submit" href="#">' + this.fluidbook.l10n.__('send') + '</a>';
+        c += '</div>';
+        c += '</div>';
+        this.viewWrap(c, 'pdfform', 'data-linkid="' + uid + '"', 'pdfform');
+        if (callback != undefined) {
+            callback();
+        }
+
+        $('iframe.pdf.view').each(function () {
+            relayIframeScrollToView($(this));
+        });
+
+        this.fluidbook.displayLoader();
+    },
+
 
     openingView: function (callback, view) {
         var $this = this;
@@ -825,6 +877,7 @@ FluidbookMenu.prototype = {
         var contentHeight = null;
         var fullscreen = m.data('fullscreen') === '1';
         var nw, nh;
+        let seamless, offsetw;
 
         var maxWidth = 100000;
         if (m.data('max-width')) {
@@ -881,7 +934,7 @@ FluidbookMenu.prototype = {
                 fullscreen = true;
                 break;
             case 'accessibility':
-                w=900;
+                w = 900;
                 h = hh * 0.9;
                 break;
             case 'share':
@@ -1164,7 +1217,24 @@ FluidbookMenu.prototype = {
             case 'pdf':
                 this.initPDFViewer();
                 iframe = m.find('iframe');
-                let seamless = iframe.hasClass('seamless');
+                seamless = iframe.hasClass('seamless');
+                var pw = iframe.data('width') * 2;
+                var th = iframe.data('total-height') * 2;
+
+                w = Math.min(pw, ww)
+                fullscreen = (w === ww);
+                ratio = pw / th;
+                ih = w / ratio;
+                h = Math.min(ih, fullscreen ? hh : hh * 0.9);
+
+                offsetw = seamless ? 40 : 0;
+
+                iframe.css('height', seamless ? ih : h).css('width', w + offsetw);
+                break;
+            case 'pdfform':
+                this.initPDFViewer();
+                iframe = m.find('iframe');
+                seamless = iframe.hasClass('seamless');
                 var pw = iframe.data('width') * 2;
                 var th = iframe.data('total-height') * 2;
 
@@ -1174,7 +1244,7 @@ FluidbookMenu.prototype = {
                 ih = w / ratio;
                 h = Math.min(ih, fullscreen ? hh : hh * 0.9);
 
-                let offsetw = seamless ? 40 : 0;
+                offsetw = seamless ? 40 : 0;
 
                 iframe.css('height', seamless ? ih : h).css('width', w + offsetw);
                 break;