From: Stephen Cameron Date: Thu, 15 Nov 2018 09:14:58 +0000 (+0100) Subject: Add download options and take into account pdfComplex setting. WIP #1806 @1.75 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=a1c0052e7c7bd5e45a5b6a4b04710e3141fb1797;p=fluidbook-html5.git Add download options and take into account pdfComplex setting. WIP #1806 @1.75 --- diff --git a/js/libs/fluidbook/fluidbook.menu.js b/js/libs/fluidbook/fluidbook.menu.js index 3c578b13..abd6a505 100644 --- a/js/libs/fluidbook/fluidbook.menu.js +++ b/js/libs/fluidbook/fluidbook.menu.js @@ -99,6 +99,8 @@ FluidbookMenu.prototype = { this.openSearch(param1, cb); } else if (view == 'print') { this.openPrint(cb); + } else if (view == 'download') { + this.openDownload(cb); } else { this['open' + camelView](param1, param2, cb); } @@ -476,6 +478,22 @@ FluidbookMenu.prototype = { } }, + openDownload: function (callback) { + var downloadDialogue = '
' + this.closeButton() + '

' + __('Download') + '

'; + + downloadDialogue += this.fluidbook.printing.getView('download'); // Reuse print dialogue since they're almost the same + + $("#view").append('
' + downloadDialogue + '
'); + + // Auto select first option (the options are dynamic so we can't do it until now) + // Todo: maybe make this different for downloads? Auto select full brochure option? + $('.print-dialogue .print-option:first-of-type input[type="radio"]').prop('checked', true); + + if (callback != undefined) { + callback(); + } + }, + closeView: function (callback, all, animate) { if (callback === undefined) { callback = function () { diff --git a/js/libs/fluidbook/fluidbook.nav.js b/js/libs/fluidbook/fluidbook.nav.js index 680cb7aa..6f8883e9 100644 --- a/js/libs/fluidbook/fluidbook.nav.js +++ b/js/libs/fluidbook/fluidbook.nav.js @@ -688,8 +688,16 @@ FluidbookNav.prototype = { }); // Download icon - $(document).on('click', '.icon-download', function () { - $this.fluidbook.downloadPDF($(this)); + $(document).on('click', '.icon-download', function (event) { + event.preventDefault(); + + // Should we show complex PDF download options? Or just give them the full PDF? + if ($this.fluidbook.datas.pdfComplex) { + $this.fluidbook.menu.openView('download'); + } else { + $this.fluidbook.downloadPDF($(this)); + } + return false; }); diff --git a/js/libs/fluidbook/fluidbook.print.js b/js/libs/fluidbook/fluidbook.print.js index 9ef637f4..7bac0d64 100644 --- a/js/libs/fluidbook/fluidbook.print.js +++ b/js/libs/fluidbook/fluidbook.print.js @@ -8,8 +8,8 @@ FluidbookPrint.prototype = { var $this = this; - // Handle click on Print button inside dialogue - $(document).on('click', '#confirmPrint', function(event) { + // Handle click on Print/Download button inside dialogue + $(document).on('click', '#confirmChoice', function(event) { event.preventDefault(); // ToDo: Consider what happens if Fluidbook is self-hosted or offline (maybe here is not the best place to handle that) @@ -18,24 +18,26 @@ FluidbookPrint.prototype = { leftPageNumber = $this.fluidbook.getPhysicalPageNumberOfSide('left'), rightPageNumber = $this.fluidbook.getPhysicalPageNumberOfSide('right'), element = $(this), - choice = $('input[name="printChoice"]:checked').val(); + mode = element.data('mode'), // Either 'print' or 'download' + print = (mode == 'print'), + choice = $('input[name="pageChoice"]:checked').val(); switch (choice) { case 'left': - $this.fluidbook._openFile(dynamicPDF + leftPageNumber, element, 'pdf', leftPageNumber + '.pdf', true); + $this.fluidbook._openFile(dynamicPDF + leftPageNumber, element, 'pdf', leftPageNumber + '.pdf', print); break; case 'right': - $this.fluidbook._openFile(dynamicPDF + rightPageNumber, element, 'pdf', rightPageNumber + '.pdf', true); + $this.fluidbook._openFile(dynamicPDF + rightPageNumber, element, 'pdf', rightPageNumber + '.pdf', print); break; case 'double': var pageRange = leftPageNumber + '-' + rightPageNumber; - $this.fluidbook._openFile(dynamicPDF + pageRange, element, 'pdf', pageRange + '.pdf', true); + $this.fluidbook._openFile(dynamicPDF + pageRange, element, 'pdf', pageRange + '.pdf', print); break; case 'all': - $this.fluidbook.openPDF(element, true); + $this.fluidbook.openPDF(element, print); break; case 'bookmarks': - $this.fluidbook.bookmarks.openPDF(element, true); + $this.fluidbook.bookmarks.openPDF(element, print); break; default: return false; @@ -45,111 +47,119 @@ FluidbookPrint.prototype = { }); }, - getView: function () { + getView: function (mode) { + + // Ensure mode is either download or print (default) + mode = (mode == 'download' ? mode : 'print'); + // Todo: handle RTL differences for page numbers? See fluidbook.index.js for example var leftPageNumber = this.fluidbook.getPhysicalPageNumberOfSide('left'), rightPageNumber = this.fluidbook.getPhysicalPageNumberOfSide('right'), isFirstPage = (this.fluidbook.currentPage == 0), isLastPage = (this.fluidbook.currentPage == this.fluidbook.datas.pages), - isSinglePageMode = (this.fluidbook.resize.orientation == 'portrait'); - printDialogue = ''; + isSinglePageMode = (this.fluidbook.resize.orientation == 'portrait'), + buttonLabels = { + 'print' : __('Print'), + 'download' : __('Download') + }, + view = ''; - printDialogue += '
'; - printDialogue += ''; // .content + view += '
'; // .content - return printDialogue; + return view; } }; diff --git a/style/fluidbook.less b/style/fluidbook.less index 08a5276e..4ae6bc11 100644 --- a/style/fluidbook.less +++ b/style/fluidbook.less @@ -1363,7 +1363,7 @@ html.ios body.portrait #interface { } } - &[data-menu="print"] { + &[data-menu="print"], &[data-menu="download"] { max-width: 820px; }