]> _ Git - fluidbook-html5.git/commitdiff
done #3766 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 30 Sep 2020 15:04:31 +0000 (17:04 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 30 Sep 2020 15:04:31 +0000 (17:04 +0200)
js/libs/fluidbook/fluidbook.accessibility.js
js/libs/fluidbook/fluidbook.keyboard.js
js/libs/fluidbook/fluidbook.search.js
js/libs/fluidbook/menu/fluidbook.index.js

index 65525eeb9002263da4aa29c83535a78b78ca351e..f422464e68d357b6bc3babcada3eb72adbccb582 100644 (file)
@@ -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
index 7cfa8fe7444851feb2584df1f95bcaf66df8e4e2..7e9450e2c884c378278aacac5554a9b1ec1e3ce9 100644 (file)
@@ -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);
     },
index 576935bbf321c4976e17fa2fc1a77d924823f56f..9c131d47659ca3ade2218fd055b9846832001ac0 100644 (file)
@@ -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('<a href="#/page/' + $(this).attr('page') + '"><div class="hits yes">' + totalHits + ' ' + $this.fluidbook.l10n.__('hit(s)') + '</div></a>');
+
+                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('<a class="menuSearchResult" href="' + url + '"></a>');
+                $(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('<div class="hits yes">' + totalHits + ' ' + $this.fluidbook.l10n.__('hit(s)') + '</div>');
+
             }
         });
 
index 215092b81df25508b4a357f1e02f9b5c32db9d26..f93194eeffe4ef7a6de5d1fae731ef7cd1da5dbf 100644 (file)
@@ -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 += '</div>';
@@ -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 '<div class="thumb ' + side + '" ' + dim.thumb + '><a role="button" aria-label="' + sprintf(this.fluidbook.l10n.__('goto page %s'), label) + '" href="#/page/' + page + '">' + this.fluidbook.loader.getThumbImage(page, true, dim.thumb) + '</a><span aria-hidden="true" class="number" ' + dim.pagenumber + '>' + label + '</span>';
+        var res = '<div class="thumb ' + side + '" ' + dim.thumb + '>';
+        if (link) {
+            res += '<a role="button" aria-label="' + sprintf(this.fluidbook.l10n.__('goto page %s'), label) + '" href="#/page/' + page + '">';
+        }
+        res += this.fluidbook.loader.getThumbImage(page, true, dim.thumb);
+        if (link) {
+            res += '</a>';
+        }
+        res += '<span aria-hidden="true" class="number" ' + dim.pagenumber + '>' + label + '</span>';
+        return res;
     },
 
     getThumbDimensions: function (page, height) {