Skip to content

Commit

Permalink
Should hide the tooltip on page resize as well (#52)
Browse files Browse the repository at this point in the history
- unset focus on cached page back and force navigation
- some type fix
Signed-off-by: Hofi <[email protected]>
  • Loading branch information
HofiOne authored May 22, 2024
2 parents e29e7c4 + 4c6d83c commit a309968
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions _js/custom/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -709,6 +711,11 @@ $(function () {
elementUnderCursor = event.target;
});

window.addEventListener('resize', function () {
if (tooltipTarget)
hideTooltip(true);
});

window.addEventListener('blur', function () {
if (tooltipTarget)
hideTooltip(true);
Expand Down
4 changes: 4 additions & 0 deletions _js/main.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
});
Expand Down
4 changes: 2 additions & 2 deletions _plugins/generate_tooltips.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"])
Expand Down

0 comments on commit a309968

Please sign in to comment.