Skip to content

Commit 7d13a2a

Browse files
committed
Cleanup code
1 parent 77f6abc commit 7d13a2a

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

LongevityWorldCup.Website/wwwroot/partials/leaderboard-content.html

+26-15
Original file line numberDiff line numberDiff line change
@@ -2679,31 +2679,42 @@ <h3>Proofs</h3>
26792679
});
26802680

26812681
function toggleSidebar() {
2682+
if (sidebar.classList.contains('expanded')) {
2683+
closeSidebar();
2684+
}
2685+
else {
2686+
openSidebar();
2687+
}
2688+
}
2689+
2690+
function openSidebar() {
26822691
sidebar.classList.remove('partially-expanded');
2683-
sidebar.classList.toggle('expanded');
26842692
sidebar.classList.remove('collapsed');
2685-
sidebarToggle.classList.toggle('active');
2686-
2687-
if (sidebar.classList.contains('expanded')) {
2688-
sidebarToggle.title = "Hide Leagues";
2689-
sidebarToggle.setAttribute('aria-label', 'Hide Sidebar');
26902693

2691-
// Scroll to the leaderboard table when closing the sidebar
2692-
document.querySelector('.search-wrapper .sidebar-toggle').scrollIntoView({
2693-
behavior: 'smooth',
2694-
block: 'start',
2695-
});
2696-
} else {
2697-
sidebarToggle.title = "Show Leagues";
2698-
sidebarToggle.setAttribute('aria-label', 'Show Sidebar');
2694+
if (!sidebar.classList.contains('expanded')) {
2695+
sidebar.classList.add('expanded');
26992696
}
2697+
if (!sidebarToggle.classList.contains('active')) {
2698+
sidebarToggle.classList.add('active')
2699+
}
2700+
2701+
sidebarToggle.title = "Hide Leagues";
2702+
sidebarToggle.setAttribute('aria-label', 'Hide Sidebar');
2703+
2704+
// Scroll to the leaderboard table
2705+
document.querySelector('.search-wrapper .sidebar-toggle').scrollIntoView({
2706+
behavior: 'smooth',
2707+
block: 'start',
2708+
});
27002709
}
27012710

27022711
function closeSidebar() {
27032712
sidebar.classList.remove('expanded');
27042713
sidebarToggle.classList.remove('active');
27052714
sidebar.classList.remove('partially-expanded');
2706-
sidebar.classList.add('button-collapsed');
2715+
if (!sidebar.classList.contains('button-collapsed')) {
2716+
sidebar.classList.add('button-collapsed');
2717+
}
27072718
sidebarToggle.title = "Show Leagues";
27082719
sidebarToggle.setAttribute('aria-label', 'Show Sidebar');
27092720

0 commit comments

Comments
 (0)