From 4730482e742d4cc95b1c230e74bb43cfdefb5c1e Mon Sep 17 00:00:00 2001 From: cep Date: Jan 09 2017 14:21:19 +0000 Subject: Fix request_diff showing instead of commit_list in new tab Fixed the issue where opening the 'Commits' tab in a new browser tab showed the 'Files Changed' tab instead. Fixes https://pagure.io/pagure/issue/787 --- diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index 92bec98..c4aef29 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -1244,10 +1244,23 @@ function updateHighlight(onload) { highlight_comment(); } else { if (onload) { - $('#request_diff').addClass('active'); - $('#comments').removeClass('active'); + $('#comments').removeClass('active'); + $('[href="#comments"]').removeClass('active'); + // When the hash points to 'Files Changed' tab. + if (location.hash.indexOf("request_diff") > -1) { $('[href="#request_diff"]').addClass('active'); - $('[href="#comments"]').removeClass('active'); + $('#request_diff').addClass('active'); + } + // When the hash points to 'Commits' tab. + else if (location.hash.indexOf("commit_list") > -1) { + $('[href="#commit_list"]').addClass('active'); + $('#commit_list').addClass('active'); + } + // If neither, then show the 'Comments' tab by default. + else { + $('#comments').addClass('active'); + $('[href="#comments"]').addClass('active'); + } } var file = parseInt(location.hash.substr(2).split(',')[0], 10); var lines = location.hash.split(',')[1].split('-').map(function (x) { return parseInt(x, 10) });