this.contentlock = new FluidbookContentLock(this);
this.menu = new FluidbookMenu(this);
this.support = new FluidbookSupport(this);
+ this.search = new FluidbookSearch(this);
this.mobilefirst = new FluidbookMobileFirst(this);
this.zoom = new FluidbookZoom(this);
this.zoom.resetZoom();
this.cache = new FluidbookCache(datas);
this.service = new FluidbookService(this, datas.id);
this.loader = new FluidbookLoader(this);
- this.search = new FluidbookSearch(this);
this.pad = new FluidbookPad(this);
this.scorm = new FluidbookScorm(this);
this.links = new FluidbookLinks(this);
if (!this.canChangePage()) {
return;
}
- this.transitionAxis = 'x';
- this.setCurrentPage(this.normalizePage(this.currentPage) + this.getNextOffset());
+
+ if (this.search.resultsNavActive()) {
+ this.search.nextResultsPage();
+ } else {
+ this.transitionAxis = 'x';
+ this.setCurrentPage(this.normalizePage(this.currentPage) + this.getNextOffset());
+ }
},
goFirstPage: function () {
if (!this.canChangePage()) {
if (!this.canChangePage()) {
return;
}
- this.transitionAxis = 'x';
- this.setCurrentPage(this.normalizePage(this.currentPage) - this.getNextOffset());
+
+ if (this.search.resultsNavActive()) {
+ this.search.previousResultsPage();
+ } else {
+ this.transitionAxis = 'x';
+ this.setCurrentPage(this.normalizePage(this.currentPage) - this.getNextOffset());
+ }
},
goLastPage: function () {
if (!this.canChangePage()) {
this.highlights = [];
this.highlightEnabled = fluidbook.datas.highlightResults;
this.resultPages = [];
+ this.resultNavPages = [];
this.plugins = [];
this.singleMode = fluidbook.singleMode;
this.resultsNavID = 'searchResultsNav';
this.hideableElements = $('header,footer,#interface'); // Which elements to show/hide when in search results nav mode
+ this.resultsActiveClass = 'searchResultsNavActive';
this.init();
}
initResultsNav: function() {
var $this = this;
+ // Previously we used buttons in the HTML for clickable elements
+ // but there's a problem in iOS 9 where buttons don't work properly
+ // with flexbox so they were swapped for <div>s instead...
var html = '';
html += '<div id="' + this.resultsNavID + '" class="hidden">';
- html += '<button class="searchResultsNavField">';
+ html += '<div class="button searchResultsNavField">';
html += getSpriteIcon('nav-search');
html += '<div class="searchResultsNavQuery"></div>';
- html += '</button>'; // .searchResultsNavField
+ html += '</div>'; // .searchResultsNavField
html += '<div class="searchResultsNavArrows">';
- html += '<button class="searchResultsPrev"></button>';
+ html += '<div class="button searchResultsPrev"></div>';
html += '<div class="searchResultsNavCounter"></div>';
- html += '<button class="searchResultsNext"></button>';
+ html += '<div class="button searchResultsNext"></div>';
html += '</div>'; // .searchResultsNavArrows
- html += '<button class="searchResultsNavClose">';
+ html += '<div class="button searchResultsNavClose">';
html += getSpriteIcon('interface-close');
- html += '</button>'; // .searchResultsNavField
+ html += '</div>'; // .searchResultsNavClose
html += '</div>'; // #searchResultsNav
$('body').append(html);
$this.closeResultsNav();
});
+ $(this.fluidbook).on('fluidbook.resize.orientation', function (event, details) {
+ if (!$this.resultsNavActive()) return;
+
+ $this.updateResultsNav($this.fluidbook.currentPage);
+ });
+
+ },
+ resultsNavActive: function() {
+ return $('body').hasClass(this.resultsActiveClass);
},
updateResultsNav: function(resultPage) {
- var resultPagePosition = this.resultPages.indexOf(resultPage);
+
+ // If we are in landscape view, there are 2 pages visible,
+ // so we only want even pages in our results. The resultPages
+ // includes all pages by default so we need to convert odd pages
+ // to even and remove duplicates created.
+ if (this.fluidbook.resize.orientation === "landscape") {
+
+ 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) {
+ return self.indexOf(value) === index;
+ });
+
+ } else {
+ this.resultNavPages = this.resultPages;
+ }
+
+ console.log('updateResultsNav...', this.resultNavPages);
+
+ var 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.resultPages.length;
+ var counterText = resultPagePosition + '/' + this.resultNavPages.length;
this.resultsNav.find('.searchResultsNavQuery').text($('#q').val());
this.resultsNav.find('.searchResultsNavCounter').text(counterText);
this.updateResultsNav(resultPage);
this.hideableElements.addClass('hidden');
this.resultsNav.removeClass('hidden');
- $('body').addClass('searchResultsNavActive');
+ $('body').addClass(this.resultsActiveClass);
},
closeResultsNav: function() {
this.hideableElements.removeClass('hidden');
this.resultsNav.addClass('hidden');
- $('body').removeClass('searchResultsNavActive');
+ $('body').removeClass(this.resultsActiveClass);
},
nextResultsPage: function() {
- var currentIndex = this.resultPages.indexOf(fluidbook.currentPage);
+ var currentIndex = this.resultNavPages.indexOf(fluidbook.currentPage);
var nextIndex = currentIndex + 1;
- if (nextIndex > this.resultPages.length) {
+ if (nextIndex > this.resultNavPages.length) {
nextIndex = 0; // Go back to beginning
}
- var nextPage = this.resultPages[nextIndex];
+ var nextPage = this.resultNavPages[nextIndex];
this.updateResultsNav(nextPage);
this.fluidbook.setCurrentPage(nextPage);
},
previousResultsPage: function() {
- var currentIndex = this.resultPages.indexOf(fluidbook.currentPage);
+ var currentIndex = this.resultNavPages.indexOf(fluidbook.currentPage);
var prevIndex = currentIndex - 1;
if (prevIndex < 0) {
- prevIndex = this.resultPages.length - 1; // Go back to end
+ prevIndex = this.resultNavPages.length - 1; // Go back to end
}
- var prevPage = this.resultPages[prevIndex];
+ var prevPage = this.resultNavPages[prevIndex];
this.updateResultsNav(prevPage);
this.fluidbook.setCurrentPage(prevPage);
matchedWord = INDEX[indexWord];
+ console.log('match found', indexWord, 'pages : ' + Object.keys(matchedWord.p).join(','));
+
for (page in matchedWord.p) {
var occurrences = matchedWord.p[page];
page = parseInt(page);
continue;
}
- if (!this.singleMode && (page % 2) === 1) {
- page--;
- }
+ // if (!this.singleMode && (page % 2) === 1) {
+ // page--;
+ // }
if (doublePages[page] == null || doublePages[page] == undefined) {
doublePages[page] = [];
pageNrs.reverse();
}
- console.log('HIGHLIGHTS', this.highlights);
-
for (var i in this.highlights) {
var h = this.highlights[i];
for (var j in h.occurences) {