From: Vincent Vanwaelscappel Date: Wed, 23 Jan 2019 14:47:58 +0000 (+0100) Subject: wait #2531 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=7ba982f2b140c3305a4bf82c104088016ef520c9;p=fluidbook-html5.git wait #2531 @1 --- diff --git a/js/libs/fluidbook/fluidbook.nav.js b/js/libs/fluidbook/fluidbook.nav.js index e6c16a57..dd125eea 100644 --- a/js/libs/fluidbook/fluidbook.nav.js +++ b/js/libs/fluidbook/fluidbook.nav.js @@ -709,7 +709,7 @@ FluidbookNav.prototype = { // Print icon $(document).on('click', '.icon-print', function () { - if ($this.fluidbook.datas.phonegap !== false) { + if (!$this.fluidbook.printing.advancedPrint()) { $this.fluidbook.print($(this)); return false; } else { diff --git a/js/libs/fluidbook/fluidbook.print.js b/js/libs/fluidbook/fluidbook.print.js index 2bbed8ee..53fe2ff5 100644 --- a/js/libs/fluidbook/fluidbook.print.js +++ b/js/libs/fluidbook/fluidbook.print.js @@ -9,7 +9,7 @@ FluidbookPrint.prototype = { var $this = this; // Handle click on Print/Download button inside dialogue - $(document).on('click', '#confirmChoice', function(event) { + $(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) @@ -23,29 +23,29 @@ FluidbookPrint.prototype = { choice = $('input[name="pageChoice"]:checked').val(); switch (choice) { - case 'left': - $this.fluidbook._openFile(dynamicPDF + leftPageNumber, element, 'pdf', leftPageNumber + '.pdf', print); - break; - case 'right': - $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', print); - break; - case 'all': - $this.fluidbook.openPDF(element, print); - break; - case 'bookmarks': - $this.fluidbook.bookmarks.openPDF(element, print); - break; - default: - return false; + case 'left': + $this.fluidbook._openFile(dynamicPDF + leftPageNumber, element, 'pdf', leftPageNumber + '.pdf', print); + break; + case 'right': + $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', print); + break; + case 'all': + $this.fluidbook.openPDF(element, print); + break; + case 'bookmarks': + $this.fluidbook.bookmarks.openPDF(element, print); + break; + default: + return false; } }); // When there are no bookmarks a click on the bookmarks option will open the bookmarks help modal - $(document).on('click', '.bookmarks-option.disabled', function(event) { + $(document).on('click', '.bookmarks-option.disabled', function (event) { event.preventDefault(); $this.fluidbook.menu.quickCloseView(); @@ -66,8 +66,8 @@ FluidbookPrint.prototype = { isLastPage = (this.fluidbook.currentPage == this.fluidbook.datas.pages), isSinglePageMode = (this.fluidbook.resize.orientation == 'portrait'), buttonLabels = { - 'print' : __('print'), - 'download' : __('download') + 'print': __('print'), + 'download': __('download') }, view = ''; @@ -102,7 +102,7 @@ FluidbookPrint.prototype = { if (!isFirstPage) { view += '
'; } - view += '
'; // Only shows 1 page when on first page + view += '
'; // Only shows 1 page when on first page view += this.fluidbook.loader.getThumbImage(rightPageNumber, null, true); view += '
'; // .thumb view += '
'; // .doubleThumb @@ -145,18 +145,18 @@ FluidbookPrint.prototype = { // Bookmarks if (this.fluidbook.datas.bookmark) { - var hasBookmarks = this.fluidbook.bookmarks.hasBookmarkedPages(), - bookmarksDisabled = hasBookmarks ? '' : 'disabled'; - - view += ''; // .print-option + var hasBookmarks = this.fluidbook.bookmarks.hasBookmarkedPages(), + bookmarksDisabled = hasBookmarks ? '' : 'disabled'; + + view += ''; // .print-option } view += ''; // Extra empty div to ensure flexbox space-between works as expected @@ -165,12 +165,23 @@ FluidbookPrint.prototype = { // Action buttons view += '
'; - view += ''+ buttonLabels[mode] +''; + view += '' + buttonLabels[mode] + ''; view += '
'; // .fonctions view += ''; // .content return view; + }, + + advancedPrint: function () { + if (this.fluidbook.datas.phonegap !== false) { + return false; + } + if (this.fluidbook.support.offline && !this.fluidbook.datas.offlineEnableAdvancedPrinting) { + return false; + } + + return true; } };