Bring deep-embedding (tab anchors) javascript up-to-date

This commit is contained in:
Tyson Whitehead 2021-04-08 11:04:37 -04:00
parent b6f5b6eb38
commit 3f77bd240f
No known key found for this signature in database
GPG key ID: B22199763A27997B
4 changed files with 13 additions and 20 deletions

View file

@ -15,7 +15,7 @@ removed or had an evaluation error.</div>
[% END %] [% END %]
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="nav-item active"><a class="nav-link" href="#tabs-status" data-toggle="tab">Status</a></li> <li class="nav-item"><a class="nav-link active" href="#tabs-status" data-toggle="tab">Status</a></li>
[% IF constituentJobs.size > 0 %] [% IF constituentJobs.size > 0 %]
<li class="nav-item"><a class="nav-link" href="#tabs-constituents" data-toggle="tab">Constituents</a></li> <li class="nav-item"><a class="nav-link" href="#tabs-constituents" data-toggle="tab">Constituents</a></li>
[% END %] [% END %]

View file

@ -58,7 +58,7 @@
</li> </li>
[% END %] [% END %]
<li class="nav-item active"><a class="nav-link" href="#tabs-evaluations" data-toggle="tab">Evaluations</a></li> <li class="nav-item"><a class="nav-link active" href="#tabs-evaluations" data-toggle="tab">Evaluations</a></li>
[% IF jobset.errormsg || jobset.fetcherrormsg %] [% IF jobset.errormsg || jobset.fetcherrormsg %]
<li class="nav-item"><a class="nav-link" href="#tabs-errors" data-toggle="tab"><span class="text-warning">Evaluation errors</span></a></li> <li class="nav-item"><a class="nav-link" href="#tabs-errors" data-toggle="tab"><span class="text-warning">Evaluation errors</span></a></li>
[% END %] [% END %]

View file

@ -15,7 +15,7 @@
</li> </li>
[% END %] [% END %]
<li class="nav-item active"><a class="nav-link" href="#tabs-project" data-toggle="tab">Jobsets</a></li> <li class="nav-item"><a class="nav-link active" href="#tabs-project" data-toggle="tab">Jobsets</a></li>
<li class="nav-item"><a class="nav-link" href="#tabs-configuration" data-toggle="tab">Configuration</a></li> <li class="nav-item"><a class="nav-link" href="#tabs-configuration" data-toggle="tab">Configuration</a></li>
</ul> </ul>

View file

@ -50,25 +50,18 @@ $(document).ready(function() {
$(".hydra-popover").popover({}); $(".hydra-popover").popover({});
$(function() { /* Activates tab according to URL anchor. */
if (window.location.hash) { if (window.location.hash) {
$(".nav-tabs a[href='" + window.location.hash + "']").tab('show'); $('.nav-tabs > .nav-item:not(.dropdown) a[href="' + window.location.hash + '"]').tab('show');
} }
/* If no tab is active, show the first one. */ $('.nav-tabs').each(function() {
$(".nav-tabs").each(function() { if ($('.nav-item:not(.dropdown) a.active',this).length == 0)
if ($("li.active", this).length > 0) return; $('.nav-item:not(.dropdown) a',this).first().tab('show');
$("a", $(this).children("li:not(.dropdown)").first()).tab('show'); });
});
/* Ensure that pressing the back button on another page $('.nav-tabs > .nav-item:not(.dropdown) a[href^="#"]').on('click', function() {
navigates back to the previously selected tab on this history.replaceState(null, null, window.location.href.split("#")[0] + $(this).attr("href"));
page. */
$('.nav-tabs').bind('show', function(e) {
var pattern = /#.+/gi;
var id = e.target.toString().match(pattern)[0];
history.replaceState(null, "", id);
});
}); });
/* Automatically set Bootstrap radio buttons from hidden form controls. */ /* Automatically set Bootstrap radio buttons from hidden form controls. */