Revert unintended "Merge branch 'read_aloud' of git@github.com:openlibrary/bookreader"
[bookreader.git] / BookReader / BookReader.js
index 7f23ef4..5390e66 100644 (file)
@@ -94,14 +94,14 @@ function BookReader() {
     // Object to hold parameters related to 1up mode
     this.onePage = {
         autofit: 'height'                                     // valid values are height, width, none
-    },
+    };
     
     // Object to hold parameters related to 2up mode
     this.twoPage = {
         coverInternalPadding: 10, // Width of cover
         coverExternalPadding: 10, // Padding outside of cover
         bookSpineDivWidth: 30,    // Width of book spine  $$$ consider sizing based on book length
-        autofit: 'auto',
+        autofit: 'auto'
     };
     
     return this;
@@ -1427,7 +1427,7 @@ BookReader.prototype.prepareTwoPageView = function(centerPercentageX, centerPerc
         visibility: 'visible',
         position: 'absolute',
         left: this.twoPage.bookCoverDivLeft + 'px',
-        top: this.twoPage.bookCoverDivTop+'px',
+        top: this.twoPage.bookCoverDivTop+'px'
     }).appendTo('#BRtwopageview');
     
     this.leafEdgeR = document.createElement('div');
@@ -1436,7 +1436,7 @@ BookReader.prototype.prepareTwoPageView = function(centerPercentageX, centerPerc
         width: this.twoPage.leafEdgeWidthR + 'px',
         height: this.twoPage.height-1 + 'px',
         left: this.twoPage.gutter+this.twoPage.scaledWR+'px',
-        top: this.twoPage.bookCoverDivTop+this.twoPage.coverInternalPadding+'px',
+        top: this.twoPage.bookCoverDivTop+this.twoPage.coverInternalPadding+'px'
     }).appendTo('#BRtwopageview');
     
     this.leafEdgeL = document.createElement('div');
@@ -1445,7 +1445,7 @@ BookReader.prototype.prepareTwoPageView = function(centerPercentageX, centerPerc
         width: this.twoPage.leafEdgeWidthL + 'px',
         height: this.twoPage.height-1 + 'px',
         left: this.twoPage.bookCoverDivLeft+this.twoPage.coverInternalPadding+'px',
-        top: this.twoPage.bookCoverDivTop+this.twoPage.coverInternalPadding+'px',    
+        top: this.twoPage.bookCoverDivTop+this.twoPage.coverInternalPadding+'px'
     }).appendTo('#BRtwopageview');
 
     div = document.createElement('div');
@@ -1522,7 +1522,7 @@ BookReader.prototype.prepareTwoPagePopUp = function() {
     this.twoPagePopUp = document.createElement('div');
     this.twoPagePopUp.className = 'BRtwoPagePopUp';
     $(this.twoPagePopUp).css({
-        zIndex: '1000',
+        zIndex: '1000'
     }).appendTo('#BRcontainer');
     $(this.twoPagePopUp).hide();
     
@@ -2309,6 +2309,12 @@ BookReader.prototype.prefetchImg = function(index) {
         //console.log('prefetching ' + index);
         var img = document.createElement("img");
         img.className = 'BRpageimage';
+        if (index < 0 || index > (this.numLeafs - 1) ) {
+            // Facing page at beginning or end, or beyond
+            $(img).css({
+                'background-color': 'transparent'
+            });
+        }
         img.src = pageURI;
         img.uri = pageURI; // browser may rewrite src so we stash raw URI here
         this.prefetchedImgs[index] = img;
@@ -2852,7 +2858,7 @@ BookReader.prototype.getPrintURI = function() {
         indexToPrint = this.firstIndex; // $$$ the index in the middle of the viewport would make more sense
     }
     
-    var options = 'id=' + this.bookId + '&server=' + this.server + '&zip=' + this.zip
+    var options = 'id=' + this.subPrefix + '&server=' + this.server + '&zip=' + this.zip
         + '&format=' + this.imageFormat + '&file=' + this._getPageFile(indexToPrint)
         + '&width=' + this._getPageWidth(indexToPrint) + '&height=' + this._getPageHeight(indexToPrint);
    
@@ -3306,7 +3312,7 @@ BookReader.prototype.updateToolbarZoom = function(reduce) {
     }
     
     if (autofit) {
-        value = autofit[0].toUpperCase() + autofit.slice(1);
+        value = autofit.slice(0,1).toUpperCase() + autofit.slice(1);
     } else {
         value = (100 / reduce).toFixed(2);
         // Strip trailing zeroes and decimal if all zeroes