From 51b17723fbe48935503b017220f605f13c058db3 Mon Sep 17 00:00:00 2001 From: Stephen Cameron Date: Tue, 13 Nov 2018 17:54:11 +0100 Subject: [PATCH] WIP #1806 @7.5 --- js/libs/fluidbook/fluidbook.bookmarks.js | 35 +++++++- js/libs/fluidbook/fluidbook.js | 1 + js/libs/fluidbook/fluidbook.menu.js | 85 +----------------- js/libs/fluidbook/fluidbook.print.js | 110 +++++++++++++++++++++++ style/print.less | 30 +++++++ 5 files changed, 179 insertions(+), 82 deletions(-) create mode 100644 js/libs/fluidbook/fluidbook.print.js diff --git a/js/libs/fluidbook/fluidbook.bookmarks.js b/js/libs/fluidbook/fluidbook.bookmarks.js index d8e7d1b1..8a906126 100644 --- a/js/libs/fluidbook/fluidbook.bookmarks.js +++ b/js/libs/fluidbook/fluidbook.bookmarks.js @@ -491,6 +491,39 @@ FluidbookBookmarks.prototype = { // Used by the print function. Will return maximum of 3 pages or a blank page if no bookmarks. getPrintPreview: function() { - return '[bookmark images go here]'; + + if (!this.hasBookmarkedPages()) { + return '
'; + } + + + var maxImages = 3, // How many images maximum to show in the bookmarks print preview thumbnail + count = 0, + html = '', + groups = this.getBookmarkedGroups(); + + html += '
'; + + for (var g = 0; g < groups.length; g++) { + count++; + var group = groups[g]; + + html += '
' + this.fluidbook.loader.getThumbImage(group.page); + + if (this.fluidbook.bookmarks.enabled) { + html += this.fluidbook.bookmarks.getBookmarkForPage(group.page, true, true); + } + + html += '
'; + + // Stop once we have enough images for the preview + if (count >= maxImages) { + break; + } + } + + html += '
'; + + return html; } }; diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index 94bcb5ac..2879cdef 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -55,6 +55,7 @@ Fluidbook.prototype = { this.audiodescription = new FluidbookAudioDescription(this); this.sound = new FluidbookSound(this); this.slideshow = new FluidbookSlideshow(this); + this.printing = new FluidbookPrint(this); if (this.datas.basket) { diff --git a/js/libs/fluidbook/fluidbook.menu.js b/js/libs/fluidbook/fluidbook.menu.js index 31ab0666..16764737 100644 --- a/js/libs/fluidbook/fluidbook.menu.js +++ b/js/libs/fluidbook/fluidbook.menu.js @@ -462,89 +462,12 @@ FluidbookMenu.prototype = { }, openPrint: function (callback) { - // Todo: handle RTL differences for page numbers? See fluidbook.index.js for example - var leftPageNumber = parseInt(this.fluidbook.getPageNumberOfSide('left')), - rightPageNumber = parseInt(this.fluidbook.getPageNumberOfSide('right')), - isFirstPage = (this.fluidbook.currentPage == 0), - isLastPage = (this.fluidbook.currentPage == this.fluidbook.datas.pages), - printDialogue = '
' + this.closeButton() + '

' + __('Print') + '

'; - printDialogue += '
'; - printDialogue += ''; // .print-dialogue - printDialogue += '
'; // .content + var printDialogue = '
' + this.closeButton() + '

' + __('Print') + '

'; + + printDialogue += this.fluidbook.printing.getView(); $("#view").append('
' + printDialogue + '
'); + if (callback != undefined) { callback(); } diff --git a/js/libs/fluidbook/fluidbook.print.js b/js/libs/fluidbook/fluidbook.print.js new file mode 100644 index 00000000..e879fa1d --- /dev/null +++ b/js/libs/fluidbook/fluidbook.print.js @@ -0,0 +1,110 @@ +function FluidbookPrint(fluidbook) { + this.fluidbook = fluidbook; + this.init(); +} + +FluidbookPrint.prototype = { + init: function () { + + // Handle click on Print button inside dialogue + $(document).on('click', '#confirmPrint', function(event) { + event.preventDefault(); + + // ToDo: handle print option selection - either send for full document or generate dynamic workshop URL. Need to also consider what happens if Fluidbook is self-hosted or offline (maybe here is not the best place to handle that) + + }); + }, + + getView: function () { + // Todo: handle RTL differences for page numbers? See fluidbook.index.js for example + var leftPageNumber = parseInt(this.fluidbook.getPageNumberOfSide('left')), + rightPageNumber = parseInt(this.fluidbook.getPageNumberOfSide('right')), + isFirstPage = (this.fluidbook.currentPage == 0), + isLastPage = (this.fluidbook.currentPage == this.fluidbook.datas.pages), + printDialogue = ''; + + printDialogue += '
'; + printDialogue += ''; // .print-dialogue + + // Action buttons + printDialogue += '
'; + printDialogue += ''+ __('Print') +''; + printDialogue += '
'; // .fonctions + + printDialogue += '
'; // .content + + return printDialogue; + } +}; + diff --git a/style/print.less b/style/print.less index 5773d10b..9292ec67 100644 --- a/style/print.less +++ b/style/print.less @@ -4,6 +4,7 @@ flex-wrap: wrap; text-align: left; padding: 1em 2em; + margin-bottom: -2em; // Offset the margin-bottom on each