[HOME] [DOWNLOAD] [DOCS] [BLOG] [SUPPORT] [TIPS] [ISSUES] [Priority Support]

expand all at once button for wiki/Documentation


#1

Please see:

Any idea on how to add an expand all button (so not each one has to be manually clicked)?

//cc @fortasse


#2

Seems like people have wanted it for years: https://www.mediawiki.org/wiki/Manual_talk:Collapsible_elements

We could hack something up in javascript though, all the expandable elements share a class we can iterate through.


#3

Yes, if not too much gymnastics, that would be awesome!


#4

I have the JS:

Array.from(document.getElementsByClassName("mw-collapsible-toggle-collapsed")).forEach(function(section){section.childNodes[1].click()});

for expanding and

Array.from(document.getElementsByClassName("mw-collapsible-toggle-expanded")).forEach(function(section){section.childNodes[1].click()});

for collapsing. I’m having trouble figuring out how to get the hooks in Mediawiki proper. I think we did something to do the “simple/complicated” documentation split, do you have any idea how the technical side of that @Patrick?


#5

Nevermind. I got Widgets and Templates confused.

Proof of concept here: https://www.whonix.org/w/index.php?title=Fortasse:Sandbox&stable=0
Widget here: https://www.whonix.org/wiki/Widget:Expand_or_Collapse_All

I’m not very stylish, so if you have ideas on how to “prettify” it, by all means. :slight_smile:


#6

Do we need a collapse all button? Seems rather playful. I mean, if someone ever needs that, we could just say “just reload the page”. For perfection’s sake it would be one button, but even that is not really needed. I am more than happy about the “expand all” button. Could you add it to https://www.whonix.org/wiki/Documentation please? I am fine with the styling, but if anyone has suggestions (and code?) to prettify it, why not.


#7

Although when you “expand all” the page is huge. So if a user wants to easily navigate back to another major section, it is easier for them to hit “collapse all” for convenience.

Also, the standard web pages where you see functionality seem to have both. Better to follow normal standards (?)

Either way, thanks @fortasse! It’s a big improvement.


#8

Now live on https://www.whonix.org/wiki/Documentation . The widget should be reusable for any other pages that have mediawiki-style expandable sections, if needed.