$this.fluidbook.alertInternetRequired();
return false;
}
- $this.fluidbook._openFile($this.getPDF(), $(this), 'pdf', $this.getBookmarksCompacted() + '.pdf');
+ $this.openPDF($(this), true);
return false;
});
sortnumeric: function (a, b) {
return a - b;
},
+ openPDF: function(element, print) {
+ print = print || false;
+ this.fluidbook._openFile(this.getPDF(), element, 'pdf', this.getBookmarksCompacted() + '.pdf', print);
+ },
getPDF: function () {
return 'https://workshop.fluidbook.com/s/e/' + this.fluidbook.datas.cid + '/' + this.getBookmarksCompacted();
},
}
if (this.fluidbook.datas.print || this.fluidbook.datas.pdf) {
+ // ToDo: differentiate between download & print?
index += '<a class="print" href="#">' + downloadLabel + '</a>';
}
index += '</div>';
index += '</div>';
return index;
+ },
+
+ // 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]';
}
};
this.openIframe(param1, cb);
} else if (view == 'search') {
this.openSearch(param1, cb);
+ } else if (view == 'print') {
+ this.openPrint(cb);
} else {
this['open' + camelView](param1, param2, cb);
}
}
},
+ 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 = '<div class="caption">' + this.closeButton() + '<h2>' + __('Print') + '</h2></div>';
+ printDialogue += '<div class="content">';
+ printDialogue += '<div class="print-dialogue">';
+
+ // ToDo: implement http://adrianroselli.com/2017/05/under-engineered-custom-radio-buttons-and-checkboxen.html - might need 2 labels for each input so thumbnails are clickable too.
+
+ // Left Page (empty when on first page)
+ if (!isFirstPage) {
+ printDialogue += '<label for="leftPage">';
+ printDialogue += '<div class="doubleThumb">';
+ printDialogue += '<div class="thumb left">';
+ printDialogue += this.fluidbook.loader.getThumbImage(leftPageNumber, null, true);
+ printDialogue += '</div>'; // .thumb
+ printDialogue += '<div class="thumb right blank"></div>';
+ printDialogue += '</div>'; // .doubleThumb
+ printDialogue += '<input type="radio" name="printChoice" value="'+ leftPageNumber +'" id="leftPage">';
+ printDialogue += '<span class="print-label-text">' + __('Left page') + '</span>';
+ printDialogue += '</label>';
+ }
+
+ // Right Page (empty when when on last page)
+ if (!isLastPage) {
+ printDialogue += '<label for="rightPage">';
+ printDialogue += '<div class="doubleThumb">';
+ printDialogue += '<div class="thumb left blank"></div>';
+ printDialogue += '<div class="thumb right">';
+ printDialogue += this.fluidbook.loader.getThumbImage(rightPageNumber, null, true);
+ printDialogue += '</div>'; // .thumb
+ printDialogue += '</div>'; // .doubleThumb
+ printDialogue += '<input type="radio" name="printChoice" value="'+ leftPageNumber +'" id="rightPage">';
+ printDialogue += '<span class="print-label-text">' + __('Right page') + '</span>';
+ printDialogue += '</label>';
+ }
+
+ // Double Page
+ if (!isFirstPage && !isLastPage) {
+ printDialogue += '<label for="doublePage">';
+ printDialogue += '<div class="doubleThumb">';
+ printDialogue += '<div class="thumb left">';
+ printDialogue += this.fluidbook.loader.getThumbImage(leftPageNumber, null, true);
+ printDialogue += '</div>';
+ printDialogue += '<div class="thumb right">';
+ printDialogue += this.fluidbook.loader.getThumbImage(rightPageNumber, null, true);
+ printDialogue += '</div>'; // .thumb
+ printDialogue += '</div>'; // .doubleThumb
+ printDialogue += '<input type="radio" name="printChoice" value="'+ leftPageNumber +','+ rightPageNumber +'" id="doublePage">'
+ printDialogue += '<span class="print-label-text">' + __('Double page') + '</span>';
+ printDialogue += '</label>';
+ }
+
+ // Full Brochure
+ printDialogue += '<label for="allPages">';
+ printDialogue += '<div class="doubleThumb">';
+ printDialogue += '<div class="thumb left">';
+ printDialogue += this.fluidbook.loader.getThumbImage(1, null, true);
+ printDialogue += '</div>'; // .thumb
+ printDialogue += '</div>'; // .doubleThumb
+ printDialogue += '<input type="radio" name="printChoice" value="all" id="allPages">'
+ printDialogue += '<span class="print-label-text">' + __('Full brochure') + '</span>';
+ printDialogue += '</label>';
+
+ // Bookmarks
+ var hasBookmarks = this.fluidbook.bookmarks.hasBookmarkedPages(),
+ bookmarksDisabled = hasBookmarks ? '' : 'disabled';
+
+ printDialogue += '<label for="bookmarkedPages">';
+ printDialogue += '<div class="doubleThumb bookmarks '+ bookmarksDisabled +'">';
+ printDialogue += this.fluidbook.bookmarks.getPrintPreview();
+ printDialogue += '</div>'; // .doubleThumb
+ printDialogue += '<input type="radio" name="printChoice" value="bookmarks" id="bookmarkedPages" '+ bookmarksDisabled +'>'
+ printDialogue += '<span class="print-label-text">' + __('My bookmarks') + '</span>';
+ printDialogue += '</label>';
+
+
+ printDialogue += '</div>'; // .print-dialogue
+ printDialogue += '</div>'; // .content
+
+ $("#view").append('<div class="mview" data-menu="print">' + printDialogue + '</div>');
+ if (callback != undefined) {
+ callback();
+ }
+ },
+
closeView: function (callback, all, animate) {
if (callback === undefined) {
callback = function () {
} else if (icon == 'pdf' && this.fluidbook.datas.pdf) {
link = this.addLink(navType, 'nav-download', '#', 'download', 'download', 'download');
} else if (icon == 'print' && this.fluidbook.datas.print) {
- link = this.addLink(navType, 'nav-print', '#', 'print', 'print', 'print');
+ link = this.addLink(navType, 'nav-print', '#/print', 'print', 'print', 'print');
} else if (icon == 'basket' && this.fluidbook.cart != undefined && this.fluidbook.cart.enabled) {
link = this.addLink(navType, 'nav-basket', '#/cart', 'cart', 'basket', 'basket');
$(this.fluidbook).on('fluidbook.cart.updateIcon', {link: $(link).attr('id')}, function (e, data) {
});
// Print icon
- $(document).on('click', '.icon-print', function () {
- $this.fluidbook.print($(this));
- return false;
- });
+ // $(document).on('click', '.icon-print', function () {
+ // $this.fluidbook.print($(this));
+ // return false;
+ // });
// Bookmarks icon
$(document).on('click', '.icon-bookmarks', function () {