$this.updateResultsNav($this.fluidbook.currentPage);
});
- },
- resultsNavActive: function () {
+ }, resultsNavActive: function () {
return $('body').hasClass(this.resultsActiveClass);
},
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').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;
this._loadLib(function () {
$this._getHints(q, callback);
});
- },
- find: function (q, callback) {
+ }, find: function (q, callback) {
var $this = this;
this._loadLib(function () {
$this._find(q, callback);
});
- },
- _loadLib: function (callback) {
+ }, _loadLib: function (callback) {
if (this.indexLoaded) {
return callback();
}
} else {
callback();
}
- },
- _getHints: function (q, callback) {
+ }, _getHints: function (q, callback) {
var words = this.normalizeQuery(q, true);
q = words.pop();
var res = [];
var returnVal = {
- total: total,
- results: res,
- terms: terms
+ total: total, results: res, terms: terms
};
callback(returnVal);
terms = words;
}
var returnVal = {
- total: total,
- results: res,
- terms: terms
+ total: total, results: res, terms: terms
};
callback(returnVal);
sortHints: function (a, b) {
return b[1] - a[1];
- },
- kill: function () {
+ }, kill: function () {
- },
- normalizeQuery: function (q, split) {
+ }, normalizeQuery: function (q, split) {
q = this.noAccents(q);
q = q.toLowerCase();
if (split) {
}
return q;
- },
- noAccents: function (source) {
+ }, noAccents: function (source) {
source = source.replace(/[àáâãäå]/g, "a");
source = source.replace(/[ÀÁÂÃÄÅ]/g, "A");
source = source.replace(/[èéêë]/g, "e");
source = source.replace(/[œ]/g, "oe");
source = source.replace(/[Œ]/g, "OE");
return source;
- },
- setHighlightTerms: function (terms) {
+ }, setHighlightTerms: function (terms) {
if (!this.highlightEnabled || window.HIGHLIGHTS === undefined) {
return;
}
this.highlights.push(h);
}
}
- },
- clearHighlights: function () {
+ }, clearHighlights: function () {
$("#searchHighlights").html('');
for (var p in this.plugins) {
var plugin = this.plugins[p];
plugin.clearHighlights();
}
- },
- highlightSearchTerms: function (pageNr) {
+ }, highlightSearchTerms: function (pageNr) {
if (!this.highlightEnabled) {
console.warn('hightlight disabled');
return;
// if (this.menuSearchHints.hasClass('mm-hidden')) {
// this.nav.menuAPI.openPanel(this.menuSearchHints, false);
// }
- },
- getSearchHints: function (q) {
+ }, getSearchHints: function (q) {
var $this = this;
this.killLastSearchHint();
this.getHints(q, function (r) {
$this.displaySearchHints(r);
});
- },
- displaySearchHints: function (hints) {
+ }, displaySearchHints: function (hints) {
var $this = this;
if (hints.length == 0) {
}
this.menuSearchHints.perfectScrollbar({
- suppressScrollX: true,
- minScrollbarLength: 40
+ suppressScrollX: true, minScrollbarLength: 40
});
$("#searchHints").css({top: top, left: left}).show();
var spreadEnabled = 0;
// Process each spread of pages to collect the ones with results
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, pagesWithHits = [];
+
+ var firstPageWithResult;
// Get total number of hits for pages in this spread
for (var i in currentPages) {
var pageNum = parseInt(currentPages[i]);
if (hits[pageNum] > 0) {
+ if (firstPageWithResult === undefined) {
+ firstPageWithResult = currentPages[i];
+ }
totalHits += hits[pageNum];
pagesWithHits.push(currentPages[i]);
}
}
} else {
spreadEnabled++;
-
- var url = '#/page/' + $(this).attr('page');
+ p = $this.fluidbook.displayOnePage ? firstPageWithResult : $(this).attr('page');
+ var url = '#/page/' + p;
if ($this.fluidbook.pad.enabled) {
if (pagesWithHits.length == 1) {
url = '#/page/' + pagesWithHits[0];
// Initialise scrollbar after populating so bars appear immediately
this.menuSearchResults.perfectScrollbar({
- suppressScrollX: true,
- minScrollbarLength: 40,
- //maxScrollbarLength: 60
+ suppressScrollX: true, minScrollbarLength: 40, //maxScrollbarLength: 60
});
- },
- registerPlugin: function (p) {
+ }, registerPlugin: function (p) {
this.plugins.push(p);
- },
- closeKeyboardonTouchDevices: function () {
+ }, closeKeyboardonTouchDevices: function () {
if (this.fluidbook.support.iOS || this.fluidbook.support.android) {
$("#q").blur();
}