//=== Event handlers
$(document).on(this.fluidbook.input.clickEvent, '#menuSearchResults a', function () {
// Find the page number of the result so we can see where it sits in the list of returned results
- var pageNumber = parseInt($(this).parents('.doubleThumb').attr('page'));
+ var pageNumber = parseInt($(this).find('.doubleThumb').attr('page'));
$this.openResultsNav(pageNumber);
});
});
$(this.fluidbook).on('fluidbook.resize.orientation', function (event, details) {
- if (!$this.resultsNavActive()) return;
+ if (!$this.resultsNavActive()) {
+ return;
+ }
$this.updateResultsNav($this.fluidbook.currentPage);
});
- }, resultsNavActive: function () {
+ },
+
+ resultsNavActive: function () {
return $('body').hasClass(this.resultsActiveClass);
},
// to even and remove duplicates created.
if (this.fluidbook.resize.orientation === "landscape") {
- var noOddPages = this.resultPages.map(function (page) {
+ const noOddPages = this.resultPages.map(function (page) {
if (page % 2 === 1) page--; // Change to preceding even number
return page;
});
this.resultNavPages = this.resultPages;
}
- var resultPagePosition = this.resultNavPages.indexOf(resultPage);
+ let 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;
- var counterText = resultPagePosition + '/' + this.resultNavPages.length;
+ const counterText = resultPagePosition + '/' + this.resultNavPages.length;
this.resultsNav.find('.searchResultsNavQuery').text($('#q').val());
this.resultsNav.find('.searchResultsNavCounter').text(counterText);
} catch (e) {
}
- if (nb == 0) {
+ if (nb === 0) {
continue;
}
page = parseInt(p);
if (page > maxPage) {
continue;
}
+ this.resultPages.push(page);
if (!this.singleMode && (page % 2) === 1) {
page--;
doublesPages[page][q] = nb;
res[page] = nb;
+
total += nb;
}
if (total > 0) {
total: total, results: res, terms: terms
};
- console.log(returnVal);
-
callback(returnVal);
},
doublesPages[page][q] = nb;
res[page] = nb;
+ this.resultPages.push(page);
total += nb;
}
if (total > 0) {