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
});
});
}
-
-
- $(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 () {
} 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') {
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();
--- /dev/null
+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