From 3b45a9a3dca119c5a8e1b3c57e49aef0c25ef5f9 Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Mon, 7 Jun 2021 21:12:50 +0100 Subject: [PATCH] Fix unresponsive click on article Former-commit-id: 8fb53644e892c569b6a5585a836a1b68a82ae9db [formerly 1fa30468411d5d2b5aa6c67d4eedbd1dbac1c813 [formerly f5b648bc5b970f989e7c2ba9c84c3e499532efae]] Former-commit-id: 3c8b7bd55e9be025dabe8041aa98e916be20c6f7 Former-commit-id: f3c95bc7d185912e490928dca2f24bc79b711e57 --- www/js/app.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index 4eb0fb70..3d455f52 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -4083,8 +4083,11 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett addListenersToLink(anchor, href, baseUrl); } }); - // Add event listeners to the main document so user can open current document in new tab or window - if (articleWindow.document.body) addListenersToLink(articleWindow.document.body, encodeURIComponent(dirEntry.url.replace(/[^/]+\//g, '')), baseUrl); + // Add event listeners to the main heading so user can open current document in new tab or window by clicking on it + if (articleWindow.document.body) { + var h1 = articleWindow.document.body.querySelector('h1'); + if (h1) addListenersToLink(h1, encodeURIComponent(dirEntry.url.replace(/[^/]+\//g, '')), baseUrl); + } } /** @@ -4128,14 +4131,14 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett appstate.target = kiwixTarget; articleWindow = thisWindow; articleContainer = thisContainer; - if (a.tagName === 'BODY') { - // We have registered a click on the document + if (a.tagName === 'H1') { + // We have registered a click on the header if (!a.newcontainer) return; // A new tab wasn't requested, so ignore // If we're not clicking within the scope of an H1, H2, etc., ignore the click - if (!uiUtil.getClosestMatchForTagname(e.target, /H\d/)) { - setTimeout(reset, 1400); - return; - } + // if (!uiUtil.getClosestMatchForTagname(e.target, /H\d/)) { + // setTimeout(reset, 1400); + // return; + // } } if (params.windowOpener) { // This processes Ctrl-click, Command-click, the long-press event, and middle-click