$(window).bind('resize', this, function(e) {
//console.log('resize!');
+
if (1 == e.data.mode) {
//console.log('centering 1page view');
if (e.data.autofit) {
this.firstIndex = startIndex;
this.prepareThumbnailView();
this.jumpToIndex(startIndex);
- } else {
- //this.resizePageView();
-
+ } else {
this.displayedIndices=[0];
this.firstIndex = startIndex;
this.displayedIndices = [this.firstIndex];
// it should start (doesn't jump after init)
this.initNavbar();
this.bindNavigationHandlers();
-
+
// Start AJAX request for OL data
if (this.getOpenLibraryRecord) {
this.getOpenLibraryRecord(this.gotOpenLibraryRecord);
}
+
}
BookReader.prototype.setupKeyListeners = function() {
//this.indicesToDisplay=[firstLeaf, firstLeaf+1];
//console.log('indicesToDisplay: ' + this.indicesToDisplay[0] + ' ' + this.indicesToDisplay[1]);
-
+
this.drawLeafsTwoPage();
this.updateToolbarZoom(this.reduce);
// set based on reduction factor
spreadSize = this.getSpreadSizeFromReduce(firstIndex, secondIndex, this.reduce);
}
-
+
// Both pages together
this.twoPage.height = spreadSize.height;
this.twoPage.width = spreadSize.width;
height: this._getPageHeight(secondIndex),
width: this._getPageWidth(secondIndex)
}
-
+
var firstIndexRatio = first.height / first.width;
var secondIndexRatio = second.height / second.width;
//console.log('firstIndexRatio = ' + firstIndexRatio + ' secondIndexRatio = ' + secondIndexRatio);
var ratio;
if (Math.abs(firstIndexRatio - canon5Dratio) < Math.abs(secondIndexRatio - canon5Dratio)) {
ratio = firstIndexRatio;
- //console.log('using firstIndexRatio ' + ratio);
} else {
ratio = secondIndexRatio;
- //console.log('using secondIndexRatio ' + ratio);
}
var totalLeafEdgeWidth = parseInt(this.numLeafs * 0.1);
// $$$ Don't hardcode ids
jToolbar.find('.share').colorbox({inline: true, opacity: "0.5", href: "#shareThis"});
jToolbar.find('.info').colorbox({inline: true, opacity: "0.5", href: "#aboutThis"});
-
+
$("body").append(
[
- '<div style="display: hidden;">',
+ '<div style="display: none;">',
this.makeShareDiv(),
this.makeAboutDiv(),
'</div>'
BookReader.prototype.gotOpenLibraryRecord = function(self, olObject) {
// $$$ could refactor this so that 'this' is available
if (olObject) {
+ // console.log(olObject);
if (olObject['table_of_contents']) {
// XXX check here that TOC is valid
self.updateTOC(olObject['table_of_contents']);
}
- }
-
- // $$$mang cleanup
- $('#BRreturn a').attr('href', 'http://openlibrary.org' + olObject.key);
+ // $$$mang cleanup
+ this.bookUrl = 'http://openlibrary.org' + olObject.key;
+ $('#BRreturn a').attr('href', this.bookUrl);
+ }
}
// Library functions
return (outer.document || outer);
},
+ escapeHTML: function (str) {
+ return(
+ str.replace(/&/g,'&').
+ replace(/>/g,'>').
+ replace(/</g,'<').
+ replace(/"/g,'"')
+ );
+ },
+
decodeURIComponentPlus: function(value) {
// Decodes a URI component and converts '+' to ' '
return decodeURIComponent(value).replace(/\+/g, ' ');
'<div class="BRfloatHead">About this book',
'<a class="floatShut" href="javascript:;" onclick="$.fn.colorbox.close();"><span class="shift">Close</span></a>',
'</div>',
- '<div class="BRfloatBody">',
- '<div class="BRfloatCover">',
- '<a href="Open Library Book Page"><img src="Open Library Book Cover" alt="Book Title" height="140"/></a>',
- '</div>',
+ '<div class="BRfloatBody">'
+ ];
+
+ // Use 3rd-party provided function if available
+ if (this.getInfoDiv) {
+ html.push(this.getInfoDiv());
+ } else {
+ html = html.concat([
'<div class="BRfloatMeta">',
'<div class="BRfloatTitle">',
- '<h2><a href="Open Library Book Page" class="title">Book Title</a></h2>',
- 'by',
- '<a href="Open Library Author Page">Book Author</a>',
+ '<h2><a href="', br.bookUrl, '" class="title">', BookReader.util.escapeHTML(br.bookTitle), '</a></h2>',
'</div>',
- '<p>Published MONTH YEAR by <a href="Open Library Publisher Page">Publisher name</a></p>',
- '<p>Written in <a href="Open Library Language page">Language</a></p>',
- '<h3>Other Formats</h3>',
- '<ul class="links">',
- '<li><a href="PDF Link">PDF</a><span>|</span></li>',
- '<li><a href="Text Link">Plain Text</a><span>|</span></li>',
- '<li><a href="DAISY Link">DAISY</a><span>|</span></li>',
- '<li><a href="PDF Link">ePub</a><span>|</span></li>',
- '<li><a href="Kindle Link">Send to Kindle</a><span>|</span></li>',
- '<li><a href="archive.org Page for Book">More...</a></li>',
- '</ul>',
- '<p class="moreInfo"><span></span>More information on <a href="Open Libarary Book Page">openlibrary.org</a>.</p>',
'</div>',
- '</div>',
- '<div class="BRfloatFoot">',
- '<a href="http://openlibrary.org/contact" class="problem">Report a problem</a>',
- '<span>|</span>',
- '<a href="http://openlibrary.org/dev/docs/bookreader">About the Bookreader</a>',
- '</div>',
- '</div>'
- ].join('\n');
+ ]);
+ }
- return html;
+ html = html.concat([
+ '</div>', // BRfloatBody
+ '<div class="BRfloatFoot">'
+ ]);
+
+ if (this.getInfoFooter) {
+ html.push(this.getInfoFooter());
+ } else {
+ html.push(
+ '<a href="http://openlibrary.org/dev/docs/bookreader">About the BookReader</a>'
+ );
+ }
+
+ html = html.concat([
+ '</div>', // BRfloatfoot
+ '</div>' // BRfloat
+ ]);
+
+ return html.join('\n');
}
});
}
+// getInfoDiv
+br.getInfoDiv = function() {
+ // $$$ it might make more sense to have a URL on openlibrary.org that returns this info
+
+ var escapedTitle = BookReader.util.escapeHTML(this.bookTitle);
+ var domainRe = /(\w+\.(com|org))/;
+ var domain = domainRe.exec(this.bookUrl)[1];
+ // XXX use different icon for archive.org
+ var html = [
+ '<div class="BRfloatCover">',
+ '<a href="', this.bookUrl, '"><img src="http://www.archive.org/download/', this.bookId, '/page/cover_t.jpg" alt="', escapedTitle, '" height="140"/></a>',
+ '</div>',
+ '<div class="BRfloatMeta">',
+ '<div class="BRfloatTitle">',
+ '<h2><a href="', this.bookUrl, '" class="title">', escapedTitle, '</a></h2>',
+ // $$$ lookup on OL
+ // 'by',
+ // '<a href="Open Library Author Page">Book Author</a>',
+ '</div>',
+ '<p>Published ', this.bookPublished,
+ //, <a href="Open Library Publisher Page">Publisher name</a>',
+ '</p>',
+ //'<p>Written in <a href="Open Library Language page">Language</a></p>',
+ '<h3>Other Formats</h3>',
+ '<ul class="links">',
+ '<li><a href="http://www.archive.org/download/', this.bookId, '/', this.subPrefix, '.pdf">PDF</a><span>|</span></li>',
+ '<li><a href="http://www.archive.org/download/', this.bookId, '/', this.subPrefix, '_djvu.txt">Plain Text</a><span>|</span></li>',
+ '<li><a href="http://www.archive.org/download/', this.bookId, '/', this.subPrefix, '_daisy.zip">DAISY</a><span>|</span></li>',
+ '<li><a href="http://www.archive.org/download/', this.bookId, '/', this.subPrefix, '.epub">ePub</a><span>|</span></li>',
+ '<li><a href="https://www.amazon.com/gp/digital/fiona/web-to-kindle?clientid=IA&itemid=', this.bookId, '&docid=', this.subPrefix, '">Send to Kindle</a><span>|</span></li>',
+ '<li><a href="', this.bookUrl, '">More...</a></li>',
+ '</ul>',
+ '<p class="moreInfo"><span></span>More information on <a href="'+ this.bookUrl + '">' + domain + '</a>.</p>',
+ '</div>',
+ '</div>',
+ '<div class="BRfloatFoot">',
+ // XXX add link to bug tracker
+ '<a href="http://openlibrary.org/contact" class="problem">Report a problem</a>',
+ '<span>|</span>',
+ '<a href="http://openlibrary.org/dev/docs/bookreader">About the Bookreader</a>',
+ '</div>'
+ ];
+
+ return html.join('\n');
+}
+
br.pageW = [
<?
$i=0;