From: Michael Ang Date: Mon, 21 Sep 2009 21:00:49 +0000 (+0000) Subject: Add ability to go to previous or next pages when printing. X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=c76f612ccca65fe89d11ab9764169b99592c4483;p=bookreader.git Add ability to go to previous or next pages when printing. --- diff --git a/GnuBook/GnuBook.js b/GnuBook/GnuBook.js index 2861113..9ac1ee4 100644 --- a/GnuBook/GnuBook.js +++ b/GnuBook/GnuBook.js @@ -2418,7 +2418,10 @@ GnuBook.prototype.printPage = function() { indexToPrint = this.twoPage.currentIndexL; } + this.indexToPrint = indexToPrint; + var htmlStr = '

Click here to print this page

'; + htmlStr += '

Prev Next

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

Close popup

'; @@ -2434,7 +2437,7 @@ GnuBook.prototype.printPage = function() { $(iframe).load(function() { var doc = GnuBook.util.getIFrameDocument(this); - $('body', doc).html(self.getPrintFrameContent(indexToPrint)); + $('body', doc).html(self.getPrintFrameContent(self.indexToPrint)); }); $('#printDiv').append(iframe); @@ -2471,6 +2474,17 @@ GnuBook.prototype.getPrintFrameContent = function(index) { return iframeStr; } +GnuBook.prototype.updatePrintFrame = function(delta) { + var newIndex = this.indexToPrint + delta; + newIndex = GnuBook.util.clamp(newIndex, 0, this.numLeafs - 1); + if (newIndex == this.indexToPrint) { + return; + } + this.indexToPrint = newIndex; + var doc = GnuBook.util.getIFrameDocument($('#printFrame')[0]); + $('body', doc).html(this.getPrintFrameContent(this.indexToPrint)); +} + // showEmbedCode() //______________________________________________________________________________ GnuBook.prototype.showEmbedCode = function() {