From: Vincent Vanwaelscappel Date: Mon, 5 Jan 2026 18:42:49 +0000 (+0100) Subject: wip #7871 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=c1993278d6f2047317280e29ae94aabf72fb7db9;p=fluidbook-html5.git wip #7871 @0.5 --- diff --git a/js/libs/fluidbook/fluidbook.menu.js b/js/libs/fluidbook/fluidbook.menu.js index 1a6d78c0..ad0fbbd0 100644 --- a/js/libs/fluidbook/fluidbook.menu.js +++ b/js/libs/fluidbook/fluidbook.menu.js @@ -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 += '
'; + c += '
'; + c += ''; + c += '
'; + 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;