Merge commit 'rajbot/newui' into newui
[bookreader.git] / BookReader / BookReader.js
index d9eb89b..e27838a 100644 (file)
@@ -80,9 +80,8 @@ 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://openlibrary.org';
+    this.logoURL = 'http://www.archive.org';
     
     // Base URL for UI images - should be overriden (before init) by
     // custom implementations.
@@ -2695,7 +2694,7 @@ BookReader.prototype.BRSearchCallback = function(results) {
         var errStr  = 'No matches were found.';
         var timeout = 1000;
         if (false === results.indexed) {
-            errStr  = "<p>This book isn't in the search engine yet.</p><p>Please <a href='http://openlibrary.org/contact?path=/stream/"+this.bookId+"/search'>drop us a line</a> so we can fix it. Thanks!</p>";
+            errStr  = "<p>This book isn't in the search engine yet.</p><p>Please <a href='http://openlibrary.org/contact?path=archive.org/stream/"+this.bookId+"/search'>drop us a line</a> so we can fix it. Thanks!</p>";
             timeout = 5000;
         }
         $(br.popup).html(errStr);
@@ -3574,7 +3573,7 @@ BookReader.prototype.initToolbar = function(mode, ui) {
         //+     "<button class='BRicon full'></button>"
         +   "</span>"
         +   "<span><a class='logo' href='" + this.logoURL + "'></a></span>"
-        +   "<span id='BRreturn'><span>Back to</span><a href='" + this.bookUrl + "'>" + this.bookTitle + "</a></span>" // XXX escape
+        +   "<span id='BRreturn'><a></a></span>"
         +   "<div id='BRnavCntlTop' class='BRnabrbuvCntl'></div>"
         + "</div>"
         /*
@@ -3591,6 +3590,14 @@ BookReader.prototype.initToolbar = function(mode, ui) {
         */
         );
 
+    // Browser hack - bug with colorbox on iOS 3 see https://bugs.launchpad.net/bookreader/+bug/686220
+    if ( navigator.userAgent.match(/ipad/i) && $.browser.webkit && (parseInt($.browser.version, 10) <= 531) ) {
+       $('#BRtoolbarbuttons .info').hide();
+       $('#BRtoolbarbuttons .share').hide();
+    }
+
+    $('#BRreturn a').attr('href', this.bookUrl).text(this.bookTitle);
+
     $('#BRtoolbar .BRnavCntl').addClass('BRup');
     $('#BRtoolbar .pause').hide();    
     
@@ -3901,14 +3908,6 @@ BookReader.prototype.bindNavigationHandlers = function() {
     $('.BRpageimage').die('mousedown.swipe').live('mousedown.swipe',
         { 'br': this },
         this.swipeMousedownHandler
-    )
-    .die('mousemove.swipe').live('mousemove.swipe',
-        { 'br': this },
-        this.swipeMousemoveHandler
-    )
-    .die('mouseup.swipe').live('mouseup.swipe',
-        { 'br': this },
-        this.swipeMouseupHandler
     );
     
     this.bindMozTouchHandlers();
@@ -3961,17 +3960,34 @@ BookReader.prototype.initSwipeData = function(clientX, clientY) {
 BookReader.prototype.swipeMousedownHandler = function(event) {
     //console.log('swipe mousedown');
     //console.log(event);
+
+    // We should be the last bubble point for the page images
+    // Disable image drag and select, but keep right-click
+    if (event.which == 3) {
+        return true;
+    }
     
     var self = event.data['br'];
+
+    $(event.target).bind('mouseout.swipe',
+        { 'br': self},
+        self.swipeMouseupHandler
+    ).bind('mouseup.swipe',
+        { 'br': self},
+        self.swipeMouseupHandler
+    ).bind('mousemove.swipe',
+        { 'br': self },
+        self.swipeMousemoveHandler
+    );    
+    
     self.initSwipeData(event.clientX, event.clientY);
     self._swipe.mightBeSwiping = true;
     self._swipe.mightBeDragging = true;
     
-    // We should be the last bubble point for the page images
-    // Disable image drag and select, but keep right-click
-    if ($(event.originalTarget).hasClass('BRpageimage') && event.button != 2) {
-        event.preventDefault();
-    }
+    event.preventDefault();
+    event.returnValue  = false;  
+    event.cancelBubble = true;          
+    return false;
 }
 
 BookReader.prototype.swipeMousemoveHandler = function(event) {
@@ -4020,19 +4036,29 @@ BookReader.prototype.swipeMousemoveHandler = function(event) {
     }
     _swipe.lastX = event.clientX;
     _swipe.lastY = event.clientY;
+    
+    event.preventDefault();
+    event.returnValue  = false;
+    event.cancelBubble = true;         
+    return false;
 }
 BookReader.prototype.swipeMouseupHandler = function(event) {
     var _swipe = event.data['br']._swipe;
     //console.log('swipe mouseup - did swipe ' + _swipe.didSwipe);
     _swipe.mightBeSwiping = false;
     _swipe.mightBeDragging = false;
+
+    $(event.target).unbind('mouseout.swipe').unbind('mouseup.swipe').unbind('mousemove.swipe');
+    
     if (_swipe.didSwipe || _swipe.didDrag) {
         // Swallow event if completed swipe gesture
         event.preventDefault();
-        event.stopPropagation();
+        event.returnValue  = false;
+        event.cancelBubble = true;         
+        return false;
     }
+    return true;
 }
-
 BookReader.prototype.bindMozTouchHandlers = function() {
     var self = this;
     
@@ -4551,7 +4577,7 @@ BookReader.prototype.gotOpenLibraryRecord = function(self, olObject) {
         self.bookUrl = 'http://openlibrary.org' + olObject.key;
         self.bookTitle = olObject['title'];
         $('#BRreturn a').attr( {'href': self.bookUrl, 'title': "Go to this book's page on Open Library" } );
-        $('#BookReader .logo').attr('title', 'Go to Open Library'); // i18n
+        $('#BRreturn a').text(self.bookTitle);
         
         $('#BRinfo').remove();
         $('#BRshare').after(self.blankInfoDiv());
@@ -5089,8 +5115,10 @@ BookReader.prototype.buildShareDiv = function(jShareDiv)
             params.page = self.getPageNum(self.currentIndex());
         }
         
-        // console.log(params);
-        form.find('.BRframeEmbed').val(self.getEmbedCode());
+        // $$$ changeable width/height to be added to share UI
+        var frameWidth = "480px";
+        var frameHeight = "430px";
+        form.find('.BRframeEmbed').val(self.getEmbedCode(frameWidth, frameHeight, params));
     })
     jForm.find('input[name=thispage]').trigger('change');
     jForm.find('input, textarea').bind('focus', function() {