Fandom Developers Wiki
(update)
No edit summary
(25 intermediate revisions by 14 users not shown)
Line 1: Line 1:
  +
{{Archive|[[Help:Collapsing|Collapsing]] is a default feature of MediaWiki 1.19}}
<div style="margin: 2px 5px 3px; border: 1px solid #ccc; background-color: #ddd; color: #333; -moz-border-radius: 5px; -khtml-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; text-align: center;">Please submit translations for missing languages to [[Talk:ShowHide|the talkpage]] instead of putting them in your wiki's Common.js</div>
 
 
 
{{Infobox JavaScript
 
{{Infobox JavaScript
  +
| Status = archive
 
| Description = Script for collapsible tables/divs using jQuery
 
| Description = Script for collapsible tables/divs using jQuery
| Scope = For site-wide use
+
| Scope = s
 
| Author = [[User:Dantman|Dantman]]
 
| Author = [[User:Dantman|Dantman]]
| Updated = 22 February 2011
+
| Updated = {{updated|MediaWiki:ShowHide/code.js}}
| Code = [[/code.js]]
+
| Code = [[MediaWiki:ShowHide/code.js|code.js]]
| Skins = Monaco<br />Monobook<br />Oasis (partial)
 
| Languages = {{#language:de}}<br />{{#language:en}}<br />{{#language:es}}<br />{{#language:fr}}<br />{{#language:it}}<br />{{#language:ja}}<br />{{#language:nl}}<br />{{#language:pl}}<br />{{#language:ru}}
 
 
}}
 
}}
   
 
'''ShowHide''' is a script for collapsible tables and divs.
 
'''ShowHide''' is a script for collapsible tables and divs.
  +
  +
== Deprecation ==
  +
As ShowHide has been deprecated for over 5 years, wikis might be interested in migrating from it to the regular [[Help:Collapsing|collapsing]] feature. For that purpose, a warning feature has been added to ShowHide that warns users when the wiki is using ShowHide and listing the elements that use deprecated classes in their JavaScript console. There is also a banner notification appearing only for administrators and content moderators across whole Template and MediaWiki namespaces when ShowHide is imported, and elsewhere when deprecated classes are in use on the page. Upon dismissing the banner notification, it won't show up for the next 6 months.
  +
  +
To enable the feature, place this piece of JavaScript in your personal JavaScript page:
  +
  +
<syntaxhighlight lang="javascript">
  +
window.ShowHideDisplayWarning = true;
  +
</syntaxhighlight>
  +
  +
This particular setting cannot be enabled site-wide and is only used to help migrating over to the core MediaWiki feature.
   
 
== Feature overview ==
 
== Feature overview ==
;Localization
+
;Localization
 
: Customize button labels according to site (or user) language preference.
 
: Customize button labels according to site (or user) language preference.
;Show all / Hide all
+
;Show all / Hide all
 
: [show all] and [hide all] buttons can be placed ''anywhere'' on a page and in ''multiple'' locations.
 
: [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.
+
: 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
 
;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.
 
: A ''NavFrame'' block or collapsible table that also uses the '''collapsed''' class will be hidden by default but can always be manually expanded.
Line 24: Line 33:
 
: 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.
 
: 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.
 
:* Can be overridden for specific ''NavFrames'' if the '''noautocollapse''' class is also used.
;Specify non-collapsible rows of a table
+
;Specify non-collapsible rows of a table
 
: Using '''class="nocollapse"''' on a row will prevent that row from collapsing.
 
: Using '''class="nocollapse"''' on a row will prevent that row from collapsing.
;Nesting collapsible content
+
;Nesting collapsible content
: Nesting collapsible tables is supported.
+
: Nesting collapsible tables is supported.
 
: Nesting ''NavFrame'' blocks is supported.
 
: Nesting ''NavFrame'' blocks is supported.
;A ''complementary'' pair of NavContent blocks enables:
+
;A ''complementary'' pair of NavContent blocks enables
  +
:
 
: In-place magnify/shrink of an image.
 
: In-place magnify/shrink of an image.
 
: Author-specified word-wrap for both image sizes.
 
: Author-specified word-wrap for both image sizes.
   
 
== Configuration ==
 
== Configuration ==
To use ShowHide please include [[ShowHide/code.js]] in your site's [[MediaWiki:Common.js]] using:
+
To use ShowHide please include ShowHide/code.js in your site's [[MediaWiki:Common.js]] using:
* <code>importScriptPage('ShowHide/code.js', 'dev');</code>
+
* <code>importScriptPage('MediaWiki:ShowHide/code.js', 'dev');</code>
   
 
You can change the configuration of ShowHide by creating a '''ShowHideConfig''' object inside either:
 
You can change the configuration of ShowHide by creating a '''ShowHideConfig''' object inside either:
* your site's [[MediaWiki:Common.js]] or
+
* your site's [[MediaWiki:Common.js]] or
 
* your personal [[Special:Mypage/wikia.js|User:USERNAME/wikia.js]] or [[Special:Mypage/monobook.js|User:USERNAME/monobook.js]] depending on what skin you are using.
 
* your personal [[Special:Mypage/wikia.js|User:USERNAME/wikia.js]] or [[Special:Mypage/monobook.js|User:USERNAME/monobook.js]] depending on what skin you are using.
   
Line 47: Line 57:
 
::* Setting it to '''0''' will make it so things are always collapsed by default.
 
::* 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'')
 
::* 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 '''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.
 
:* ''NavFrames'' with the '''collapsed''' class ''do count toward the NavFrame threshold'' and are always initially collapsed but can always be manually expanded.
Line 55: Line 66:
 
; ''linkBefore''
 
; ''linkBefore''
 
: Set to true to have ShowHide prepend links to NavFrame instead of appending them.
 
: 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 <code><nowiki>[]</nowiki></code>.
   
 
=== Example ===
 
=== Example ===
  +
<syntaxhighlight lang="javascript">
<pre>
 
 
var ShowHideConfig = { autoCollapse: Infinity };
 
var ShowHideConfig = { autoCollapse: Infinity };
importScriptPage('ShowHide/code.js', 'dev');
+
importScriptPage('MediaWiki:ShowHide/code.js', 'dev');
  +
</syntaxhighlight>
</pre>
 
 
:If you prefer to ''override'' the default labels for, say, English language then you can use ''langCode'' key, '''en''', to do so. This might be done in your personal [[Special:Mypage/wikia.js|User:USERNAME/wikia.js]] or [[Special:Mypage/monobook.js|User:USERNAME/monobook.js]].
 
:If you prefer to ''override'' the default labels for, say, English language then you can use ''langCode'' key, '''en''', to do so. This might be done in your personal [[Special:Mypage/wikia.js|User:USERNAME/wikia.js]] or [[Special:Mypage/monobook.js|User:USERNAME/monobook.js]].
  +
<pre>
 
  +
<syntaxhighlight lang="javascript">
 
var ShowHideConfig = {
 
var ShowHideConfig = {
autoCollapse: 3,
+
autoCollapse: 3,
en: {
+
en: {
show: "more",
+
show: "more",
hide: "less",
+
hide: "less",
showAll: "expand all",
+
showAll: "expand all",
hideAll: "collapse all"
+
hideAll: "collapse all"
  +
}
}
 
 
};
 
};
  +
</syntaxhighlight>
</pre>
 
  +
:If you would like to change the brackets from <code><nowiki>[]</nowiki></code> to say <code><nowiki>{}</nowiki></code>,you can use:
  +
  +
<syntaxhighlight lang="javascript">
  +
var ShowHideConfig = {
  +
brackets: '{}'
  +
};
  +
</syntaxhighlight>
  +
  +
=== Styling ===
  +
For CSS styling of the show/hide button, the class <code>collapseLink</code> refers to what is inside the brackets, while the class <code>collapseButton</code> refers to the whole button.
   
 
== Collapsible table ==
 
== Collapsible table ==
 
Specify the class '''collapsible''' for the table. Optionally specify the class '''nocollapse''' for specific rows. ''viz.''
 
Specify the class '''collapsible''' for the table. Optionally specify the class '''nocollapse''' for specific rows. ''viz.''
* Nesting collapsible tables is supported.
+
* Nesting collapsible tables is supported.
 
*: Use '''class="nocollapse"''' on the row where the nested table is located to ensure its header row (with the nested show/hide button) remains visible.
 
*: Use '''class="nocollapse"''' on the row where the nested table is located to ensure its header row (with the nested show/hide button) remains visible.
   
Line 83: Line 107:
 
!width=40%|Rendered
 
!width=40%|Rendered
 
|-
 
|-
 
|<pre>
||
 
<pre>
 
 
{| class="collapsible"
 
{| class="collapsible"
 
!colspan="2"| This is a test
 
!colspan="2"| This is a test
Line 100: Line 123:
 
!colspan=2|Table with certain rows specified "nocollapse"
 
!colspan=2|Table with certain rows specified "nocollapse"
 
|-
 
|-
 
|<pre>
||
 
<pre>
 
 
{| class="wikitable collapsible"
 
{| class="wikitable collapsible"
 
!colspan="2"| Title
 
!colspan="2"| Title
Line 124: Line 146:
 
|- class="nocollapse"
 
|- class="nocollapse"
 
| abc || def
 
| abc || def
|-
+
|-
 
| 123 || 765
 
| 123 || 765
|-
+
|-
 
| xyz || 123
 
| xyz || 123
 
|- class="nocollapse"
 
|- class="nocollapse"
 
| pqr || 987
 
| pqr || 987
|-
 
 
|}
 
|}
 
|-
 
|-
 
!colspan=2 BGCOLOR="#ffffff"|Nested tables
 
!colspan=2 BGCOLOR="#ffffff"|Nested tables
 
|-
 
|-
 
|<pre>
||
 
<pre>
 
 
{| class="wikitable collapsible"
 
{| class="wikitable collapsible"
 
!colspan="2"| Title
 
!colspan="2"| Title
Line 182: Line 202:
 
| Column A || Column B
 
| Column A || Column B
 
|- class="nocollapse"
 
|- class="nocollapse"
||the
+
|the
 
|quick
 
|quick
 
|-
 
|-
||brown
+
|brown
 
|fox
 
|fox
|-
 
 
|}
 
|}
 
|-
 
|-
Line 193: Line 212:
 
|-
 
|-
 
| pqr || 987
 
| pqr || 987
|-
 
 
|}
 
|}
|-
 
 
|}
 
|}
   
Line 201: Line 218:
 
== Collapsible ''NavFrame'' block ==
 
== Collapsible ''NavFrame'' block ==
 
Use the following class definitions within tag pairs:
 
Use the following class definitions within tag pairs:
 
; NavGlobal
; NavGlobal : for placing '''[show all]''' and '''[hide all]''' buttons anywhere on the page
+
: for placing '''[show all]''' and '''[hide all]''' buttons anywhere on the page
; NavFrame : defines a ''NavFrame'' block which is the outer wrapper for using the classes '''NavHead''', '''NavContent''' and '''NavPic'''
 
  +
; NavFrame
; NavHead : the header where the show/hide link will be placed
 
 
: defines a ''NavFrame'' block which is the outer wrapper for using the classes '''NavHead''', '''NavContent''' and '''NavPic'''
; NavContent : block text content that is collapsible (may include a table)
 
  +
; NavHead
; NavPic : image content that is collapsible
 
 
: the header where the show/hide link will be placed
  +
; NavContent
 
: block text content that is collapsible (may include a table)
  +
; NavPic
 
: image content that is collapsible
   
* Nesting ''NavFrame'' blocks (tags using the '''NavFrame''' class) is supported.
+
* Nesting ''NavFrame'' blocks (tags using the '''NavFrame''' class) is supported.
 
*: Check that all tags are closed. If you see progressive indentation then that is a symptom of a tag that was never closed.
 
*: Check that all tags are closed. If you see progressive indentation then that is a symptom of a tag that was never closed.
   
Line 216: Line 238:
 
!colspan=2 BGCOLOR="#ffffff"|Default behavior and override behavior
 
!colspan=2 BGCOLOR="#ffffff"|Default behavior and override behavior
 
|-
 
|-
 
|<pre>
||
 
<pre>
 
 
; collapsed
 
; collapsed
 
<div class="NavFrame collapsed">
 
<div class="NavFrame collapsed">
Line 264: Line 285:
 
</pre>
 
</pre>
 
|
 
|
  +
 
; collapsed
 
; collapsed
  +
 
<div class="NavFrame collapsed">
 
<div class="NavFrame collapsed">
 
<div class="NavHead">
 
<div class="NavHead">
Line 273: Line 296:
 
</div>
 
</div>
 
</div>
 
</div>
  +
  +
   
 
; noautocollapse
 
; noautocollapse
  +
 
<div class="NavFrame noautocollapse">
 
<div class="NavFrame noautocollapse">
 
<div class="NavHead">
 
<div class="NavHead">
Line 283: Line 309:
 
</div>
 
</div>
 
</div>
 
</div>
  +
  +
   
 
; default
 
; default
  +
 
<div class="NavFrame">
 
<div class="NavFrame">
 
<div class="NavHead">
 
<div class="NavHead">
Line 290: Line 319:
 
</div>
 
</div>
 
<div class="NavContent">
 
<div class="NavContent">
[... This content(3) may auto-collapse ...]<br/>
+
[... This content(3) may auto-collapse ...]<br />
[... and contains a collapsible table ...]
+
[... and contains a collapsible table ...]
 
{| class="wikitable collapsible"
 
{| class="wikitable collapsible"
 
!colspan="2"| Title
 
!colspan="2"| Title
Line 298: Line 327:
 
|- class="nocollapse"
 
|- class="nocollapse"
 
| abc || def
 
| abc || def
|-
+
|-
 
| 123 || 765
 
| 123 || 765
|-
+
|-
 
| xyz || 123
 
| xyz || 123
 
|- class="nocollapse"
 
|- class="nocollapse"
 
| pqr || 987
 
| pqr || 987
|-
 
 
|}
 
|}
 
</div>
 
</div>
Line 311: Line 339:
 
!colspan=2 BGCOLOR="#ffffff"|Nested ''NavFrame'' blocks
 
!colspan=2 BGCOLOR="#ffffff"|Nested ''NavFrame'' blocks
 
|-
 
|-
 
|<pre>
||
 
<pre>
 
 
<div class="NavFrame">
 
<div class="NavFrame">
 
<div class="NavHead">
 
<div class="NavHead">
Line 377: Line 404:
 
</div>
 
</div>
 
<div class="NavContent">
 
<div class="NavContent">
[... This content is initially hidden and ...]<br/>
+
[... This content is initially hidden and ...]<br />
 
[--- contains the previous example ---]
 
[--- contains the previous example ---]
   
   
 
; collapsed
 
; collapsed
  +
 
<div class="NavFrame collapsed">
 
<div class="NavFrame collapsed">
 
<div class="NavHead">
 
<div class="NavHead">
Line 388: Line 416:
 
<div class="NavContent">
 
<div class="NavContent">
 
[... This content(1) is initially hidden ...]
 
[... This content(1) is initially hidden ...]
</div>
+
</div></div>
  +
</div>
 
   
 
; noautocollapse
 
; noautocollapse
  +
 
<div class="NavFrame noautocollapse">
 
<div class="NavFrame noautocollapse">
 
<div class="NavHead">
 
<div class="NavHead">
Line 398: Line 427:
 
<div class="NavContent">
 
<div class="NavContent">
 
[... This content(2) does not auto-collapse ...]
 
[... This content(2) does not auto-collapse ...]
</div>
+
</div></div>
  +
</div>
 
   
 
; default
 
; default
  +
 
<div class="NavFrame">
 
<div class="NavFrame">
 
<div class="NavHead">
 
<div class="NavHead">
Line 407: Line 437:
 
</div>
 
</div>
 
<div class="NavContent">
 
<div class="NavContent">
[... This content(3) may auto-collapse ...]<br/>
+
[... This content(3) may auto-collapse ...]<br />
[... and contains a collapsible table ...]
+
[... and contains a collapsible table ...]
 
{| class="wikitable collapsible"
 
{| class="wikitable collapsible"
 
!colspan="2"| Title
 
!colspan="2"| Title
Line 415: Line 445:
 
|- class="nocollapse"
 
|- class="nocollapse"
 
| abc || def
 
| abc || def
|-
+
|-
 
| 123 || 765
 
| 123 || 765
|-
+
|-
 
| xyz || 123
 
| xyz || 123
 
|- class="nocollapse"
 
|- class="nocollapse"
 
| pqr || 987
 
| pqr || 987
|-
 
 
|}
 
|}
 
</div></div>[--- previous example inserted above here ---]
 
</div>
 
</div>
 
</div>
 
</div>
[--- previous example inserted above here ---]
 
   
</div>
 
</div>
 
 
|-
 
|-
 
!colspan=2 BGCOLOR="#ffffff"|''NavGlobal'' DIV placed anywhere on page creates [show all] [hide all] buttons
 
!colspan=2 BGCOLOR="#ffffff"|''NavGlobal'' DIV placed anywhere on page creates [show all] [hide all] buttons
 
|-
 
|-
 
|<pre>
||
 
<pre>
 
 
<div class="NavGlobal">
 
<div class="NavGlobal">
 
<!-- place anywhere on page for
 
<!-- place anywhere on page for
Line 441: Line 467:
 
</div>
 
</div>
 
</pre>
 
</pre>
 
|<div class="NavGlobal">
|
 
  +
<div class="NavGlobal">
 
 
<!-- place anywhere on page for
 
<!-- place anywhere on page for
 
[Show all] [Hide all]
 
[Show all] [Hide all]
Line 448: Line 474:
 
-->
 
-->
 
</div>
 
</div>
|-
 
 
|}
 
|}
   
Line 454: Line 479:
 
Normally, if you click on the magnify sprite,&nbsp;http://images.wikia.com/common/releases_200911.1/skins/common/images/magnify-clip.png ,&nbsp;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.
 
Normally, if you click on the magnify sprite,&nbsp;http://images.wikia.com/common/releases_200911.1/skins/common/images/magnify-clip.png ,&nbsp;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.
+
* 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 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.
+
* 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:
 
This is really just a special application of the NavFrame class but with:
 
# ''two'' NavContent div elements instead of just ''one''
 
# ''two'' NavContent div elements instead of just ''one''
# a potentially confusing relationship between the <code>"display:'''none'''"</code> in-line style and the <code>'''collapsed'''</code> in-line class tag
+
# a potentially confusing relationship between the <code>"display:'''none'''"</code> in-line style and the <code>'''collapsed'''</code> in-line class tag
 
# careful placement of {{t|clr}} so as to disable text-wrap based on whichever image is currently visible
 
# careful placement of {{t|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.
+
Note that using the NavPic class does not yield the same result. Indeed, the NavPic class currently serves no useful purpose.
 
<!-- Dantman, I think the magnify sprite located within div.magnify ought to become the "collapseLink" whenever the NavPic class has been used. Currently that so-called magnify sprite is a redundant link to the File: page just as the image area itself links to the File page. What do you think? Is that intuitive? complex? simple? -- najevi -->
 
<!-- Dantman, I think the magnify sprite located within div.magnify ought to become the "collapseLink" whenever the NavPic class has been used. Currently that so-called magnify sprite is a redundant link to the File: page just as the image area itself links to the File page. What do you think? Is that intuitive? complex? simple? -- najevi -->
   
  +
;Caveat
;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.
+
: 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.
   
 
{| class="wikitable"
 
{| class="wikitable"
Line 474: Line 500:
 
|colspan=2| 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.
 
|colspan=2| 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.
 
|-
 
|-
 
|<pre>
||
 
<pre>
 
 
Duis aute ...
 
Duis aute ...
 
<!-- "collapsed" will toggle the coded state
 
<!-- "collapsed" will toggle the coded state
Line 484: Line 509:
 
=> initially VISIBLE small image -->
 
=> initially VISIBLE small image -->
 
<div class="NavContent" style="display:none;" >
 
<div class="NavContent" style="display:none;" >
[[File:Tree.jpg|thumb|120px|Caption here]]</div>
+
[[File:Example.jpg|thumb|120px|Caption here]]</div>
 
<!-- display:block + collapsed
 
<!-- display:block + collapsed
 
=> initially INVISIBLE large image -->
 
=> initially INVISIBLE large image -->
 
<div class="NavContent" style="display:block;">
 
<div class="NavContent" style="display:block;">
[[File:Tree.jpg|thumb|360px|Caption here]]</div>
+
[[File:Example.jpg|thumb|360px|Caption here]]</div>
 
</div>
 
</div>
 
Lorem ipsum ...
 
Lorem ipsum ...
Line 496: Line 521:
 
<!-- "collapsed" will toggle the coded state
 
<!-- "collapsed" will toggle the coded state
 
of the in-line style "display:" -->
 
of the in-line style "display:" -->
  +
<div class="NavFrame collapsed">
 
<div class="NavHead"></div>
+
<div class="NavFrame collapsed">
  +
<div class="NavHead"> </div>
 
<!-- display:none + collapsed
 
<!-- display:none + collapsed
 
=> initially VISIBLE small image -->
 
=> initially VISIBLE small image -->
  +
<div class="NavContent" style="display:none;" >
 
[[File:Tree.jpg|thumb|120px|Caption here]]</div>
+
<div class="NavContent" style="display:none;" >[[File:Example.jpg|thumb|120px|Caption here]]</div>
 
<!-- display:block + collapsed
 
<!-- display:block + collapsed
 
=> initially INVISIBLE large image -->
 
=> initially INVISIBLE large image -->
  +
<div class="NavContent" style="display:block;">
 
[[File:Tree.jpg|thumb|360px|Caption here]]</div>
+
<div class="NavContent" style="display:block;">[[File:Example.jpg|thumb|360px|Caption here]]</div>
 
</div>
 
</div>
  +
 
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
 
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
 
|-
 
|-
 
|colspan=2| Notice that the {{t|clr}} has been placed ''inside'' the div associated with the larger 360px image.
 
|colspan=2| Notice that the {{t|clr}} has been placed ''inside'' the div associated with the larger 360px image.
 
|-
 
|-
 
|<pre>
||
 
<pre>
 
 
Duis aute ...
 
Duis aute ...
 
<div class="NavFrame collapsed">
 
<div class="NavFrame collapsed">
 
<div class="NavHead"></div>
 
<div class="NavHead"></div>
 
<div class="NavContent" style="display:none;" >
 
<div class="NavContent" style="display:none;" >
[[File:Tree.jpg|thumb|120px|Caption here]]</div>
+
[[File:Example.jpg|thumb|120px|Caption here]]</div>
 
<div class="NavContent" style="display:block;">
 
<div class="NavContent" style="display:block;">
[[File:Tree.jpg|thumb|360px|Caption here]]{{clr}}</div>
+
[[File:Example.jpg|thumb|360px|Caption here]]{{clr}}</div>
 
<!--
 
<!--
 
{{clr}} on this line would prevent text-wrap beside thumbnail
 
{{clr}} on this line would prevent text-wrap beside thumbnail
Line 528: Line 554:
 
|
 
|
 
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
 
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  +
<div class="NavFrame collapsed">
 
<div class="NavHead"></div>
+
<div class="NavFrame collapsed">
<div class="NavContent" style="display:none;" >
+
<div class="NavHead"> </div>
[[File:Tree.jpg|thumb|120px|Caption here]]</div>
+
<div class="NavContent" style="display:none;" >[[File:Example.jpg|thumb|120px|Caption here]]</div>
<div class="NavContent" style="display:block;">
+
<div class="NavContent" style="display:block;">[[File:Example.jpg|thumb|360px|Caption here]]
[[File:Tree.jpg|thumb|360px|Caption here]]{{clr}}</div>
+
{{clr}}</div>
 
<!--
 
<!--
 
{{clr}} on this line would prevent text-wrap beside thumbnail
 
{{clr}} on this line would prevent text-wrap beside thumbnail
 
-->
 
-->
 
</div>
 
</div>
  +
 
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
 
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|-
 
 
|}
 
|}
   
Line 551: Line 577:
 
|colspan=2| 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.
 
|colspan=2| 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.
 
|-
 
|-
 
|<pre>
||
 
<pre>
 
 
Duis aute ...
 
Duis aute ...
 
<!-- "collapsed" will toggle the coded state
 
<!-- "collapsed" will toggle the coded state
Line 561: Line 586:
 
=> initially VISIBLE small image -->
 
=> initially VISIBLE small image -->
 
<div class="NavContent" style="display:none;" >
 
<div class="NavContent" style="display:none;" >
[[File:Tree.jpg|right|120px|Caption here]]</div>
+
[[File:Example.jpg|right|120px|Caption here]]</div>
 
<!-- display:block + collapsed
 
<!-- display:block + collapsed
 
=> initially INVISIBLE large image -->
 
=> initially INVISIBLE large image -->
 
<div class="NavContent" style="display:block;">
 
<div class="NavContent" style="display:block;">
[[File:Tree.jpg|right|360px|Caption here]]</div>
+
[[File:Example.jpg|right|360px|Caption here]]</div>
 
</div>
 
</div>
 
Lorem ipsum ...
 
Lorem ipsum ...
Line 573: Line 598:
 
<!-- "collapsed" will toggle the coded state
 
<!-- "collapsed" will toggle the coded state
 
of the in-line style "display:" -->
 
of the in-line style "display:" -->
  +
<div class="NavFrame collapsed">
 
<div class="NavHead" style="float:right;"></div>
+
<div class="NavFrame collapsed">
 
<div class="NavHead" style="float:right;"> </div>
 
<!-- display:none + collapsed
 
<!-- display:none + collapsed
 
=> initially VISIBLE small image -->
 
=> initially VISIBLE small image -->
  +
<div class="NavContent" style="display:none;" >
 
[[File:Tree.jpg|right|120px|Caption here]]</div>
+
<div class="NavContent" style="display:none;" >[[File:Example.jpg|right|120px|Caption here]]</div>
 
<!-- display:block + collapsed
 
<!-- display:block + collapsed
 
=> initially INVISIBLE large image -->
 
=> initially INVISIBLE large image -->
  +
<div class="NavContent" style="display:block;">
 
[[File:Tree.jpg|right|360px|Caption here]]</div>
+
<div class="NavContent" style="display:block;">[[File:Example.jpg|right|360px|Caption here]]</div>
 
</div>
 
</div>
  +
 
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
 
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
 
|-
 
|-
 
|colspan=2| Notice that the {{t|clr}} has been placed ''inside'' the div associated with the larger 360px image.
 
|colspan=2| Notice that the {{t|clr}} has been placed ''inside'' the div associated with the larger 360px image.
 
|-
 
|-
 
|<pre>
||
 
<pre>
 
 
Duis aute ...
 
Duis aute ...
 
<div class="NavFrame collapsed">
 
<div class="NavFrame collapsed">
 
<div class="NavHead" style="float:right;"></div>
 
<div class="NavHead" style="float:right;"></div>
 
<div class="NavContent" style="display:none;" >
 
<div class="NavContent" style="display:none;" >
[[File:Tree.jpg|right|120px|Caption here]]</div>
+
[[File:Example.jpg|right|120px|Caption here]]</div>
 
<div class="NavContent" style="display:block;">
 
<div class="NavContent" style="display:block;">
[[File:Tree.jpg|right|360px|Caption here]]{{clr}}</div>
+
[[File:Example.jpg|right|360px|Caption here]]{{clr}}</div>
 
<!--
 
<!--
 
{{clr}} on this line would prevent text-wrap beside thumbnail
 
{{clr}} on this line would prevent text-wrap beside thumbnail
Line 605: Line 631:
 
|
 
|
 
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
 
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  +
<div class="NavFrame collapsed">
 
<div class="NavHead" style="float:right;"></div>
+
<div class="NavFrame collapsed">
<div class="NavContent" style="display:none;" >
+
<div class="NavHead" style="float:right;"> </div>
[[File:Tree.jpg|right|120px|Caption here]]</div>
+
<div class="NavContent" style="display:none;" >[[File:Example.jpg|right|120px|Caption here]]</div>
<div class="NavContent" style="display:block;">
+
<div class="NavContent" style="display:block;">[[File:Example.jpg|right|360px|Caption here]]
[[File:Tree.jpg|right|360px|Caption here]]{{clr}}</div>
+
{{clr}}</div>
 
<!--
 
<!--
 
{{clr}} on this line would prevent text-wrap beside thumbnail
 
{{clr}} on this line would prevent text-wrap beside thumbnail
 
-->
 
-->
 
</div>
 
</div>
  +
 
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
 
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|-
 
 
|}
 
|}
   
 
== Updates ==
 
== Updates ==
  +
  +
<table cellpadding="0" cellspacing="0" border="0" style="width:100%; margin-bottom:3px; margin-top:3px;"><tr><td style="background:transparent;"><div style="overflow:auto; height:200px; width:100%; -moz-border-radius-topleft:-0.5em; border:0px solid #AAAAAA; padding-left:-0.5em; background:transparent;">
  +
;April 28, 2012
  +
*Korean i18n.
  +
;April 16, 2012
  +
*Portuguese and Brazilian Portuguese i18n.
  +
;April 13, 2012
  +
*Chinese i18n.
  +
;March 2, 2012
  +
*Hungarian i18n.
  +
;October 17, 2011
  +
*Bulgarian i18n.
  +
;October 15, 2011
  +
*Fixed French i18n.
 
;October 9, 2011
 
;October 9, 2011
 
*Italian i18n.
 
*Italian i18n.
Line 653: Line 693:
 
;June 14th, 2009
 
;June 14th, 2009
 
* Refactored to use jQuery and posted here.
 
* Refactored to use jQuery and posted here.
  +
</div></td><td style="width:5px;"> </td></tr></table>
   
 
== See also ==
 
== See also ==
 
*[[Help:Dynamic navigation]]
 
 
*[http://joeyaa08.blogspot.com/2010/02/collapsible-templates.html Joeyaa: Collapsible Templates]. Written by [http://community.wikia.com/wiki/User:Joeyaa User:Joeyaa].
 
*[http://joeyaa08.blogspot.com/2010/02/collapsible-templates.html Joeyaa: Collapsible Templates]. Written by [http://community.wikia.com/wiki/User:Joeyaa User:Joeyaa].
 
*[http://cannabis.wikia.com/wiki/User:Timeshifter/Collapsed_table_via_NavFrame Collapsed table via NavFrame]. Simple explanation and example of how show/hide capability was created with just one line added to a wiki's MediaWiki:Common.js page.
 
*[http://cannabis.wikia.com/wiki/User:Timeshifter/Collapsed_table_via_NavFrame Collapsed table via NavFrame]. Simple explanation and example of how show/hide capability was created with just one line added to a wiki's MediaWiki:Common.js page.
*[[ShowHide2]]
 
 
*[[mediawikiwiki:Manual:Collapsible tables|MediaWiki Manual:Collapsible tables]]
 
*[[mediawikiwiki:Manual:Collapsible tables|MediaWiki Manual:Collapsible tables]]
 
*[[w:c:community:Forum:Need help with ShowHide script|Forum:Need help with ShowHide script]] - implementing Show/Hide with the Oasis/Wikia skin.
 
*[[w:c:community:Forum:Need help with ShowHide script|Forum:Need help with ShowHide script]] - implementing Show/Hide with the Oasis/Wikia skin.
[[Category:JavaScript]]
 

Revision as of 02:14, 3 October 2018

This article is about a system or feature that is no longer in use.

The page is retained for historical reasons.

Reason: Collapsing is a default feature of MediaWiki 1.19

ShowHide is a script for collapsible tables and divs.

Deprecation

As ShowHide has been deprecated for over 5 years, wikis might be interested in migrating from it to the regular collapsing feature. For that purpose, a warning feature has been added to ShowHide that warns users when the wiki is using ShowHide and listing the elements that use deprecated classes in their JavaScript console. There is also a banner notification appearing only for administrators and content moderators across whole Template and MediaWiki namespaces when ShowHide is imported, and elsewhere when deprecated classes are in use on the page. Upon dismissing the banner notification, it won't show up for the next 6 months.

To enable the feature, place this piece of JavaScript in your personal JavaScript page:

window.ShowHideDisplayWarning = true;

This particular setting cannot be enabled site-wide and is only used to help migrating over to the core MediaWiki feature.

Feature overview

Localization
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.
Nesting collapsible content
Nesting collapsible tables is supported.
Nesting NavFrame blocks is supported.
A complementary pair of NavContent blocks enables
In-place magnify/shrink of an image.
Author-specified word-wrap for both image sizes.

Configuration

To use ShowHide please include ShowHide/code.js in your site's MediaWiki:Common.js using:

  • importScriptPage('MediaWiki:ShowHide/code.js', 'dev');

You can change the configuration of ShowHide by creating a ShowHideConfig object inside either:

autoCollapse
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 [].

Example

var ShowHideConfig = { autoCollapse: Infinity };
importScriptPage('MediaWiki:ShowHide/code.js', 'dev');
If you prefer to override the default labels for, say, English language then you can use langCode key, en, to do so. This might be done in your personal User:USERNAME/wikia.js or User:USERNAME/monobook.js.
var ShowHideConfig = { 
	autoCollapse: 3,
	en: {
		show: "more",
		hide: "less",
		showAll: "expand all",
		hideAll: "collapse all"
	}
};
If you would like to change the brackets from [] to say {},you can use:
var ShowHideConfig = { 
    brackets: '{}'
};

Styling

For CSS styling of the show/hide button, the class collapseLink refers to what is inside the brackets, while the class collapseButton refers to the whole button.

Collapsible table

Specify the class collapsible for the table. Optionally specify the class nocollapse for specific rows. viz.

  • Nesting collapsible tables is supported.
    Use class="nocollapse" on the row where the nested table is located to ensure its header row (with the nested show/hide button) remains visible.
Wiki markup Rendered
{| class="collapsible"
!colspan="2"| This is a test
|-
| Column 1 || Column 2
|}
This is a test
Column 1 Column 2
Table with certain rows specified "nocollapse"
{| class="wikitable collapsible"
!colspan="2"| Title
|- class="nocollapse"
| Column 1 || Column 2
|- class="nocollapse"
| abc || def
|- 
| 123 || 765
|- 
| xyz || 123
|- class="nocollapse"
| pqr || 987
|-
|}
Title
Column 1 Column 2
abc def
123 765
xyz 123
pqr 987
Nested tables
{| class="wikitable collapsible"
!colspan="2"| Title
|-
| Column 1 || Column 2
|-
| abc || def
|-
| abc || def
|- class="nocollapse"
|colspan=2|
{| class="toccolours collapsible"
!colspan="2" BGCOLOR="#ffffff"| Embedded table
|- class="nocollapse"
| Column A || Column B
|- class="nocollapse"
||the
|quick
|-
||brown
|fox
|-
|}
|-
| xyz || 123
|-
| pqr || 987
|-
|}
Title
Column 1 Column 2
abc def
abc def
Embedded table
Column A Column B
the quick
brown fox
xyz 123
pqr 987


Collapsible NavFrame block

Use the following class definitions within tag pairs:

NavGlobal
for placing [show all] and [hide all] buttons anywhere on the page
NavFrame
defines a NavFrame block which is the outer wrapper for using the classes NavHead, NavContent and NavPic
NavHead
the header where the show/hide link will be placed
NavContent
block text content that is collapsible (may include a table)
NavPic
image content that is collapsible
  • Nesting NavFrame blocks (tags using the NavFrame class) is supported.
    Check that all tags are closed. If you see progressive indentation then that is a symptom of a tag that was never closed.
Wiki markup Rendered
Default behavior and override behavior
; collapsed
<div class="NavFrame collapsed">
<div class="NavHead">
[... Title of hidden content(1) ...]
</div>
<div class="NavContent">
[... This content(1) is initially hidden ...]
</div>
</div>

; noautocollapse
<div class="NavFrame noautocollapse">
<div class="NavHead">
[... Title of hide-able content(2) ...]
</div>
<div class="NavContent">
[... This content(2) does not auto-collapse ...]
</div>
</div>

; default
<div class="NavFrame">
<div class="NavHead">
[... Title of hidden content(3) ...]
</div>
<div class="NavContent">
[... This content(3) may auto-collapse ...]<br/>
[...  and contains a collapsible table ...]
{| class="wikitable collapsible"
!colspan="2"| Title
|- class="nocollapse"
| Column 1 || Column 2
|- class="nocollapse"
| abc || def
|- 
| 123 || 765
|- 
| xyz || 123
|- class="nocollapse"
| pqr || 987
|-
|}
</div>
</div>
collapsed


noautocollapse


default
Nested NavFrame blocks
<div class="NavFrame">
<div class="NavHead">
[... Title of hidden content(0) ...]
</div>
<div class="NavContent">
[... This content is initially hidden and ...]<br/>
[--- contains the previous example ---]


; collapsed
<div class="NavFrame collapsed">
<div class="NavHead">
[... Title of hidden content(1) ...]
</div>
<div class="NavContent">
[... This content(1) is initially hidden ...]
</div>
</div>

; noautocollapse
<div class="NavFrame noautocollapse">
<div class="NavHead">
[... Title of hide-able content(2) ...]
</div>
<div class="NavContent">
[... This content(2) does not auto-collapse ...]
</div>
</div>

; default
<div class="NavFrame">
<div class="NavHead">
[... Title of hidden content(3) ...]
</div>
<div class="NavContent">
[... This content(3) may auto-collapse ...]<br/>
[...  and contains a collapsible table ...]
{| class="wikitable collapsible"
!colspan="2"| Title
|- class="nocollapse"
| Column 1 || Column 2
|- class="nocollapse"
| abc || def
|- 
| 123 || 765
|- 
| xyz || 123
|- class="nocollapse"
| pqr || 987
|-
|}
</div>
</div>
[--- previous example inserted above here ---]

</div>
</div>
NavGlobal DIV placed anywhere on page creates [show all] [hide all] buttons
<div class="NavGlobal">
<!-- place anywhere on page for 
     [show all]  [hide all]
     buttons                      
-->
</div>

Magnify and shrink pictures without leaving the article

Normally, if you click on the magnify sprite, magnify-clip.png , 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:

  1. two NavContent div elements instead of just one
  2. a potentially confusing relationship between the "display:none" in-line style and the collapsed in-line class tag
  3. 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.
Duis aute ...
<!-- "collapsed" will toggle the coded state
     of the in-line style "display:"         -->
<div class="NavFrame collapsed"> 
<div class="NavHead"></div>
<!-- display:none + collapsed 
     => initially VISIBLE small image        -->
<div class="NavContent" style="display:none;" > 
[[File:Example.jpg|thumb|120px|Caption here]]</div>
<!-- display:block + collapsed 
     => initially INVISIBLE large image      -->
<div class="NavContent" style="display:block;"> 
[[File:Example.jpg|thumb|360px|Caption here]]</div>
</div>
Lorem ipsum ...

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Notice that the {{clr}} has been placed inside the div associated with the larger 360px image.
Duis aute ...
<div class="NavFrame collapsed"> 
<div class="NavHead"></div>
<div class="NavContent" style="display:none;" > 
[[File:Example.jpg|thumb|120px|Caption here]]</div>
<div class="NavContent" style="display:block;"> 
[[File:Example.jpg|thumb|360px|Caption here]]{{clr}}</div>
<!-- 
{{clr}} on this line would prevent text-wrap beside thumbnail
-->
</div>
Lorem ipsum ...

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


Repeating the same two example but using Right instead of Thumb for the image and also floating the Show/Hide button right rather than the default.
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.
Duis aute ...
<!-- "collapsed" will toggle the coded state
     of the in-line style "display:"         -->
<div class="NavFrame collapsed"> 
<div class="NavHead" style="float:right;"></div>
<!-- display:none + collapsed 
     => initially VISIBLE small image        -->
<div class="NavContent" style="display:none;" > 
[[File:Example.jpg|right|120px|Caption here]]</div>
<!-- display:block + collapsed 
     => initially INVISIBLE large image      -->
<div class="NavContent" style="display:block;"> 
[[File:Example.jpg|right|360px|Caption here]]</div>
</div>
Lorem ipsum ...

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Notice that the {{clr}} has been placed inside the div associated with the larger 360px image.
Duis aute ...
<div class="NavFrame collapsed"> 
<div class="NavHead" style="float:right;"></div>
<div class="NavContent" style="display:none;" > 
[[File:Example.jpg|right|120px|Caption here]]</div>
<div class="NavContent" style="display:block;"> 
[[File:Example.jpg|right|360px|Caption here]]{{clr}}</div>
<!-- 
{{clr}} on this line would prevent text-wrap beside thumbnail
-->
</div>
Lorem ipsum ...

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Updates

April 28, 2012
  • Korean i18n.
April 16, 2012
  • Portuguese and Brazilian Portuguese i18n.
April 13, 2012
  • Chinese i18n.
March 2, 2012
  • Hungarian i18n.
October 17, 2011
  • Bulgarian i18n.
October 15, 2011
  • Fixed French i18n.
October 9, 2011
  • Italian i18n.
June 10, 2011
  • Japanese i18n.
May 31, 2011
  • Code cleanup, styling and a bug fix for NavFrame collapsing.
February 22, 2011
  • Russian i18n.
January 18, 2011
  • Polish i18n.
June 26, 2010
  • Dutch, German, and French i18n.
December 19, 2009
  • Apply the missing $button node.
  • Support linkBefore config option to switch location of show/hide button.
  • Quote keywords used in keys to avoid breaking older browsers.
July 2, 2009
  • Bugfix for collapsible tables default collapse and nesting of them
July 1, 2009
  • Minor bugfix for show/hide all labels.
June 30, 2009
  • Centralized i18n started and smart choosing of what language to use.
  • Modified and fixed ability to configure ShowHide.
June 29, 2009
  • Fix a minor collapsible tables bug so we fully support nesting of collapsible tables in our version
June 28, 2009
  • Support nocollapse on table rows
June 19th, 2009
  • Support noautocollapse class to stop NavFrame from auto-collapsing certain things.
  • Suggestion from es.pokemon, switched the a to a span using tabIndex, and added code to allow enter to trigger the show/hide.
  • Also support the spacebar.
June 14th, 2009
  • Refactored to use jQuery and posted here.
 

See also