المعرفة:NavFrame

Documentation for dynamic navigation boxes.

Dynamic navigation boxes use a combination of CSS and Javascript to make collapsible navigation boxes. The technical parts comprise style sheet declarations in MediaWiki:Common.css, and Javascript code in MediaWiki:Common.js.

Example (click "show" or "hide" to see the good bits):

مستخدم:Mzajac/Soviet-legacy AFV Navbox

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

How to use

NavFrame divs

With div, you can hide almost anything. There are three main classes: NavFrame, NavHead, NavContent. The initial state is for the content shown with a link to "hide", except when the NavContent has style="display:none;".

Simple example

You will need to create three div elements:

<div class="NavFrame">
  <div class="NavHead">[... This is the title of your collapsible content ...]</div>
  <div class="NavContent">
    [... The content you want to hide goes here ...]
  </div>
</div>


To initially hide the content do this:

<div class="NavFrame">
  <div class="NavHead">[... This is the title of the hidden content ...]</div>
  <div class="NavContent" style="display:none;">
    [... This content is initially hidden ...]
  </div>
</div>


Mixed classes example

You can even apply other classes along with these, making a more styled design rather than if you were to use the standard classes:

<div class="messagebox standard-talk NavFrame">
  <div class="somerandomclass NavHead">
    [... This is the title; it does not have to be plain text, you can get creative here ...]</div>
  <div class="NavContent anotherclass">
    [... The content you want to hide goes here ...]
  </div>
</div>

Collapsible tables

The initial state of any collapsible content can be controlled using a "collapsible table", because it also allows a table with only one element with content, and a header.

Simple example

Tables are simpler to work with, as you merely need to add the collapsible to the table itself. For the [hide]/[show] link to appear, the table's first row must be a header row, i.e. begin (in wikisyntax) with an exclamation mark. The use of the class toccolours in the example below is merely for appearance; it is not needed for collapsible to function:

{| class="toccolours collapsible" width="60%"
!colspan="2"| Fun with table columns
|-
| Column 1 || Column 2
|}
Fun with table columns
Column 1 Column 2

One-element example, initially expanded:

Always displayed header
Optionally displayed text Optionally displayed text Optionally displayed text Optionally displayed text Optionally displayed text Optionally displayed text

Auto-collapsing tables

You have two choices of auto-collapse. In addition to the collapsible class, you can add either collapsed or autocollapse. The first always initially collapses a table. autocollapse only initially collapses a table if there are at least two collapsible tables on a page.

{| class="toccolours collapsible autocollapse" width=60%
|-
! colspan="2" | This autocollapse table will initially collapse because there are at least two collapsible tables on this page.
|-
| Column 1 || Column 2
|}
This autocollapse table will initially collapse because there are at least two collapsible tables on this page.
Column 1 Column 2
{| class="toccolours collapsible collapsed" width=60%
|-
! colspan="2" | This table will always initially collapse
|-
| Column 1 || Column 2
|}

One-element example, initially collapsed:

Sortable collapsible tables

initially expanded initially collapsed
numbers
name number
a 123
b 6
c 45

Limitations

Currently, the three Nav* classes apply styles of their own. When mixing classes, this causes some of the Nav styles to override other styles (in the above example, NavFrame is overriding the styles from .messagebox.standard-talk).

This limitation does not affect collapsible tables.

Accessibility

All browsers from Internet Explorer 5.5 and on (IE5.5/6/7, Firefox, Safari / KHTML, Opera 8/9, etc.) that support JavaScript will properly collapse the elements.

Internet Explorer 5 and browsers which do not support JavaScript will render the elements without the [hide/show] links and will not collapse them.

Templates

Navigation template comparison
ع  ن  ت
collapsible Header color Image Groups Style
parameter
Example
{{Navigation}} NavFrame NavHead لا لا لا {{OPEC}}
{{Navigation with image}} NavFrame NavHead Left/right of body لا لا {{HolmesNovels}}
{{Navigation with columns}} NavFrame NavHead لا لا لا
{{Dynamic navigation box}} collapsible navbox لا لا نعم {{CSUHeads}}
{{Dynamic navigation box with image}} NavFrame NavHead Upper left لا لا {{SlovakPMs}}
{{Navbox generic}} collapsible navbox لا نعم نعم {{Dilbert}}
{{Navbox generic with image}} collapsible navbox Right-hand side نعم نعم {{Jewish life}}
{{NavigationBox}} لا navbox Right of title+body لا لا {{EPA}}
{{Commons:NavigationBox}} لا #ccccff Right of title+body لا لا
{{Commons:Dynamic navigation box}} NavFrame #ccccff لا لا لا
{{Commons:Dynamic navigation box with image}}  NavFrame NavHead Upper left لا لا
The background color for the header or title is inherited from the class listed below. The templates have color parameters that override the default.
Collapsible attributes
Type CSS classes Collapses when Custom
initial state
Nesting Header
color
Font size
NavFrame div NavFrame, NavHead, NavContent 3+ of the same لا نعم #efefef 90%
Collapsible table collapsible, navbox 2+ of the same نعم لا #ccccff 90%

For the technically minded, انظر Common.css and Common.js.


. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

انظر أيضاً