X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=sidebyside;f=BookReader%2FBookReader.js;h=5d532a95d71f3f1223a995a9ca6c8378895cf282;hb=b52bb23a38cd41f1a3140fb61836ed68e1709493;hp=756f9350bf97f62238f256de78ae13149fd55c5b;hpb=e494b1e1e5227bbfad7dd50b54b11e9a08f7126b;p=bookreader.git diff --git a/BookReader/BookReader.js b/BookReader/BookReader.js index 756f935..5d532a9 100644 --- a/BookReader/BookReader.js +++ b/BookReader/BookReader.js @@ -1239,6 +1239,8 @@ BookReader.prototype.jumpToIndex = function(index, pageX, pageY) { this.willChangeToIndex(index); + this.ttsStop(); + if (this.constMode2up == this.mode) { this.autoStop(); @@ -1344,8 +1346,6 @@ BookReader.prototype.switchMode = function(mode) { this.reduce = this.quantizeReduce(this.reduce, this.onePage.reductionFactors); this.prepareOnePageView(); } else if (3 == mode) { - $('button.thumb').hide(); - $('button.twopg').show(); this.reduce = this.quantizeReduce(this.reduce, this.reductionFactors); this.prepareThumbnailView(); } else { @@ -2415,7 +2415,7 @@ BookReader.prototype.prefetchImg = function(index) { if (index < 0 || index > (this.numLeafs - 1) ) { // Facing page at beginning or end, or beyond $(img).css({ - 'background-color': 'transparent' + 'background-color': '#efefef' }); } img.src = pageURI; @@ -2635,40 +2635,45 @@ BookReader.prototype.getPageWidth2UP = function(index) { // search() //______________________________________________________________________________ BookReader.prototype.search = function(term) { - term = term.replace(/\//g, ' '); // strip slashes - this.searchTerm = term; - $('#BookReaderSearchScript').remove(); - var script = document.createElement("script"); - script.setAttribute('id', 'BookReaderSearchScript'); - script.setAttribute("type", "text/javascript"); - script.setAttribute("src", 'http://'+this.server+'/BookReader/flipbook_search_br.php?url='+escape(this.bookPath + '_djvu.xml')+'&term='+term+'&format=XML&callback=br.BRSearchCallback'); - document.getElementsByTagName('head')[0].appendChild(script); - $('#BookReaderSearchBox').val(term); - $('#BookReaderSearchResults').html('Searching...'); -} - -// searchNew() -//______________________________________________________________________________ -BookReader.prototype.searchNew = function(term) { - //console.log('searchNew called with term=' + term); + //console.log('search called with term=' + term); + + $('#textSrch').blur(); //cause mobile safari to hide the keyboard + var url = 'http://'+this.server.replace(/:.+/, ''); //remove the port and userdir url += '/~edward/inside_jsonp.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); - //console.log('search url='+url); + //console.log('search url='+url); + + term = term.replace(/\//g, ' '); // strip slashes, since this goes in the url + this.searchTerm = term; + this.removeSearchResults(); - this.showProgressPopup(); - this.ttsAjax = $.ajax({url:url, dataType:'jsonp', jsonpCallback:'BRSearchCallbackNew'}); + this.showProgressPopup(' Search results will appear below...'); + this.ttsAjax = $.ajax({url:url, dataType:'jsonp', jsonpCallback:'BRSearchCallback'}); } +// BRSearchCallback() +//______________________________________________________________________________ // Unfortunately, we can't pass 'br.searchCallback' to our search service, // because it can't handle the '.' -function BRSearchCallbackNew(results) { +function BRSearchCallback(results) { //console.log('got ' + results.matches.length + ' results'); br.removeSearchResults(); br.searchResults = results; //console.log(br.searchResults); + + if (0 == results.matches.length) { + $(br.popup).text('No matches were found.'); + setTimeout(function(){ + $(br.popup).fadeOut('slow', function() { + br.removeProgressPopup(); + }) + },1000); + return; + } + var i; for (i=0; i'); - - for (var key in this.searchResults) { - if (null != this.searchResults[key].div) { - $(this.searchResults[key].div).remove(); - } - delete this.searchResults[key]; - } - - var pages = dom.getElementsByTagName('PAGE'); - - if (0 == pages.length) { - // $$$ it would be nice to echo the (sanitized) search result here - $('#BookReaderSearchResults').append('
  • No search results found
  • '); - } else { - for (var i = 0; i < pages.length; i++){ - //console.log(pages[i].getAttribute('file').substr(1) +'-'+ parseInt(pages[i].getAttribute('file').substr(1), 10)); - - - var re = new RegExp (/_(\d{4})\.djvu/); - var reMatch = re.exec(pages[i].getAttribute('file')); - var index = parseInt(reMatch[1], 10); - //var index = parseInt(pages[i].getAttribute('file').substr(1), 10); - - var children = pages[i].childNodes; - var context = ''; - for (var j=0; j'; - - var index = this.leafNumToIndex(index); - if (null != index) { - //coordinates are [left, bottom, right, top, [baseline]] - //we'll skip baseline for now... - var coords = children[j].getAttribute('coords').split(',',4); - if (4 == coords.length) { - this.searchResults[index] = {'l':parseInt(coords[0]), 'b':parseInt(coords[1]), 'r':parseInt(coords[2]), 't':parseInt(coords[3]), 'div':null}; - } - } - } - } - var pageName = this.getPageName(index); - var middleX = (this.searchResults[index].l + this.searchResults[index].r) >> 1; - var middleY = (this.searchResults[index].t + this.searchResults[index].b) >> 1; - //TODO: remove hardcoded instance name - $('#BookReaderSearchResults').append('
  • ' + pageName + ' - ' + context + '
  • '); - } - } - $('#BookReaderSearchResults').append(''); - - // $$$ update again for case of loading search URL in new browser window (search box may not have been ready yet) - $('#BookReaderSearchBox').val(this.searchTerm); - - this.updateSearchHilites(); -} // updateSearchHilites() //______________________________________________________________________________ @@ -3331,6 +3263,12 @@ BookReader.prototype.initNavbar = function() { $('#BookReader').after( '
    ' + '
    ' // Page turn buttons + + '' + + '' + + '' + + '' + + '' + + '' + '' + '' + '
    ' @@ -3342,6 +3280,7 @@ BookReader.prototype.initNavbar = function() { + '
    ' + '
    ' + '' + + '
    ' + '' ); @@ -3437,10 +3376,13 @@ BookReader.prototype.initNavbar = function() { .append('
    '); //.wrap('
    ').parent(); // XXXmang is this used for hiding the tooltip? + // $$$mang, why are these set both here and in bindNavigationHandlers? $('.BRicon.book_left').bind('click', function() { + self.ttsStop(); self.left(); }); $('.BRicon.book_right').bind('click', function() { + self.ttsStop(); self.right(); }); @@ -3489,7 +3431,7 @@ BookReader.prototype.addSearchResult = function(queryString, pageIndex) { var re = new RegExp('{{{(.+?)}}}', 'g'); queryString = queryString.replace(re, '$1') - $('