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(', '));
- });
+ 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() {
+ initResultsNav: function () {
var $this = this;
// Previously we used buttons in the HTML for clickable elements
this.resultsNav = $('#' + this.resultsNavID);
//=== Event handlers
- $(document).on('click', '#menuSearchResults a', function() {
+ $(document).on('click', '#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'));
$this.openResultsNav(pageNumber);
});
- $(document).on('click', '.searchResultsNavField', function() {
+ $(document).on('click', '.searchResultsNavField', function () {
$this.closeResultsNav(true);
$this.fluidbook.nav.openSearch();
});
- $(document).on('click', '.searchResultsNext', function() {
+ $(document).on('click', '.searchResultsNext', function () {
$this.nextResultsPage();
});
- $(document).on('click', '.searchResultsPrev', function() {
+ $(document).on('click', '.searchResultsPrev', function () {
$this.previousResultsPage();
});
- $(document).on('click', '.searchResultsNavClose', function() {
+ $(document).on('click', '.searchResultsNavClose', function () {
$this.closeResultsNav();
});
});
// Close results nav when hitting escape
- key('esc', function() {
+ key('esc', function () {
if ($this.resultsNavActive()) {
$this.closeResultsNav();
}
},
- resultsNavActive: function() {
- return $('body').hasClass(this.resultsActiveClass);
+ resultsNavActive: function () {
+ return $('body').hasClass(this.resultsActiveClass);
},
- updateResultsNav: function(resultPage) {
+ updateResultsNav: function (resultPage) {
// If we are in landscape view, there are 2 pages visible,
// so we only want even pages in our results. The resultPages
// to even and remove duplicates created.
if (this.fluidbook.resize.orientation === "landscape") {
- var noOddPages = this.resultPages.map(function(page) {
+ var noOddPages = this.resultPages.map(function (page) {
if (page % 2 === 1) page--; // Change to preceding even number
return page;
});
// Remove any duplicates created when converting pages to even numbers
// Ref: https://stackoverflow.com/a/14438954
- this.resultNavPages = noOddPages.filter(function(value, index, self) {
+ this.resultNavPages = noOddPages.filter(function (value, index, self) {
return self.indexOf(value) === index;
});
this.resultsNav.find('.searchResultsNavQuery').text($('#q').val());
this.resultsNav.find('.searchResultsNavCounter').text(counterText);
},
- openResultsNav: function(resultPage) {
+ openResultsNav: function (resultPage) {
this.updateResultsNav(resultPage);
this.hideableElements.addClass('hidden');
this.resultsNav.removeClass('hidden');
$('body').addClass(this.resultsActiveClass);
},
- closeResultsNav: function(keepSearch) {
+ closeResultsNav: function (keepSearch) {
keepSearch = keepSearch !== 'undefined' ? keepSearch : false;
this.hideableElements.removeClass('hidden');
$('body').removeClass(this.resultsActiveClass);
},
- nextResultsPage: function() {
+ nextResultsPage: function () {
var currentIndex = this.resultNavPages.indexOf(fluidbook.currentPage);
var nextIndex = currentIndex + 1;
this.updateResultsNav(nextPage);
this.fluidbook.setCurrentPage(nextPage);
},
- previousResultsPage: function() {
+ previousResultsPage: function () {
var currentIndex = this.resultNavPages.indexOf(fluidbook.currentPage);
var prevIndex = currentIndex - 1;
},
highlightSearchTerms: function (pageNr) {
if (!this.highlightEnabled) {
+ console.warn('hightlight disabled');
return;
}
this.clearHighlights();
if (this.termsToHighlight.length === 0) {
+ console.warn('no terms to highlight');
return;
}
if (!this.singleMode && evenPageNumber % 2 === 1) {
evenPageNumber--;
}
-
- if (this.resultPages.indexOf(evenPageNumber) === -1) {
- return;
- }
}
var pageNrs = [];