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 %]
<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 %]
<li class="nav-item"><a class="nav-link" href="#tabs-constituents" data-toggle="tab">Constituents</a></li>
[% END %]

View file

@ -58,7 +58,7 @@
</li>
[% 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 %]
<li class="nav-item"><a class="nav-link" href="#tabs-errors" data-toggle="tab"><span class="text-warning">Evaluation errors</span></a></li>
[% END %]

View file

@ -15,7 +15,7 @@
</li>
[% 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>
</ul>

View file

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