Merge commit 'origin/master'
authorMichael Ang <mang@archive.org>
Fri, 24 Sep 2010 21:06:23 +0000 (21:06 +0000)
committerMichael Ang <mang@archive.org>
Fri, 24 Sep 2010 21:06:23 +0000 (21:06 +0000)
BookReader/BookReader.js
BookReaderDemo/BookReaderDemo.css [new file with mode: 0644]
BookReaderDemo/BookReaderJSSimple.js
BookReaderDemo/index.html

index 5390e66..a655dcd 100644 (file)
@@ -72,9 +72,13 @@ function BookReader() {
     this.lastDisplayableIndex2up = null;
     
     // We link to index.php to avoid redirect which breaks back button
+    // Should be overriden (before init) by custom implmentations.
     this.logoURL = 'http://www.archive.org/index.php';
     
-    // Base URL for images
+    // Base URL for UI images - should be overriden (before init) by
+    // custom implementations.
+    // $$$ This is the same directory as the images referenced by relative
+    //     path in the CSS.  Would be better to automagically find that path.
     this.imagesBaseURL = '/bookreader/images/';
     
     // Mode constants
@@ -3186,7 +3190,15 @@ BookReader.prototype.initToolbar = function(mode, ui) {
     // Hide mode buttons and autoplay if 2up is not available
     // $$$ if we end up with more than two modes we should show the applicable buttons
     if ( !this.canSwitchToMode(this.constMode2up) ) {
-        jToolbar.find('.one_page_mode, .two_page_mode, .play, .pause').hide();
+        jToolbar.find('.two_page_mode, .play, .pause').hide();
+    }
+    if ( !this.canSwitchToMode(this.constModeThumb) ) {
+        jToolbar.find('.thumbnail_mode').hide();
+    }
+    
+    // Hide one page button if it is the only mode available
+    if ( ! (this.canSwitchToMode(this.constMode2up) || this.canSwitchToMode(this.constModeThumb)) ) {
+        jToolbar.find('.one_page_mode').hide();
     }
 
     // Switch to requested mode -- binds other click handlers
@@ -3654,11 +3666,11 @@ BookReader.prototype.startLocationPolling = function() {
 //________
 // Returns true if we can switch to the requested mode
 BookReader.prototype.canSwitchToMode = function(mode) {
-    if (mode == this.constMode2up) {
+    if (mode == this.constMode2up || mode == this.constModeThumb) {
         // check there are enough pages to display
         // $$$ this is a workaround for the mis-feature that we can't display
         //     short books in 2up mode
-        if (this.numLeafs < 6) {
+        if (this.numLeafs < 2) {
             return false;
         }
     }
diff --git a/BookReaderDemo/BookReaderDemo.css b/BookReaderDemo/BookReaderDemo.css
new file mode 100644 (file)
index 0000000..6d88d64
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * Custom overrides for BookReader Demo.
+ */
+
+/* Hide print and embed functionality */
+#BRtoolbar .embed, .print {
+    display: none;
+}
index 4d08470..fe3219a 100644 (file)
@@ -18,7 +18,10 @@ br.getPageHeight = function(index) {
 
 // We load the images from archive.org -- you can modify this function to retrieve images
 // using a different URL structure
-br.getPageURI = function(index) {
+br.getPageURI = function(index, reduce, rotate) {
+    // reduce and rotate are ignored in this simple implementation, but we
+    // could e.g. look at reduce and load images from a different directory
+    // or pass the information to an image server
     var leafStr = '000';            
     var imgStr = (index+1).toString();
     var re = new RegExp("0{"+imgStr.length+"}$");
@@ -77,8 +80,11 @@ br.getPageNum = function(index) {
 br.numLeafs = 15;
 
 // Book title and the URL used for the book title link
-br.bookTitle= 'Open Library Bookreader Presentation';
+br.bookTitle= 'Open Library BookReader Presentation';
 br.bookUrl  = 'http://openlibrary.org';
 
+// Override the path used to find UI images
+br.imagesBaseURL = '../BookReader/images/';
+
 // Let's go!
 br.init();
index 6dcc1da..12932fe 100644 (file)
@@ -3,7 +3,11 @@
 <html>
 <head>
     <title>bookreader demo</title>
-    <link rel="stylesheet" type="text/css" href="../BookReader/BookReader.css">    
+    
+    <link rel="stylesheet" type="text/css" href="../BookReader/BookReader.css"></link>
+    <!-- Custom CSS overrides -->
+    <link rel="stylesheet" type="text/css" href="BookReaderDemo.css"></link>
+    
     <script type="text/javascript" src="http://www.archive.org/download/BookReader/lib/jquery-1.2.6.min.js"></script>
     <script type="text/javascript" src="http://www.archive.org/download/BookReader/lib/jquery.easing.1.3.js"></script>
     <script type="text/javascript" src="../BookReader/BookReader.js"></script>