From 321fdec3da29b6fdbb22f89ec8080a3216a25672 Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Aug 13 2018 23:46:27 +0000 Subject: make anchor tabs work better on stats page Fixes #3446 --- diff --git a/pagure/templates/repo_stats.html b/pagure/templates/repo_stats.html index 65051c5..45bdeae 100644 --- a/pagure/templates/repo_stats.html +++ b/pagure/templates/repo_stats.html @@ -111,23 +111,38 @@ commits_history_call = function() { $(document).ready(function() { $('.stats_btn').click(function(ev){ + ev.preventDefault(); var _b = $("#data_stats"); _b.hide(); - $('.stats_btn').removeClass('active') + $('.stats_btn').removeClass('active'); if ($(this).attr('name') == 'issues') { {% if config.get('ENABLE_TICKETS', True) %} issues_history_stats_plot_call(); $(this).addClass('active'); + window.location.hash = 'issues' {% endif %} } else if ($(this).attr('name') == 'authors') { commits_authors_call(); $(this).addClass('active'); + window.location.hash = 'authors' } else if ($(this).attr('name') == 'commits') { commits_history_call(); $(this).addClass('active'); + window.location.hash = 'commits' } }); - + window.onhashchange = function () { + if (window.location.hash == 'issues') { + {% if config.get('ENABLE_TICKETS', True) %} + issues_history_stats_plot_call(); + {% endif %} + } else if (window.location.hash == 'authors') { + commits_authors_call(); + } else if (window.location.hash == 'commits') { + commits_history_call(); + } + } + $('.stats_btn[name="authors"]').trigger("click"); }); {% endblock %} diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 0d21278..6b6f81c 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -1008,6 +1008,7 @@ def view_branches(repo, username=None, namespace=None): branchname=branchname, ) + @UI_NS.route('//forks/') @UI_NS.route('//forks') @UI_NS.route('///forks/') @@ -1019,7 +1020,7 @@ def view_branches(repo, username=None, namespace=None): def view_forks(repo, username=None, namespace=None): """ Forks """ - + return flask.render_template( 'repo_forks.html', select='forks',