Skip to content

Commit

Permalink
Restore collapsed states of outputs boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
kasnerz committed Nov 6, 2024
1 parent e72d776 commit f8b3a9d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions factgenie/static/js/browse.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var current_example_idx = 0;
var selected_campaigns = [];
var collapsed_boxes = [];
var splitInstance = Split(['#centerpanel', '#rightpanel'], {
sizes: [66, 33],
gutterSize: 1,
Expand Down Expand Up @@ -334,6 +335,8 @@ function showSelectedCampaigns() {
$(this).removeClass("active");
}
});


}

function toggleRaw() {
Expand All @@ -359,6 +362,8 @@ function updateDisplayedAnnotations() {
// show the selected annotator
$(`.box-${campaign_id}`).show();
}

restoreCollapsedStates();
enableTooltips();
}

Expand Down Expand Up @@ -414,3 +419,28 @@ $(document).ready(function () {
enableTooltips();
});

// Restore collapsed states after page change/content load
function restoreCollapsedStates() {
collapsed_boxes.forEach(targetId => {
const element = document.getElementById(targetId);
if (element) {
const bsCollapse = new bootstrap.Collapse(element, {
toggle: false
});
bsCollapse.hide();
}
});
}

// Store collapsed state when boxes are toggled
document.addEventListener('shown.bs.collapse', function (e) {
const targetId = e.target.id;
collapsed_boxes = collapsed_boxes.filter(id => id !== targetId);
});

document.addEventListener('hidden.bs.collapse', function (e) {
const targetId = e.target.id;
if (!collapsed_boxes.includes(targetId)) {
collapsed_boxes.push(targetId);
}
});

0 comments on commit f8b3a9d

Please sign in to comment.