More actions
No edit summary |
No edit summary |
||
| (7 intermediate revisions by the same user not shown) | |||
| Line 5: | Line 5: | ||
if (window.innerWidth >= 768) { | if (window.innerWidth >= 768) { | ||
const idsToCollapse = [ | const idsToCollapse = [ | ||
'Muling', 'Misc', 'Anti-ban', 'Anti-PK', 'Trip_Settings', 'Skills_Settings', 'Equipment' | 'Muling', 'Misc', 'Anti-ban', 'Proggies', 'Anti-PK', 'Trip_Settings', 'Add-On_Settings', 'Skills_Settings', 'Equipment' | ||
]; | ]; | ||
| Line 24: | Line 24: | ||
}); | }); | ||
// | // Expand any collapsed parent citizen-section containing the heading | ||
function expandCitizenSectionFromHeading(heading) { | function expandCitizenSectionFromHeading(heading) { | ||
if (!heading) return; | if (!heading) return; | ||
// If the clicked ID is on a <span> inside a heading, go up to the heading | |||
if (heading.tagName === 'SPAN' && heading.parentElement && heading.parentElement.classList.contains('citizen-section-heading')) { | |||
heading = heading.parentElement; | |||
} | |||
// Case 1: Heading itself is a .citizen-section-heading | |||
if (heading.classList.contains('citizen-section-heading')) { | |||
const section = heading.nextElementSibling; | |||
if (section && section.classList.contains('citizen-section') && section.hidden) { | |||
section.hidden = false; | |||
} | |||
return; | |||
} | |||
// Case 2: Heading is inside a collapsed .citizen-section | |||
let current = heading; | let current = heading; | ||
while (current) { | while (current) { | ||
if (current.classList && current.classList.contains('citizen-section') && current.hidden) { | if (current.classList && current.classList.contains('citizen-section') && current.hidden) { | ||
current.hidden = false; | current.hidden = false; | ||
} | } | ||
if (current.classList && current.classList.contains('citizen-section-heading')) { | if (current.classList && current.classList.contains('citizen-section-heading')) { | ||
break; | break; | ||
} | } | ||
current = current.parentElement; | current = current.parentElement; | ||
| Line 40: | Line 55: | ||
} | } | ||
// | |||
// Scroll to real heading, after layout is ready | |||
function smoothScrollToHeading(heading) { | function smoothScrollToHeading(heading) { | ||
if (!heading) return; | if (!heading) return; | ||