this.initResultsNav();
},
+ debugSearch: function(keyword) {
+ this._loadLib(function() {
+ console.log('Comparison of page results for keyword "'+ keyword +'"');
+ console.log('INDEX:', Object.keys(INDEX[keyword].p).join(', '));
+ console.log('HIGHLIGHTS:', Array.from(new Set(HIGHLIGHTS["loutres"].map(function(h) { return h.page }))).join(', '));
+ });
+ },
+
// The results nav bar provides navigation between results without needing the menu to be open
// When it is active, the rest of the interface is hidden
initResultsNav: function() {
});
$(document).on('click', '.searchResultsNavField', function() {
- $this.closeResultsNav();
+ $this.closeResultsNav(true);
$this.fluidbook.nav.openSearch();
});
$this.updateResultsNav($this.fluidbook.currentPage);
});
+ // Close results nav when hitting escape
+ key('esc', function() {
+ if ($this.resultsNavActive()) {
+ $this.closeResultsNav();
+ }
+ })
+
},
resultsNavActive: function() {
this.resultNavPages = this.resultPages;
}
- console.log('updateResultsNav...', this.resultNavPages);
-
var resultPagePosition = this.resultNavPages.indexOf(resultPage);
// Convert from zero-based index. If page clicked isn't found in results pages, default to 1
resultPagePosition = (resultPagePosition === -1) ? 1 : resultPagePosition + 1;
this.resultsNav.removeClass('hidden');
$('body').addClass(this.resultsActiveClass);
},
- closeResultsNav: function() {
+ closeResultsNav: function(keepSearch) {
+ keepSearch = keepSearch !== 'undefined' ? keepSearch : false;
+
this.hideableElements.removeClass('hidden');
this.resultsNav.addClass('hidden');
+
+ if (!keepSearch) {
+ this.closeSearch();
+ }
+
$('body').removeClass(this.resultsActiveClass);
},
nextResultsPage: function() {
var currentIndex = this.resultNavPages.indexOf(fluidbook.currentPage);
var nextIndex = currentIndex + 1;
- if (nextIndex > this.resultNavPages.length) {
+ if (nextIndex >= this.resultNavPages.length) {
nextIndex = 0; // Go back to beginning
}
matchedWord = INDEX[indexWord];
- console.log('match found', indexWord, 'pages : ' + Object.keys(matchedWord.p).join(','));
-
for (page in matchedWord.p) {
var occurrences = matchedWord.p[page];
page = parseInt(page);
terms: terms
};
- console.log(returnVal);
-
callback(returnVal);
},
var $this = this;
this.find(q, function (results) {
- console.log('Search results', results);
$this.openResults(results);
});
},