$('html').addClass('sharp');
}
- if (this.nav.isInverted() ) {
+ if (this.nav.isInverted()) {
$('html').addClass('menu-inverted');
} else {
$('html').addClass('menu-default');
}
- if(this.nav.isLogoCentered()){
+ if (this.nav.isLogoCentered()) {
$('#logo').addClass('center');
}
} catch (err) {
}
});
- }, initPage: function (pageNr, doublePage, position) {
+ },
+
+ initPage: function (pageNr, doublePage, position) {
if ($("#page_" + pageNr).length > 0) {
return;
}
$(doublePage).find('.' + position).remove();
var page = '<div class="page ' + position + '" id="page_' + pageNr + '" data-page="' + pageNr + '"><div class="background" page="' + pageNr + '"></div><div class="ctlinks" data-blendmode="normal"></div><div class="texts" highlight=""></div><div class="clinks" data-blendmode="normal"></div><div class="shade"></div></div>';
$(doublePage).append(page);
- }, hidePage: function (position) {
+ },
+
+ hidePage: function (position) {
$("#pages ." + position).hide();
- }, canChangePage: function () {
+ },
+
+ canChangePage: function () {
try {
return this.pagetransitions.canChangePage();
} catch (e) {
}
return false;
- }, initVideos: function () {
+ },
+
+ initVideos: function () {
this.video.initVideos();
- }, getNextOffset: function () {
+ },
+
+ getNextOffset: function () {
var offset = 2;
if (this.displayOnePage) {
offset = 1;
}
this.transitionAxis = 'x';
return offset;
- }, goNextPage: function () {
+ },
+
+ goNextPage: function () {
if (!this.canChangePage()) {
return;
}
this.transitionAxis = 'x';
this.setCurrentPage(this.normalizePage(this.currentPage) + this.getNextOffset());
}
- }, goFirstPage: function () {
+ },
+
+ goFirstPage: function () {
if (!this.canChangePage()) {
return;
}
this.transitionAxis = 'x';
this.setCurrentPage(1);
- }, goPreviousPage: function () {
+ },
+
+ goPreviousPage: function () {
if (!this.canChangePage()) {
return;
}
this.transitionAxis = 'x';
this.setCurrentPage(this.normalizePage(this.currentPage) - this.getNextOffset());
}
- }, goLastPage: function () {
+ },
+
+ goLastPage: function () {
if (!this.canChangePage()) {
return;
}
this.transitionAxis = 'x';
this.setCurrentPage(this.contentlock.getMaxPage());
- }, goNextChapter: function () {
+ },
+
+ goNextChapter: function () {
if (!this.canChangePage()) {
return;
}
}
this.transitionAxis = 'x';
this.setCurrentPage(this.normalizePage(next));
- }, goPreviousChapter: function () {
+ },
+
+ goPreviousChapter: function () {
if (!this.canChangePage()) {
return;
}
}
this.transitionAxis = 'x';
this.setCurrentPage(this.normalizePage(prev));
- }, goNextChapterPage: function () {
+ },
+
+ goNextChapterPage: function () {
if (!this.canChangePage()) {
return;
}
}
this.transitionAxis = 'y';
this.setCurrentPage(this.normalizePage(next));
- }, goPreviousChapterPage: function () {
+ },
+
+ goPreviousChapterPage: function () {
if (!this.canChangePage()) {
return;
}
}
this.transitionAxis = 'y';
this.setCurrentPage(this.normalizePage(prev));
- }, normalizePage: function (page) {
+ },
+
+ normalizePage: function (page) {
page = Math.max(1, Math.min(page, this.contentlock.getMaxPage()));
if (!this.displayOnePage && page % 2 === 1) {
page--;
}
return page;
- }, setCurrentPage: function (page) {
+ },
+
+ setCurrentPage: function (page) {
window.location.hash = "#/page/" + this.normalizePage(page);
- }, changeAddress: function () {
+ },
+
+ changeAddress: function () {
var hash = window.location.hash;
if ($('.mview[data-hash="' + hash + '"]').length > 0) {
return;
window.location.hash = "/page/" + page;
}
}
- }, getButtonsVisibility: function (page) {
+ },
+
+ getButtonsVisibility: function (page) {
if (page === undefined) {
page = this.currentPage;
}
var next = page < max;
var previous = (page > 1);
return {previous: previous, next: next};
- }, hideUnnecessaryButtons: function (page) {
+ },
+
+ hideUnnecessaryButtons: function (page) {
var speed = 500;
if (page === undefined) {
page = this.currentPage;
if (s_out.length > 0) {
$(s).children(s_out.join(',')).addClass('hidden');
}
- }, showAllButtons: function () {
+ },
+
+ showAllButtons: function () {
$("#next-arrows,#prev-arrows").addClass('help').show();
},
$("#pagesnumbers .left").html(this.getPageNumberOfSide('left', true));
$("#pagesnumbers .right").html(this.getPageNumberOfSide('right', true));
$("#pagesnumbers").removeClass('hidden');
- }, getPhysicalPageNumberOfSide: function (side, strict) { // Side should be 'left' or 'right'
+ },
+
+ getPhysicalPageNumberOfSide: function (side, strict) { // Side should be 'left' or 'right'
if (undefined === strict) {
strict = false;
}
var w = this.wopen(url, '_blank', '');
if (print) {
setTimeout(function () {
- // w.print();
+ // w.print();
}, 2000);
}
},
this.resultsNavID = 'searchResultsNav';
this.hideableElements = $('header,footer,#interface'); // Which elements to show/hide when in search results nav mode
this.resultsActiveClass = 'searchResultsNavActive';
+ this.robust = fluidbook.settings.search_mode === 'robust';
+ this.hintsEnabled = !this.robust;
this.init();
}
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');
$this._getHints(q, callback);
});
},
+
find: function (q, callback) {
var $this = this;
this._loadLib(function () {
$this._find(q, callback);
});
},
+
_loadLib: function (callback) {
if (this.indexLoaded) {
return callback();
}
var $this = this;
- loadJSLibrary('data/search.index.js?j=' + this.fluidbook.settings.cacheDate, function () {
+
+ let __loadTexts = function () {
$this._loadTexts(function () {
if ($this.highlightEnabled) {
loadJSLibrary('data/search.highlight.js?j=' + this.fluidbook.settings.cacheDate, function () {
callback();
}
});
- });
+ };
+
+ if (!this.robust) {
+ loadJSLibrary('data/search.index.js?j=' + this.fluidbook.settings.cacheDate, function () {
+ __loadTexts();
+ });
+ } else {
+ __loadTexts();
+ }
},
_loadTexts: function (callback) {
- if (this.fluidbook.settings.searchWordSelectionAlgorithm === 'expression') {
+ if (this.robust || this.fluidbook.settings.searchWordSelectionAlgorithm === 'expression') {
loadJSLibrary('data/search.texts.js?j=' + this.fluidbook.settings.cacheDate, function () {
callback();
});
callback();
}
},
+
_getHints: function (q, callback) {
- var words = this.normalizeQuery(q, true);
+ var words = this.normalizeQuery(q, true, false);
q = words.pop();
var res = [];
if (q.length < 3) {
return a;
},
+ _findRobust(q, callback) {
+ q = this.normalizeQuery(q, false, true);
+ var res = {};
+ var terms = [];
+ var total = 0;
+ var doublesPages = [];
+ var maxPage = this.fluidbook.contentlock.getMaxPage();
+
+ for (var p in TEXTS) {
+ var t = TEXTS[p];
+ var regexp = new RegExp(q, 'g');
+ var r = t.match(regexp);
+ var nb = 0;
+ try {
+ nb = r.length;
+ } catch (e) {
+
+ }
+ if (nb == 0) {
+ continue;
+ }
+ page = parseInt(p);
+ if (page > maxPage) {
+ continue;
+ }
+
+ if (!this.singleMode && (page % 2) === 1) {
+ page--;
+ }
+
+ doublesPages[page] = [];
+ doublesPages[page][q] = nb;
+
+ res[page] = nb;
+ total += nb;
+ }
+ if (total > 0) {
+ terms = [q];
+ }
+ var returnVal = {
+ total: total, results: res, terms: terms
+ };
+
+ console.log(returnVal);
+
+ callback(returnVal);
+ },
+
_find: function (q, callback) {
+ if (this.robust) {
+ return this._findRobust(q, callback);
+ }
+
+
var algo = this.getSearchWordSelectionAlgorithm(q);
if (algo === 'expression') {
return this._findExpression(q, callback);
sortHints: function (a, b) {
return b[1] - a[1];
},
+
kill: function () {
},
- normalizeQuery: function (q, split) {
+
+ normalizeQuery: function (q, split, removeSpaces) {
q = this.noAccents(q);
q = q.trim();
q = q.replace(/\s+/g, ' ');
+ if (removeSpaces) {
+ q = q.replace(/\s+/g, '');
+ }
q = q.toLowerCase();
if (split) {
return q.split(' ');
}
return q;
},
+
noAccents: function (source) {
return removeDiacritics(source);
},
+
setHighlightTerms: function (terms) {
if (!this.highlightEnabled || window.HIGHLIGHTS === undefined) {
return;
}
}
},
+
clearHighlights: function () {
$("#searchHighlights").html('');
for (var p in this.plugins) {
plugin.clearHighlights();
}
},
+
highlightSearchTerms: function (pageNr) {
if (!this.highlightEnabled) {
console.warn('hightlight disabled');
},
initSearchHints: function () {
+ if (!this.hintsEnabled) {
+ return;
+ }
this.menuSearchHints = $('#menuSearchHints');
this.fluidbook.hideMenuItems(); // Hide menu items to give space for hints div
// if (this.menuSearchHints.hasClass('mm-hidden')) {
// this.nav.menuAPI.openPanel(this.menuSearchHints, false);
// }
- }, getSearchHints: function (q) {
+ },
+
+ getSearchHints: function (q) {
+ if (!this.hintsEnabled) {
+ this.fluidbook.hideMenuItems();
+ this._loadLib(function () {
+ });
+ return;
+ }
var $this = this;
this.killLastSearchHint();
this.getHints(q, function (r) {
$this.displaySearchHints(r);
});
- }, displaySearchHints: function (hints) {
+ },
+
+ displaySearchHints: function (hints) {
+ if (!this.hintsEnabled) {
+ return;
+ }
var $this = this;
if (hints.length == 0) {
},
killLastSearchHint: function () {
+ if (!this.hintsEnabled) {
+ return;
+ }
this.kill();
},
hideSearchHints: function () {
+ if (!this.hintsEnabled) {
+ return;
+ }
if (this.menuSearchHints !== undefined) {
this.menuSearchHints.html('').hide(); // Clear and hide all hints
}
this.menuSearchResults.perfectScrollbar({
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();
}