Skip to content

Commit

Permalink
Add anchor link to plugin details tabs (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xpirix authored Nov 30, 2023
1 parent 0a5d8a9 commit b661773
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions qgis-app/plugins/templates/plugins/plugin_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,44 @@
});
});
});

// Handle URL anchor for tabs
$(window).load(function() {

// Store the current scroll position
var scrollPosition = 0;

// Handle tab clicks
$('.nav-tabs a').on('click', function (e) {
e.preventDefault();

// Store the current scroll position
scrollPosition = $(window).scrollTop();

// Update the URL without triggering a reload
window.location.hash = this.hash;

// Show the tab
$(this).tab('show');
});

// Restore the scroll position on tab change
$('.nav-tabs a').on('shown.bs.tab', function (e) {
$(window).scrollTop(scrollPosition);
});

// Activate the tab based on the URL fragment
var hash = window.location.hash;
if (hash) {
$('.nav-tabs a[href="' + hash + '"]').tab('show');
}

// Scroll to the top when the page loads
setTimeout(() => {
$(window).scrollTop(0);
})

});
</script>
{% endblock %}
{% block extracss %}
Expand Down

0 comments on commit b661773

Please sign in to comment.