Merge branch 'newui' of http://github.com/lancearthur/bookreader into lancemerge
[bookreader.git] / BookReader / BookReader.js
index 2d64c69..d4dc433 100644 (file)
@@ -1498,7 +1498,7 @@ BookReader.prototype.prepareTwoPageView = function(centerPercentageX, centerPerc
     $(this.twoPage.coverDiv).attr('id', 'BRbookcover').css({
         width:  this.twoPage.bookCoverDivWidth + 'px',
         height: this.twoPage.bookCoverDivHeight+'px',
-        visibility: 'visible',
+        visibility: 'visible'
     }).appendTo('#BRtwopageview');
     
     this.leafEdgeR = document.createElement('div');
@@ -2646,7 +2646,7 @@ BookReader.prototype.getPageWidth2UP = function(index) {
 BookReader.prototype.search = function(term) {
     //console.log('search called with term=' + term);
     var url = 'http://'+this.server.replace(/:.+/, ''); //remove the port and userdir
-    url    += '/~edward/inside_jsonp.php?item_id='+this.bookId;
+    url    += '/fulltext/inside.php?item_id='+this.bookId;
     url    += '&doc='+this.subPrefix;   //TODO: test with subitem
     url    += '&path='+this.bookPath.replace(new RegExp('/'+this.subPrefix+'$'), ''); //remove subPrefix from end of path
     url    += '&q='+escape(term);
@@ -2657,14 +2657,12 @@ BookReader.prototype.search = function(term) {
     
     this.removeSearchResults();
     this.showProgressPopup('<img id="searchmarker" src="'+this.imagesBaseURL + 'marker_srch-on.png'+'"> Search results will appear below...');
-    this.ttsAjax = $.ajax({url:url, dataType:'jsonp', jsonpCallback:'BRSearchCallback'});    
+    this.ttsAjax = $.ajax({url:url, dataType:'jsonp', jsonpCallback:'br.BRSearchCallback'});    
 }
 
 // BRSearchCallback()
 //______________________________________________________________________________
-// Unfortunately, we can't pass 'br.searchCallback' to our search service,
-// because it can't handle the '.'
-function BRSearchCallback(results) {    
+BookReader.prototype.BRSearchCallback = function(results) {
     //console.log('got ' + results.matches.length + ' results');
     br.removeSearchResults();
     br.searchResults = results; 
@@ -2871,9 +2869,10 @@ BookReader.prototype.updateSearchHilites2UP = function() {
     var i, j;
     for (i=0; i<results.matches.length; i++) {
         //console.log(results.matches[i].par[0]);
+        //TODO: loop over all par objects
+        var pageIndex = this.leafNumToIndex(results.matches[i].par[0].page);        
         for (j=0; j<results.matches[i].par[0].boxes.length; j++) {
             var box = results.matches[i].par[0].boxes[j];
-            var pageIndex = this.leafNumToIndex(box.page);
             if (jQuery.inArray(pageIndex, this.displayedIndices) >= 0) {
                 if (null == box.div) {
                     //create a div for the search highlight, and stash it in the box object
@@ -3101,6 +3100,8 @@ BookReader.prototype.showBookmarkCode = function() {
 //______________________________________________________________________________
 BookReader.prototype.autoToggle = function() {
 
+    this.ttsStop();
+
     var bComingFrom1up = false;
     if (2 != this.mode) {
         bComingFrom1up = true;
@@ -3475,6 +3476,9 @@ BookReader.prototype.addSearchResult = function(queryString, pageIndex) {
         shadow: false
     })
     .hover( function() {
+                // remove from other markers then turn on just for this
+                // XXX should be done when nav slider moves
+                $('.search,.chapter').removeClass('front');
                 $(this).addClass('front');
             }, function() {
                 $(this).removeClass('front');
@@ -3539,6 +3543,8 @@ BookReader.prototype.addChapter = function(chapterTitle, pageNumber, pageIndex)
         shadow: false
     })
     .hover( function() {
+            // remove hover effect from other markers then turn on just for this
+            $('.search,.chapter').removeClass('front');
                 $(this).addClass('front');
             }, function() {
                 $(this).removeClass('front');
@@ -4555,6 +4561,9 @@ BookReader.util = {
 // ttsToggle()
 //______________________________________________________________________________
 BookReader.prototype.ttsToggle = function () {
+
+    this.autoStop();
+
     if (false == this.ttsPlaying) {
         this.ttsPlaying = true;
         this.showProgressPopup('Loading audio...');