From: Vincent Vanwaelscappel Date: Tue, 6 Jan 2026 15:18:42 +0000 (+0100) Subject: wip #7871 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ff4a2b0592b58c6bf8693d27bd2f0b22827fb9ed;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 9546e690..9f2d424e 100644 --- a/js/libs/fluidbook/fluidbook.menu.js +++ b/js/libs/fluidbook/fluidbook.menu.js @@ -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 += '
'; - c += '
'; - c += ''; - c += '
'; - 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 index 00000000..95cafdfa --- /dev/null +++ b/js/libs/fluidbook/menu/fluidbook.pdfform.js @@ -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 += '
'; + c += '
'; + c += ''; + c += '
'; + 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