});
},
-
// 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 () {
}
var $this = this;
+ let r = new Map();
this.find(q, function (results) {
$this.openResults(results);
});
var spreadEnabled = 0;
// Process each spread of pages to collect the ones with results
+
+ var pagesWithHits = [];
+
this.menuSearchResults.find('.doubleThumb').each(function () {
- var currentPages = $(this).data('pages').toString().split(','), totalHits = 0, pagesWithHits = [];
+ var currentPages = $(this).data('pages').toString().split(','), totalHits = 0;
var firstPageWithResult;
}
}
-
// If there's already a .hits element, this spread has already been processed
if ($(this).find('.hits').length > 0) {
return;
}
});
+ let referencePage = pagesWithHits.find((el) => el >= $this.fluidbook.currentPage) ?? parseInt(pagesWithHits[0])
+ console.log(referencePage)
+
// Set Highlighting of results keywords
this.setHighlightTerms(results.terms);
this.hideSearchHints();
// Redirect to the only result page if the flag is enabled
if(this.fluidbook.search.isSearchfloatActive && $this.menuSearchResults.find('.doubleThumb[data-enabled="1"]').length > 0) {
setTimeout(function () {
- fluidbook.setCurrentPage($this.menuSearchResults.find('.doubleThumb[data-enabled="1"]').attr('page'));
- var pageNumber = parseInt($("#menuSearchResults a").find('.doubleThumb').attr('page'));
+ fluidbook.setCurrentPage($this.menuSearchResults.find('.doubleThumb[data-enabled="1"][data-pages*='+referencePage+']').attr('page'));
+ var pageNumber = parseInt($("#menuSearchResults a").find('.doubleThumb[data-enabled="1"][data-pages*='+referencePage+']').attr('page'));
$this.openResultsNav(pageNumber);
fluidbook.nav.burger.close();
}, 100);