Remove not-yet-implemented fit button
[bookreader.git] / BookReader / BookReader.js
index 5ee5644..9ee130b 100644 (file)
@@ -465,6 +465,7 @@ BookReader.prototype.drawLeafsOnePage = function() {
 
             var img = document.createElement("img");
             img.src = this._getPageURI(index, this.reduce, 0);
+            $(img).addClass('BRnoselect');
             $(img).css('width', width+'px');
             $(img).css('height', height+'px');
             $(div).append(img);
@@ -656,10 +657,8 @@ BookReader.prototype.drawLeafsThumbnail = function( seekIndex ) {
                     self.firstIndex = $(this).data('leaf');
                     self.switchMode(self.constMode1up);
                     event.preventDefault();
-                });
-                
-                // $$$ we don't actually go to this URL (click is handled in handler above)
-                link.href = '#page/' + (this.getPageNum(leaf)) +'/mode/1up' ;
+                    event.stopPropagation();
+                });                
                 $(div).append(link);
                 
                 $('#BRpageview').append(div);
@@ -2644,7 +2643,7 @@ BookReader.prototype.getPageWidth2UP = function(index) {
 BookReader.prototype.search = function(term) {
     //console.log('search called with term=' + term);
     
-    $('#textSrch').blur(); //cause mobile safari to hide the keyboard 
+    $('#textSrch').blur(); //cause mobile safari to hide the keyboard     
     
     var url = 'http://'+this.server.replace(/:.+/, ''); //remove the port and userdir
     url    += '/fulltext/inside.php?item_id='+this.bookId;
@@ -3274,7 +3273,8 @@ BookReader.prototype.initNavbar = function() {
         +         '<button class="BRicon onepg"></button>'
         +         '<button class="BRicon twopg"></button>'
         +         '<button class="BRicon thumb"></button>'
-        +         '<button class="BRicon fit"></button>'
+        // $$$ not yet implemented
+        //+         '<button class="BRicon fit"></button>'
         +         '<button class="BRicon zoom_in"></button>'
         +         '<button class="BRicon zoom_out"></button>'
         +         '<button class="BRicon book_left"></button>'
@@ -3615,18 +3615,16 @@ BookReader.prototype.addChapterFromEntry = function(tocEntryObject) {
 BookReader.prototype.initToolbar = function(mode, ui) {
 
     // $$$mang should be contained within the BookReader div instead of body
-
     var readIcon = '';
     if (!navigator.userAgent.match(/mobile/i)) {
         readIcon = "<button class='BRicon read modal'></button>";
     }
-    
+
     $("body").append(
           "<div id='BRtoolbar'>"
         +   "<span id='BRtoolbarbuttons'>"
         /* XXXmang integrate search */
         +     "<form action='javascript:br.search($(\"#textSrch\").val());' id='booksearch'><input type='search' id='textSrch' name='textSrch' val='' placeholder='Search inside'/><button type='submit' id='btnSrch' name='btnSrch'>GO</button></form>"
-        // XXXmang icons incorrect or handlers wrong
         +     "<button class='BRicon play'></button>"
         +     "<button class='BRicon pause'></button>"
         +     "<button class='BRicon info'></button>"
@@ -3636,6 +3634,7 @@ BookReader.prototype.initToolbar = function(mode, ui) {
         +   "</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>"
+        +   "<div id='BRnavCntlTop' class='BRnavCntl BRup'></div>"
         + "</div>"
         /*
         + "<div id='BRzoomer'>"
@@ -3651,7 +3650,7 @@ BookReader.prototype.initToolbar = function(mode, ui) {
         */
         );
     
-    $('#BRtoolbar .pause').hide();
+    $('#BRtoolbar .pause').hide();    
     
     this.updateToolbarZoom(this.reduce); // Pretty format
         
@@ -3888,13 +3887,6 @@ BookReader.prototype.bindNavigationHandlers = function() {
         return false;
     });
     
-    // XXX fix integration
-    // XXX Mobile safari was not picking up this handler, so 
-    //     I explictly set the form action in initToolbar()
-    // $('#booksearch').bind('submit', function() {
-    //    self.search($('#textSrch').val());
-    // });
-
     this.initSwipeData();
     $('#BookReader').die('mousemove.navigation').live('mousemove.navigation',
         { 'br': this },
@@ -3947,6 +3939,7 @@ BookReader.prototype.initSwipeData = function(clientX, clientY) {
      */
     this._swipe = {
         mightBeSwiping: false,
+        didSwipe: false,
         startTime: (new Date).getTime(),
         startX: clientX,
         startY: clientY,
@@ -3988,7 +3981,7 @@ BookReader.prototype.swipeMousemoveHandler = function(event) {
     var absY = Math.abs(_swipe.deltaY);
     
     // Minimum distance in the amount of tim to trigger the swipe
-    var minSwipeLength = Math.max($('#BookReader').width() / 5, 100);
+    var minSwipeLength = Math.min($('#BookReader').width() / 5, 50);
     var maxSwipeTime = 1000;
     
     // Check for horizontal swipe
@@ -3996,6 +3989,7 @@ BookReader.prototype.swipeMousemoveHandler = function(event) {
         //console.log('swipe! ' + _swipe.deltaX + ',' + _swipe.deltaY + ' ' + _swipe.deltaT + 'ms');
         
         _swipe.mightBeSwiping = false; // only trigger once
+        _swipe.didSwipe = true;
         if (event.data['br'].mode == event.data['br'].constMode2up) {
             if (_swipe.deltaX < 0) {
                 event.data['br'].right();
@@ -4006,9 +4000,14 @@ BookReader.prototype.swipeMousemoveHandler = function(event) {
     }
 }
 BookReader.prototype.swipeMouseupHandler = function(event) {
-    //console.log('swipe mouseup');
-    //console.log(event);
-    event.data['br']._swipe.mightBeSwiping = false;
+    var _swipe = event.data['br']._swipe;
+    //console.log('swipe mouseup - did swipe ' + _swipe.didSwipe);
+    _swipe.mightBeSwiping = false;
+    if (_swipe.didSwipe) {
+        // Swallow event if completed swipe gesture
+        event.preventDefault();
+        event.stopPropagation();
+    }
 }
 
 BookReader.prototype.bindMozTouchHandlers = function() {
@@ -4667,14 +4666,13 @@ BookReader.prototype.ttsStartCB = function (data) {
 // showProgressPopup
 //______________________________________________________________________________
 BookReader.prototype.showProgressPopup = function(msg) {
+    if (soundManager.debugMode) console.log('showProgressPopup index='+this.ttsIndex+' pos='+this.ttsPosition);
     if (this.popup) return;
     
     this.popup = document.createElement("div");
     $(this.popup).css({
         top:      ($('#BookReader').height()*0.5-100) + 'px',
-        left:     ($('#BookReader').width()-300)*0.5 + 'px',
-        width:    '300px',
-        border:   '2px solid black'
+        left:     ($('#BookReader').width()-300)*0.5 + 'px'
     }).attr('className', 'BRprogresspopup');
 
     var bar = document.createElement("div");
@@ -4995,22 +4993,28 @@ BookReader.prototype.ttsStartPolling = function () {
         },3000);
     };
     $().ready(function(){
-        $('#BRtoolbar').animate({top:0},3000).animate({top:-40});
-        $('#BRnav').animate({bottom:0},3000).animate({bottom:-53});
+    /*
+        $('#BRtoolbar').delay(3000).animate({top:-40});
+        $('#BRnav').delay(3000).animate({bottom:-53});
         changeArrow();
-        $('.BRnavCntl').animate({opacity:1},3000).animate({height:'43px'}).animate({opacity:1},1000).animate({opacity:.25},1000);
+        $('.BRnavCntl').delay(3000).animate({height:'43px'}).delay(1000).animate({opacity:.25},1000);
+    */
         $('.BRnavCntl').click(
             function(){
                 if ($('#BRnavCntlBtm').hasClass('BRdn')) {
                     $('#BRtoolbar').animate({top:-40});
-                    $('#BRnav').animate({bottom:-53});
+                    $('#BRnav').animate({bottom:-55});
                     $('#BRnavCntlBtm').addClass('BRup').removeClass('BRdn');
-                    $('.BRnavCntl').animate({height:'43px'}).animate({opacity:1},1000).animate({opacity:.25},1000);
+                    $('#BRnavCntlTop').addClass('BRdn').removeClass('BRup');
+                    $('#BRnavCntlBtm.BRnavCntl').animate({height:'45px'});
+                    $('.BRnavCntl').delay(1000).animate({opacity:.25},1000);
                 } else {
                     $('#BRtoolbar').animate({top:0});
                     $('#BRnav').animate({bottom:0});
                     $('#BRnavCntlBtm').addClass('BRdn').removeClass('BRup');
-                    $('.BRnavCntl').animate({opacity:1,height:'30px'});
+                    $('#BRnavCntlTop').addClass('BRup').removeClass('BRdn');
+                    $('#BRnavCntlBtm.BRnavCntl').animate({height:'30px'});
+                    $('.BRvavCntl').animate({opacity:1})
                 };
             }
         );
@@ -5024,5 +5028,14 @@ BookReader.prototype.ttsStartPolling = function () {
                 $('.BRnavCntl').animate({opacity:.25},250);
             };
         });
+        $('#BRnavCntlTop').mouseover(function(){
+            if ($(this).hasClass('BRdn')) {
+                $('.BRnavCntl').animate({opacity:1},250);
+            };
+        });
+        $('#BRnavCntlTop').mouseleave(function(){
+            if ($(this).hasClass('BRdn')) {
+                $('.BRnavCntl').animate({opacity:.25},250);
+            };
+        });
     });
-