Disable image right-click for protected books
authorMichael Ang <mang@archive.org>
Tue, 1 Feb 2011 00:03:23 +0000 (00:03 +0000)
committerMichael Ang <mang@archive.org>
Tue, 1 Feb 2011 00:03:23 +0000 (00:03 +0000)
BookReader/BookReader.js
BookReader/BookReaderLending.css
BookReaderIA/datanode/BookReaderJSIA.php

index 2d9be07..6efb703 100644 (file)
@@ -240,6 +240,21 @@ BookReader.prototype.init = function() {
         }
     });
     
+    if (this.protected) {
+        $('.BRpagediv1up').live('contextmenu', this, function(e) {
+            return false;
+        });
+        
+        $('.BRpageimage').live('contextmenu', this, function(e) {
+            return false;
+        });
+
+        $('.BRpagedivthumb').live('contextmenu', 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
index 4326a88..7619c70 100644 (file)
@@ -4,6 +4,11 @@ Copyright(c)2011 Internet Archive. Software license AGPL version 3.
 This file is part of BookReader <http://github.com/openlibrary/bookreader
 */
 
+.BRpagediv1up, .BRpageimage, .BRpagedivthumb {
+    -moz-user-select: none;
+    -webkit-user-select: none;
+}
+
 @media print {
     .BRpagediv1up, .BRpageimage, .BRpagedivthumb {
         display: none;
index 5082569..5f2cde7 100644 (file)
@@ -529,9 +529,11 @@ if ('' != $metaData->{'page-progression'}) {
 }
 
 $useOLAuth = false;
+$protected = false;
 foreach ($metaData->xpath('//collection') as $collection) {
     if('browserlending' == $collection) {
         $useOLAuth = true;
+        $protected = true;
     }
 }
 
@@ -544,6 +546,10 @@ if ($useOLAuth) {
     echo "br.olAuth = false;\n";
 }
 
+if ($protected) {
+    echo "br.protected = true;\n";
+}
+
 # Special cases
 if ('bandersnatchhsye00scarrich' == $id) {
     echo "br.mode     = 2;\n";