From 4c6d83cc5a8b6cf534705974da64d32895ad5172 Mon Sep 17 00:00:00 2001 From: Hofi Date: Wed, 22 May 2024 15:01:53 +0200 Subject: [PATCH] Should hide the tooltip on page resize as well - unset focus on cached page back and force navigation - some type fix Signed-off-by: Hofi --- _js/custom/navigation.js | 7 +++++++ _js/main.min.js | 4 ++++ _plugins/generate_tooltips.rb | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/_js/custom/navigation.js b/_js/custom/navigation.js index 9bcf96cb..98f8ec05 100644 --- a/_js/custom/navigation.js +++ b/_js/custom/navigation.js @@ -148,6 +148,8 @@ $(function () { // Try to scroll to a giben anchor, if any if (anchorId) scrollToAnchor(anchorId); + // Clear any focus (e.g back navigation keeps the previously clicked link focused) + window.trigger('blur'); } function updateContentFromUrl(url) { @@ -709,6 +711,11 @@ $(function () { elementUnderCursor = event.target; }); + window.addEventListener('resize', function () { + if (tooltipTarget) + hideTooltip(true); + }); + window.addEventListener('blur', function () { if (tooltipTarget) hideTooltip(true); diff --git a/_js/main.min.js b/_js/main.min.js index 85a7513a..bb1e4623 100644 --- a/_js/main.min.js +++ b/_js/main.min.js @@ -8539,6 +8539,7 @@ $(function() { if (ClipboardJS.isSupported()) addCodeBlocksTitle(); addContentTooltips(); if (anchorId) scrollToAnchor(anchorId); + window.trigger("blur"); } function updateContentFromUrl(url) { var currContent = document.querySelector(contentID); @@ -8876,6 +8877,9 @@ $(function() { document.addEventListener("mouseover", function(event) { elementUnderCursor = event.target; }); + window.addEventListener("resize", function() { + if (tooltipTarget) hideTooltip(true); + }); window.addEventListener("blur", function() { if (tooltipTarget) hideTooltip(true); }); diff --git a/_plugins/generate_tooltips.rb b/_plugins/generate_tooltips.rb index 6307c0ca..1be9c976 100644 --- a/_plugins/generate_tooltips.rb +++ b/_plugins/generate_tooltips.rb @@ -58,7 +58,7 @@ def make_tooltip(page, page_links, id, url, match) link_data = page_links[id] if link_data != nil url = link_data["url"] - url = prefixed_url(url, page.site.config["baseurl"]) + url = prefixed_url(url, page.site.config["baseurl"]) else puts "Error: Unknown ID in matching part: #{match_parts}" return match @@ -309,7 +309,7 @@ def gen_page_link_data(links_dir, link_files_pattern) page_link_data = page_links_dictionary[alias_id] if page_link_data == nil - puts "Error: Unknow ID (#{alias_id}) in alias definition" + puts "Error: Unknown ID (#{alias_id}) in alias definition" exit 4 end page_link_data["title"].concat(alias_data["aliases"])