Suggest user refresh the BookReader if we lost the network connection.
[bookreader.git] / BookReader / BookReader.js
index db5581d..26aebbe 100644 (file)
@@ -240,6 +240,21 @@ BookReader.prototype.init = function() {
         }
     });
     
+    if (this.protected) {
+        $('.BRpagediv1up').live('contextmenu dragstart', this, function(e) {
+            return false;
+        });
+        
+        $('.BRpageimage').live('contextmenu dragstart', this, function(e) {
+            return false;
+        });
+
+        $('.BRpagedivthumb').live('contextmenu dragstart', this, function(e) {
+            return false;
+        });
+        
+    }
+    
     $('.BRpagediv1up').bind('mousedown', this, function(e) {
         // $$$ the purpose of this is to disable selection of the image (makes it turn blue)
         //     but this also interferes with right-click.  See https://bugs.edge.launchpad.net/gnubook/+bug/362626
@@ -2393,8 +2408,11 @@ BookReader.prototype.setMouseHandlers2UP = function() {
     this.setClickHandler2UP( this.prefetchedImgs[this.twoPage.currentIndexL],
         { self: this },
         function(e) {
-            if (e.button == 2) {
+            if (e.which == 3) {
                 // right click
+                if (e.data.self.protected) {
+                    return false;
+                }
                 return true;
             }
                         
@@ -2409,8 +2427,11 @@ BookReader.prototype.setMouseHandlers2UP = function() {
     this.setClickHandler2UP( this.prefetchedImgs[this.twoPage.currentIndexR],
         { self: this },
         function(e) {
-            if (e.button == 2) {
+            if (e.which == 3) {
                 // right click
+                if (e.data.self.protected) {
+                    return false;
+                }
                 return true;
             }
             
@@ -3961,14 +3982,17 @@ BookReader.prototype.swipeMousedownHandler = function(event) {
     //console.log('swipe mousedown');
     //console.log(event);
 
+    var self = event.data['br'];
+
     // We should be the last bubble point for the page images
     // Disable image drag and select, but keep right-click
     if (event.which == 3) {
+        if (self.protected) {
+            return false;
+        }
         return true;
     }
     
-    var self = event.data['br'];
-
     $(event.target).bind('mouseout.swipe',
         { 'br': self},
         self.swipeMouseupHandler
@@ -4574,7 +4598,7 @@ BookReader.prototype.gotOpenLibraryRecord = function(self, olObject) {
         }
 
         // $$$mang cleanup
-        self.bookUrl = 'http://openlibrary.org' + olObject.key;
+        self.bookUrl = self.olHost + olObject.key;
         self.bookTitle = olObject['title'];
         $('#BRreturn a').attr( {'href': self.bookUrl, 'title': "Go to this book's page on Open Library" } );
         $('#BRreturn a').text(self.bookTitle);
@@ -4584,7 +4608,7 @@ BookReader.prototype.gotOpenLibraryRecord = function(self, olObject) {
         self.buildInfoDiv($('#BRinfo'));
         
         // Check for borrowed book
-        if (this.olAuth) {
+        if (self.olAuth) {
             var returnUrl = self.olHost + olObject.key + '/do_return/borrow';
             var borrowUrl = self.olHost + olObject.key + '/borrow';
             
@@ -4599,13 +4623,19 @@ BookReader.prototype.gotOpenLibraryRecord = function(self, olObject) {
                 .appendTo('#BRreturn');
             */
             
-            $('#BRreturn').css({ 'line-height': '19px'} );
-            
-            $('<form id="BRreturnform" action="' + returnUrl + '" method="post"><input type="submit" value="Return book" /><input type="hidden" name="action" value="return" /></form>')
+            $('<form id="BRreturnform" action="' + returnUrl + '" method="post"><input type="submit" value="Return book" onclick="olAuth.deleteCookies();"/><input type="hidden" name="action" value="return" /></form>')
                 .appendTo('#BRreturn');
 
+        } else {
+            $('<a/>').attr( { 'href': self.bookUrl, 'title': 'Go to this book\'s page on Open Library' } )
+                .text('On openlibrary.org')
+                .appendTo('#BRreturn');
         }
         
+        $('#BRreturn').css({ 'line-height': '19px'} );
+        $('#BRreturn a').css( {'height': '18px' } );
+
+        
     }
 }