MediaWiki talk:CollapsibleTables.js

From Guild Wars 2 Wiki
Jump to navigationJump to search

Description[edit]

This class allows to make tables collapsible and adds a show/hide button to affected tables. Tables which class attribute contains collapsible or expandable are affected by this class and can be collapsed; the latter automatically hides the content of all sections.
Header rows are used to divide the table into sections which can be collapsed separately. By default the first row of the table is interpreted as a header row, however this can be overwritten by adding collapsible to the class attribute of header rows. You can also hide a section individually by default when in collapsible mode by using expandable as the row's class name instead.

Usage examples[edit]

Note: Style information are not shown in the code column.
Code Result
{| class="collapsible"
! Table title
|-
| Table content
|}
Table title
Table content
{| class="expandable"
! Table title
|-
| Table content
|}
{| class="collapsible"
! Table title
|- class="collapsible"
! Subtitle 1
|-
| Subtable content
|- class="expandable"
! Subtitle 2
|-
| Subtable content
|}
Table title
Subtitle 1
Subtable content
Subtable content

See also[edit]

Additional check for malformed tables without rows[edit]

I just noticed that this js throws an error to the console if there was a table on the page which had class="collapsible/expandable" without any rows defined. It sounds like a mad niche case, but I found a visually working example here. I suspect there are other nav templates with the same broken wikitext. -Chieftain AlexUser Chieftain Alex sig.png 12:48, 10 June 2017 (UTC)

I broke stuff? :< I copy-pasted the PvP league backpieces nav, which in turn was a copy-paste of another one... which I cannot remember at present. :( 91.67.25.63 13:22, 10 June 2017 (UTC)
It's good for QA. :) Chieftain AlexUser Chieftain Alex sig.png 14:07, 10 June 2017 (UTC)