beautyjoy / llab

Lightweight lab curriculum system
7 stars 13 forks source link

IDEA: Possible solution to the nested dropdown things that isn't entirely cry-worthy #128

Closed cycomachead closed 1 year ago

cycomachead commented 9 years ago

Clicking on each heading in the dropdown menu can hide and show all the sections below the menu.

However, the implementation could be relatively easy-ish.

Maintain an object: header-id: [ subsection-ids] then onclick() will call a function toggleSubsections() will iterate over that list and call hide() or show() and the main header item and have a field / class called subsections-visible

Alternatively, the loop can go through the dropdown items from the header item until the next header item. We could do this version right now, but it's a little wacky and won't handle nested items well. It also doesn't do a good job hiding everything on the first view of the dropdown.

This makes building the dropdown more complex because the code will need to determine what section is currently being shown and hide all the others, but this should be doable but doing 1 extra pre-process loop over all the children of the topic file.

The tricky part is if curriculum.js also now has to determine levels of nesting...that will not be good, so maybe this should wait until topic.js is refactored.