From 4c23c35d3f26364df70021a32a48dad38dd13b12 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 30 Sep 2020 17:04:31 +0200 Subject: [PATCH] done #3766 @1.5 --- js/libs/fluidbook/fluidbook.accessibility.js | 3 +- js/libs/fluidbook/fluidbook.keyboard.js | 2 ++ js/libs/fluidbook/fluidbook.search.js | 26 +++++++------- js/libs/fluidbook/menu/fluidbook.index.js | 36 ++++++++++++++++---- 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.accessibility.js b/js/libs/fluidbook/fluidbook.accessibility.js index 65525eeb..f422464e 100644 --- a/js/libs/fluidbook/fluidbook.accessibility.js +++ b/js/libs/fluidbook/fluidbook.accessibility.js @@ -79,11 +79,10 @@ FluidbookAccessibility.prototype = { }); add_event_listener('keydown', function (e) { - if (e.keyCode === 9) { + if (e.keyCode === 9 || e.keyCode === 38 || e.keyCode === 40) { $('body').addClass('keyboard-navigating'); fluidbook.input.useKeyboard(); set_css(''); } }); - })(document); \ No newline at end of file diff --git a/js/libs/fluidbook/fluidbook.keyboard.js b/js/libs/fluidbook/fluidbook.keyboard.js index 7cfa8fe7..7e9450e2 100644 --- a/js/libs/fluidbook/fluidbook.keyboard.js +++ b/js/libs/fluidbook/fluidbook.keyboard.js @@ -72,6 +72,7 @@ FluidbookKeyboard.prototype = { } console.log(next); var ne = $(items).eq(next); + console.log(ne, actions); $.each(actions, function (k, action) { if (action === 'focus') { $(ne).focus(); @@ -126,6 +127,7 @@ FluidbookKeyboard.prototype = { e.preventDefault(); } else if ($this.fluidbook.search.isResultsOverviewOpened()) { $this.fluidbook.search.navigateResults(handler.key === 'down' ? 1 : -1); + e.preventDefault(); } }, false, false); }, diff --git a/js/libs/fluidbook/fluidbook.search.js b/js/libs/fluidbook/fluidbook.search.js index 576935bb..9c131d47 100644 --- a/js/libs/fluidbook/fluidbook.search.js +++ b/js/libs/fluidbook/fluidbook.search.js @@ -169,7 +169,7 @@ FluidbookSearch.prototype = { }, navigateResults: function (dir) { - this.fluidbook.keyboard._navigate('#menuSearchResults .doubleThumb', dir); + this.fluidbook.keyboard._navigate('#menuSearchResults .menuSearchResult', dir); }, closeResultsNav: function (keepSearch) { @@ -756,15 +756,10 @@ FluidbookSearch.prototype = { hits[k] += v; }); - // ToDo: check the purpose of the group variable? Also check tracking - //$this.displayResults(r, group, cb); - //console.log('Search results...'); - //console.log(results); - // Display results // Use the index of all pages as a starting point to filter results thumbnails - this.menuSearchResults.html(this.fluidbook.menu.index._getNormalView(true, 141)).hide(); + this.menuSearchResults.html(this.fluidbook.menu.index._getSearchResultsView()).hide(); var spreadEnabled = 0; // Process each spread of pages to collect the ones with results @@ -799,18 +794,21 @@ FluidbookSearch.prototype = { } } else { spreadEnabled++; - $(this).attr('data-enabled', '1'); - // Add the link to the main result page. Link around the hits div is for better usability (previously wasn't clickable) - $(this).append('
' + totalHits + ' ' + $this.fluidbook.l10n.__('hit(s)') + '
'); + + var url = '#/page/' + $(this).attr('page'); if ($this.fluidbook.pad.enabled) { if (pagesWithHits.length == 1) { - $(this).find('a').attr('href', '#/page/' + pagesWithHits[0]); + url = '#/page/' + pagesWithHits[0]; } else { - $(this).find('a').attr('href', '#/search/' + e + '/' + $(this).attr('page')); + url = '#/search/' + e + '/' + $(this).attr('page'); } - } else { - $(this).find('a').attr('href', '#/page/' + $(this).attr('page')); } + + $(this).wrap(''); + $(this).attr('data-enabled', '1'); + // Add the link to the main result page. Link around the hits div is for better usability (previously wasn't clickable) + $(this).append('
' + totalHits + ' ' + $this.fluidbook.l10n.__('hit(s)') + '
'); + } }); diff --git a/js/libs/fluidbook/menu/fluidbook.index.js b/js/libs/fluidbook/menu/fluidbook.index.js index 215092b8..f93194ee 100644 --- a/js/libs/fluidbook/menu/fluidbook.index.js +++ b/js/libs/fluidbook/menu/fluidbook.index.js @@ -62,8 +62,18 @@ FluidbookIndex.prototype = { return this.normalHTML; }, - _getNormalView: function (forceNormal, height) { + _getSearchResultsView: function () { + return this._getNormalView(true, 141, false, false); + }, + + _getNormalView: function (forceNormal, height, bookmarks, pageLinks) { var contentClass = 'content'; + if (pageLinks === undefined) { + pageLinks = true; + } + if (bookmarks === undefined) { + bookmarks = true; + } if (forceNormal === undefined) { forceNormal = false; } @@ -118,8 +128,8 @@ FluidbookIndex.prototype = { } if (i > 0) { - ix1 += this._thumb(i, s1, height); - if (this.fluidbook.bookmarks.enabled) { + ix1 += this._thumb(i, s1, height, undefined, pageLinks); + if (this.fluidbook.bookmarks.enabled && bookmarks) { ix1 += this.fluidbook.bookmarks.getBookmarkForPage(i, mobileFirst, this.fluidbook.settings.bookmarkPermanentIcon); } pages.push(i); @@ -137,8 +147,8 @@ FluidbookIndex.prototype = { } if (!this.singleMode) { if (j <= this.fluidbook.contentlock.getMaxPage()) { - ix2 += this._thumb(j, s1, height); - if (this.fluidbook.bookmarks.enabled) { + ix2 += this._thumb(j, s1, height, undefined, pageLinks); + if (this.fluidbook.bookmarks.enabled && bookmarks) { ix2 += this.fluidbook.bookmarks.getBookmarkForPage(j, true); } ix2 += ''; @@ -163,13 +173,25 @@ FluidbookIndex.prototype = { return res; }, - _thumb: function (page, side, height, label) { + _thumb: function (page, side, height, label, link) { + if (link === undefined) { + link = true; + } var dim = this.getThumbDimensions(page, height); var virtual = this.fluidbook.physicalToVirtual(page); if (label === undefined) { label = virtual; } - return '
' + this.fluidbook.loader.getThumbImage(page, true, dim.thumb) + ''; + var res = '
'; + if (link) { + res += ''; + } + res += this.fluidbook.loader.getThumbImage(page, true, dim.thumb); + if (link) { + res += ''; + } + res += ''; + return res; }, getThumbDimensions: function (page, height) { -- 2.39.5