ShowHide

This script has been superceded by features in core MediaWiki software

Now that all Wikia wikis have been upgraded from MediaWiki 1.16 to 1.19, collapsible elements are supported by default in core MediaWiki. See Help:Collapsing for more details. All users are highly advised to phase out usage of this script and begin using mw-collapsible class instead. This will allow you to remove outdated code from your wiki (this script), which in turn makes maintaining your code base easier and makes pages load faster.

Please submit translations for missing languages to the talkpage instead of putting them in your wiki's Common.js

Contents

Feature overview

Customize button labels according to site (or user) language preference.

Show all / Hide all

[show all] and [hide all] buttons can be placed anywhere on a page and in multiple locations.

All NavFrame blocks on the page are affected however, collapsible tables are not affected by these buttons. This behavior is by design.

Specify collapsed by default

A NavFrame block or collapsible table that also uses the collapsed class will be hidden by default but can always be manually expanded.

Auto-collapse threshold

When the specified number of NavFrame blocks or collapsible tables with the autocollapse class are present on a page then all will collapse by default. The counts are handled separately, so one NavFrame and one collapsible table will not be considered 2.

Can be overridden for specific NavFrames if the noautocollapse class is also used.

Specify non-collapsible rows of a table

Using class="nocollapse" on a row will prevent that row from collapsing.

ShowHideConfig.autoCollapse sets the threshold for default collapse of all collapsible content on a page. When the number of NavFrames or collapsible tables with the autocollapse on the page is equal to or greater than specified number then auto-collapse is triggered.

By default this is set to 2 meaning for example "If there are two or more NavFrames on the page, then hide them all by default", and likewise for collapsible tables with autocollapse on them.

You can change this to any number.

Setting it to 0 will make it so things are always collapsed by default.

setting it to Infinity will make it so things never auto-collapse. (Note: Infinity is case-sensitive)

NavFrames with the noautocollapse class do count toward the NavFrame threshold and are never auto-collapsed but can always be manually collapsed.

NavFrames with the collapsed class do count toward the NavFrame threshold and are always initially collapsed but can always be manually expanded.

userLang

(true|false) ShowHide is smart about what language to use to display show/hide messages. Currently by default it will prefer the user's language, but use the content language otherwise, and fall back to English if there are no messages in a desired language. You can disable this by setting the ShowHideConfig.userLang option to false.

langCode

Messages for localization of the language used in button labels can be added using the two-character language code as a key (e.g. ShowHideConfig.en or ShowHideConfig.ja) and then creating an object for four messages. The four messages used are "show", "hide", "showAll", and "hideAll". See example below for how to override the default labels used for the English language. Translations for missing languages can be posted to the talkpage.

linkBefore

Set to true to have ShowHide prepend links to NavFrame instead of appending them.

brackets

Allows changing the style of the brackets around the "show" and "hide" buttons from the default [].

Magnify and shrink pictures without leaving the article

Normally, if you click on the magnify sprite, , located right-most inside the thumbnail image caption box you are taken away from the article you were browsing to a page in the File namespace where the detail and history for that image can be viewed. The size of the image displayed there may not be the precise size that the author wanted to show the reader. If you click on the image itself you are taken to that same details page.

You can use ShowHide functionality to toggle between a small image and a magnified image in-situ - i.e. without leaving the currently displayed wiki article.

The article text will adjust to flow around the expanded image in whichever way the author has designed it to.

The author may specify the precise sizes of the smaller image and the larger image.

This is really just a special application of the NavFrame class but with:

two NavContent div elements instead of just one

a potentially confusing relationship between the "display:none" in-line style and the collapsed in-line class tag

careful placement of {{clr}} so as to disable text-wrap based on whichever image is currently visible

Note that using the NavPic class does not yield the same result. Indeed, the NavPic class currently serves no useful purpose.

Caveat

The style display:none will cause the content of that div element to never be displayed at a browser that has disabled (or does not support) javascript.

Wiki markup

Rendered

Note how the combined effect of "collapsed" and "display:none;" is for the 120px thumbnail to be initially VISIBLE with a show button displayed to reveal the larger, hidden image.