From 645c856f22fa221aee7c7e3019a0c98a572c71ee Mon Sep 17 00:00:00 2001 From: Michael Ang Date: Mon, 21 Sep 2009 22:50:16 +0000 Subject: [PATCH] Improved print UI --- GnuBook/GnuBook.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/GnuBook/GnuBook.js b/GnuBook/GnuBook.js index 5441dd7..5243320 100644 --- a/GnuBook/GnuBook.js +++ b/GnuBook/GnuBook.js @@ -2421,9 +2421,9 @@ GnuBook.prototype.printPage = function() { this.indexToPrint = indexToPrint; var htmlStr = '
'; - htmlStr = '

Click here to print

'; + htmlStr = '

Click here to print this page

'; htmlStr += '
' - htmlStr += '

'; + htmlStr += '

'; //htmlStr += ' '; //htmlStr += ''; htmlStr += 'Prev Next'; @@ -2447,12 +2447,14 @@ GnuBook.prototype.printPage = function() { $('body', doc).html(self.getPrintFrameContent(self.indexToPrint)); }); - $('#printDiv').append(iframe); + $('#printDiv').prepend(iframe); } -GnuBook.prototype.getPrintFrameContent = function(index) { - var imageAspect = this.getPageWidth(index) / this.getPageHeight(index); - var paperAspect = 8.5 / 11; // Use US Letter in portrait as guesstimate +GnuBook.prototype.getPrintFrameContent = function(index) { + // We fit the image based on an assumed US Letter aspect ratio. + var paperAspect = 8.5 / 11; + var imageAspect = this.getPageWidth(index) / this.getPageHeight(index); + var rotate = 0; // Rotate if possible and appropriate, to get larger image size on printed page @@ -2467,16 +2469,16 @@ GnuBook.prototype.getPrintFrameContent = function(index) { var fitAttrs; if (imageAspect > paperAspect) { // wider than paper, fit width - fitAttrs = 'width="95%"'; + fitAttrs = 'width="100%"'; } else { // taller than paper, fit height - fitAttrs = 'height="95%"'; + fitAttrs = 'height="100%"'; } var imageURL = this.getPageURI(index, 1, rotate); - var iframeStr = '' + this.bookTitle + ''; - iframeStr += '

'; - iframeStr += '

'; + var iframeStr = '' + this.bookTitle + ''; + iframeStr += '
'; + iframeStr += ''; iframeStr += '
'; iframeStr += ''; -- 2.20.1