Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always show the traceability information of selected item #366

Merged
merged 7 commits into from
Jan 4, 2024
Merged
14 changes: 8 additions & 6 deletions mlx/traceability/assets/traceability.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ jQuery(function () {
});

$(document).ready(function () {
const anchorId = location.hash.slice(1);
$('div.collapsible_links div.admonition.item').each(function (i) {
$(this).siblings('dl').first().addCollapseButton($(this));
$(this).siblings('dl').first().addCollapseButton($(this), anchorId);
$(this).css('clear', 'left'); // sphinx-rtd-theme==0.5.0 sets `clear: both` which pushes button out of bar
});

Expand Down Expand Up @@ -60,8 +61,7 @@ $(document).ready(function () {
});

// if an item was selected, ensure it's displayed at the top of the viewport
if (location.hash) {
const anchorId = location.hash.slice(1);
if (anchorId) {
const element = document.getElementById(anchorId);
if (element) {
element.scrollIntoView(true, { block: "start", inline: "nearest" });
Expand All @@ -71,11 +71,12 @@ $(document).ready(function () {

// item
jQuery.fn.extend({
addCollapseButton: function (admonition) {
addCollapseButton: function (admonition, anchorId) {
var relations = $(this);

if (relations.children().length > 0) {
if (admonition.parent().hasClass('collapse')) {
const itemDiv = admonition.parent()
if (itemDiv.hasClass('collapse') && itemDiv.attr('id') != anchorId) {
0xBDEF marked this conversation as resolved.
Show resolved Hide resolved
// collapse relations and attributes list for each item on page load
relations.toggle();
arrowDirection = 'down';
Expand All @@ -94,7 +95,8 @@ jQuery.fn.extend({
'font-size': '135%',
'color': linkColor,
'float': 'right',
'padding': '1px ' + paddingX
'padding': '1px ' + paddingX,
'cursor': 'pointer',
},
click: function () {
relations.toggle('fold');
Expand Down