From: Stephen Cameron Date: Tue, 15 Jan 2019 16:18:16 +0000 (+0100) Subject: WIP #2498 @5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=cd968cde087a3bbaeba920671fe028f5897796c8;p=fluidbook-html5.git WIP #2498 @5 --- diff --git a/js/libs/fluidbook/fluidbook.menu.js b/js/libs/fluidbook/fluidbook.menu.js index c85bdd1c..df950132 100644 --- a/js/libs/fluidbook/fluidbook.menu.js +++ b/js/libs/fluidbook/fluidbook.menu.js @@ -851,8 +851,16 @@ FluidbookMenu.prototype = { }); break; case 'print': - case 'download': + case 'download': w = 820; + + // If the option to print the full brochure is disabled, + // we change the print dialogue to a 2 column mode and narrower width + if (!this.fluidbook.datas.printFullBrochure) { + w = 560; + } + + // Enable fullscreen when there's no longer enough width for the popup if (ww < w) { fullscreen = true; } diff --git a/js/libs/fluidbook/fluidbook.print.js b/js/libs/fluidbook/fluidbook.print.js index 2bbed8ee..bc5b0841 100644 --- a/js/libs/fluidbook/fluidbook.print.js +++ b/js/libs/fluidbook/fluidbook.print.js @@ -20,7 +20,9 @@ FluidbookPrint.prototype = { element = $(this), mode = element.data('mode'), // Either 'print' or 'download' print = (mode == 'print'), - choice = $('input[name="pageChoice"]:checked').val(); + choice = $('input[name="pageChoice"]:checked').val(), + rangeStart = parseInt($('#pageRangeStart').val()), + rangeEnd = parseInt($('#pageRangeEnd').val()); switch (choice) { case 'left': @@ -39,11 +41,29 @@ FluidbookPrint.prototype = { case 'bookmarks': $this.fluidbook.bookmarks.openPDF(element, print); break; + case 'range': + if (isNaN(rangeStart) || + isNaN(rangeEnd) || + (rangeStart < 1) || + (rangeEnd > $this.fluidbook.datas.pages) || + (rangeStart > rangeEnd) + ) { + alert(__('Invalid page range. Please try again.')); + return false; + } + var pageRange = rangeStart + '-' + rangeEnd; + $this.fluidbook._openFile(dynamicPDF + pageRange, element, 'pdf', pageRange + '.pdf', print); + break; default: return false; } }); + // Automatically select page range option when clicking in the input fields + $(document).on('focus', '.page-range-input', function() { + $('#pageRange').prop('checked', true); + }); + // 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) { event.preventDefault(); @@ -131,17 +151,19 @@ FluidbookPrint.prototype = { } // Full Brochure - view += ''; // .print-option + if ((mode === 'print' && this.fluidbook.datas.printFullBrochure) || mode === 'download') { + view += ''; // .print-option + } // Bookmarks if (this.fluidbook.datas.bookmark) { @@ -154,12 +176,33 @@ FluidbookPrint.prototype = { view += this.fluidbook.bookmarks.getPrintPreview(); view += ''; // .doubleThumb view += ''; - view += '' + view += ''; view += ''; view += ''; // .print-option } - view += ''; // Extra empty div to ensure flexbox space-between works as expected + view += ''; // Extra empty div to ensure flexbox space-between works as expected + + // Page range inputs + if (mode === 'print' && this.fluidbook.datas.printPageRange) { + + // leftPageNumber may be false if on first page + var rangeStart = Math.max(leftPageNumber, 1); + + // Current page + 1 unless we're out of range. + // It has to be calculated this way because sometimes there is no rightPageNumber + var rangeEnd = Math.min(rangeStart + 1, this.fluidbook.datas.pages); + + view += ''; // .print-option + } view += ''; // .print-dialogue diff --git a/style/mixins.less b/style/mixins.less index ae1e82c4..e563fe2d 100644 --- a/style/mixins.less +++ b/style/mixins.less @@ -36,6 +36,10 @@ .menu-color-a(@background,@button) { background: @background; + input[type="text"] { + background: @button; + } + .fonctions { a { background-color: @button; @@ -63,4 +67,4 @@ &.hidden { opacity: 0; } -} \ No newline at end of file +} diff --git a/style/print.less b/style/print.less index 927858f1..a48156d5 100644 --- a/style/print.less +++ b/style/print.less @@ -6,6 +6,7 @@ justify-content: space-between; padding: 1.5em 2em 1em; margin-bottom: -2em; // Offset the margin-bottom on each