Jump to content

User:GhostInTheMachine/FoldSections

From Wikipedia, the free encyclopedia

GhostInTheMachineTalkAllHelpMiscModulesOtherLayoutPhotosProjectsScriptsTidyingTidyingSDTODOUBXWIP2024-08-11 12:46:49

Purpose

[edit]

This 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

[edit]

The 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

[edit]

The script probably only works on Vector. I have not tried it on other skins or on Evil Vector.

Installing

[edit]

Add 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

[edit]

This 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

[edit]

In 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

[edit]

The 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, I am working to alter this script to cope with the change.

Alternatives

[edit]

Bugs

[edit]

June 2024

[edit]

Damage due to a series of changes to the HTML created for headings.

see T365736 and more details in mw:Heading HTML changes

Possible improvements

[edit]

Replace 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
    • Do not try to collapse the TOC in articles
    • Confirm that the fix for T298638 does not have other side-effects
    • Check changes from T290280 and probably T13555

See also

[edit]