From 0ca5f4750730fd71c4fd230f0024c55590dac0cf Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Tue, 15 May 2018 01:39:38 +0200 Subject: Fix javascript problem that causes unintended behavior If you browse in a browser tab through some websites and want to go back to the previous page, post or user, you can either click the history back button, press the corresponding key on your mouse or even press + on your keyboard. But if you only press on a page, post or user, the callback function of the "keyup" event will change the location in the desired direction on the blog if there is a previous page, post or user, and if neither nor is pressed. This is a functionality of the javascript from the template and not a functionality of your browser. Pressing + IS a functionality of the browser and should not conflict with the behavior when is pressed alone. This commit fixes this problem by adding the condition that should not be pressed either. --- template/admin/rsrc/main.js | 2 +- template/standard/rsrc/main.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/template/admin/rsrc/main.js b/template/admin/rsrc/main.js index 1870ced..46880f2 100644 --- a/template/admin/rsrc/main.js +++ b/template/admin/rsrc/main.js @@ -8,7 +8,7 @@ const next = document.getElementById("next-site"); // Handle arrow keys and change the location to the desired direction //============================================================================== document.addEventListener("keyup", function(e) { - if(!e.ctrlKey && !e.shiftKey) { + if(!e.ctrlKey && !e.shiftKey && !e.altKey) { (e.keyCode === 37 && prev) && (window.location.href = prev.getAttribute("href")); (e.keyCode === 39 && next) && (window.location.href = next.getAttribute("href")); } diff --git a/template/standard/rsrc/main.js b/template/standard/rsrc/main.js index 6d088e3..f73d061 100644 --- a/template/standard/rsrc/main.js +++ b/template/standard/rsrc/main.js @@ -8,7 +8,7 @@ const next = document.getElementById("next-site"); // Handle arrow keys and change the location to the desired direction //============================================================================== document.addEventListener("keyup", function(e) { - if(!e.ctrlKey && !e.shiftKey) { + if(!e.ctrlKey && !e.shiftKey && !e.altKey) { (e.keyCode === 37 && prev) && (window.location.href = prev.getAttribute("href")); (e.keyCode === 39 && next) && (window.location.href = next.getAttribute("href")); } -- cgit v1.2.3