GhostInTheMachine • Talk • All • Help • Misc • Modules • Other • Layout • Photos • Projects • Scripts • Tidying • TidyingSD • TODO • UBX • WIP • 2024-08-11 12:46:49 |
Purpose
editThis script adds an icon in front of each section header.
- for a section that is expanded — fully displayed
- for a section that is collapsed — everything below the heading is hidden
Use
editThe icon acts as a toggle button — collapsing or "folding" the text of a displayed section or displaying the text of a currently collapsed section.
The icon is added to all headings from H2 down.
Prerequisites
editThe script probably only works on Vector. I have not tried it on other skins or on Evil Vector.
Installing
editAdd the following line to your common.js file.
{{subst:Lusc|User:GhostInTheMachine/FoldSections.js}}
Add the following line for elsewhere
mw.loader.load( '/w/index.php?title=User:GhostInTheMachine/FoldSections.js&action=raw&ctype=text/javascript' ); // Backlink: User:GhostInTheMachine/FoldSections.js
Notes
editThis script was shamelessly stolen from User:BrandonXLF/CollapseSections.
I then changed the CSS to change the icons from up/down chevrons to down/right chevrons
- See the collection of possible "standard" OOUI icons.
The script is active for articles, talk pages and (now) user contribution pages.
Contributions list
editIn March 2022, T298638 added daily date headings into the user contributions page. Rather than have the code test for which skin was in use and only output them for the mobile skin, on the desktop skins the dates are just hidden.
This script adds CSS to cause the daily dates to be also displayed for desktop skins, so that it is possible to collapse individual days in the list.
Talk pages
editThe script no longer works on talk pages (and such pages as the Village Pump) due to the Discussion Tools changes. Talk pages no longer show the section headings in H2 tags as nature intended, but in a div tag which has a mw-heading2 class.
As of January 2023[update], I am working to alter this script to cope with the change.
Alternatives
edit- User:BrandonXLF/CollapseSections — the original — puts icons in front of all section headings
- User:BethNaught/hideSectionDesktop — puts links after the section headings — only H2 headings
Bugs
editJune 2024
editDamage due to a series of changes to the HTML created for headings.
- see T365736 and more details in mw:Heading HTML changes
Possible improvements
editReplace the icons with characters
- This might avoid any extra load dependency
- This would allow them to be styled to a different colour
- Maybe — ↑ and ↓
- Have different jQuery filters for articles and the contributions page