.GBicon.one_page_mode { background: url(images/one_page_mode_icon.png) no-repeat; }
.GBicon.two_page_mode { background: url(images/two_page_mode_icon.png) no-repeat; }
.GBicon.embed { background: url(images/embed_icon.png) no-repeat; }
+.GBicon.print { background: url(images/print_icon.png) no-repeat; }
.GBicon.book_left { background: url(images/book_left_icon.png) no-repeat; }
.GBicon.book_right { background: url(images/book_right_icon.png) no-repeat; }
.GBicon.book_up { background: url(images/book_up_icon.png) no-repeat; }
this.twoPagePopUp = null;
this.leafEdgeTmp = null;
this.embedPopup = null;
+ this.printPopup = null;
this.searchResults = {};
}
}
+// printPage
+//______________________________________________________________________________
+GnuBook.prototype.printPage = function() {
+ if (null != this.printPopup) { // check if already showing
+ return;
+ }
+ this.printPopup = document.createElement("div");
+ $(this.printPopup).css({
+ position: 'absolute',
+ top: '20px',
+ left: ($('#GBcontainer').width()-400)/2 + 'px',
+ width: '500px',
+ padding: "20px",
+ border: "3px double #999999",
+ zIndex: 3,
+ backgroundColor: "#fff"
+ }).appendTo('#GnuBook');
+
+ var indexToPrint;
+ if (1 == this.mode) {
+ indexToPrint = this.firstIndex;
+ } else {
+ indexToPrint = this.currentLeafL;
+ }
+
+ htmlStr = '<p style="text-align:center;"><b><a href="javascript:void(0);" onclick="window.frames[0].print(); return false;">Click here to print this page</a></b></p>';
+ htmlStr += '<iframe name ="printFrame" id="printFrame" src="GnuBookPrint.php?id='+this.bookId+'&server='+this.server+'&zip='+this.zip+'&index='+this.leafMap[indexToPrint]+'&format='+this.imageFormat+'" width="500px" height="400px"></iframe>';
+ htmlStr += '<p style="text-align:center;"><a href="" onclick="gb.printPopup = null; $(this.parentNode.parentNode).remove(); return false">Close popup</a></p>';
+
+ this.printPopup.innerHTML = htmlStr;
+}
+
// showEmbedCode()
//______________________________________________________________________________
GnuBook.prototype.showEmbedCode = function() {
// We build in mode 2
jToolbar.append("<span id='GBtoolbarbuttons' style='float: right'>"
- + "<button class='GBicon rollover embed' />"
+ + "<button class='GBicon print' /> <button class='GBicon rollover embed' />"
+ "<form class='GBpageform' action='javascript:' onsubmit='gb.jumpToPage(this.elements[0].value)'> <span class='label'>Page:<input id='GBpagenum' type='text' size='3' onfocus='gb.autoStop();'></input></span></form>"
+ "<div class='GBtoolbarmode2' style='display: inline'><button class='GBicon rollover book_leftmost' /><button class='GBicon rollover book_left' /><button class='GBicon rollover book_right' /><button class='GBicon rollover book_rightmost' /></div>"
+ "<div class='GBtoolbarmode1' style='display: hidden'><button class='GBicon rollover book_top' /><button class='GBicon rollover book_up' /> <button class='GBicon rollover book_down' /><button class='GBicon rollover book_bottom' /></div>"
'.zoom_out': 'Zoom out',
'.one_page_mode': 'One-page view',
'.two_page_mode': 'Two-page view',
+ '.print': 'Print this page',
'.embed': 'Embed bookreader',
'.book_left': 'Flip left',
'.book_right': 'Flip right',
gb.next();
return false;
});
+
+ jToolbar.find('.print').bind('click', function(e) {
+ gb.printPage();
+ return false;
+ });
jToolbar.find('.embed').bind('click', function(e) {
gb.showEmbedCode();
var title = this.bookTitle.substr(0, maximumCharacters - 3);
title += '...';
return title;
-}
\ No newline at end of file
+}
// $$$ the remapping isn't totally automatic yet and requires user to
// ln -s ~/petabox/www/datanode/GnuBook ~/public_html/GnuBook
// so we enable it only for known hosts
- $devhosts = array('mang', 'testflip');
+ $devhosts = array('mang', 'testflip', 'rkumar');
if (in_array($match[1], $devhosts)) {
$serverBaseURL = $serverBaseURL . ":81/~" . $match[1];
}
--- /dev/null
+<?
+/*
+Copyright(c)2008 Internet Archive. Software license AGPL version 3.
+
+This file is part of GnuBook.
+
+ GnuBook is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GnuBook is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with GnuBook. If not, see <http://www.gnu.org/licenses/>.
+
+GnuBookPrint.php exists to get around the same-origin policy that prevents
+us from calling print() on an iframe that comes from a cluster datanode.
+*/
+
+$id = $_REQUEST['id'];
+$server = $_REQUEST['server'];
+$zip = $_REQUEST['zip'];
+$index = $_REQUEST['index'];
+$format = $_REQUEST['format'];
+
+$file = sprintf("%s_%s/%s_%04d.%s", $id, $format, $id, $index, $format);
+echo "<p style='text-align:center;'>";
+echo "<img src='http://{$server}/GnuBook/GnuBookImages.php?zip={$zip}&file={$file}&scale=1' height='100%'/>";
+echo "</p>";
+
+?>
\ No newline at end of file