User:Dispenser/Navbox

 [ Discuss this script ]

On Wikipedia many of the navboxes are using either class="toccolours" or id="toc". These are not very specific classes to be using and in the case of the latter is illegal in the HTML spec. Using the more specific  class will allow site admins to better control the appear navboxes as well as allowing user styles for navboxes.

Here's this script comes in, it allows me to edit many more navboxes a day than I could otherwise. The script modify the wikitext so that it retains as much of the original appear. It is likely the most complicated single AWB script with over 100 rules. The following is a summary of its basic functions:


 * Converts HTML attributes to CSS
 * Adds navbar-header or navbar-collapsible and removes old edit links
 * Fixes many common coding mistakes and error from copying and pasting malformed code
 * Adds Uncategorized template where needed

There are some limitations to what the script can do. So some of the things still need to be corrected by hand. Moreover  and   class are not identical to each other. This is further complicated with the collapsible table class which messes up when there's no automatic width specified.

Differences in toccolours and navbox classes
.toccolours {                    table.navbox { background-color: #f9f9f9;       background-color: #f9f9f9; border: 1px solid #aaa;          border: 1px solid #aaa; >   clear: both; font-size: 95%;             |    font-size: 90%; >   margin: 1em 0em 0em; padding: 5px;               |    padding: 2px; >   text-align: center; >   width: 100%; }                                }                               >  @media print { >     .navbox { >         display: none; >     }                               >  }

Fixes to common complaints

 * Font size is too small/large: Add font-size:95%; to set it to the size as previously with class="toccolous". If the page was sprinkled with font-size:90%; a better choice for a base font-size might be font-size:85%; (0.90×0.90)
 * How do I control the collapsing?


 * The collapsing is controlled through the class tag, collapsible will add the ability for the table to collapsible. collapsed and autocollapse will dictate when the table collapse, always and when 2 or more tables are the same page, respectively.


 * If desired the collapsing can be controlled from the article itself. Replace autocollapse</tt> with <tt> </tt>, then when using that template inside an article you can set its state like so:.


 * The collapsing doesn't work, it becomes scrunched up!


 * This is because there isn't any fixed wide set, thus collapsed it attempts to have a minimum width. Use a fixed value in <tt>em</tt>s or percent.


 * How do I set the width?


 * Add to the style attribute the margin and width properties, like such: . Removing one of those values cause that value to the mirror of the other side. Use <tt>auto</tt> for the side to allow the table to center across the page. Avoid using PIXEL unit as they DO NOT SCALE.

<tt>50em</tt> is recommend as a pseudo-standard for fixed width as it fit on well on a 800x600 display and typically provides enough space with the default font-size.

Meta-template
Some Wikipedian prefer to use meta templates
 * Generic navbox templates:
 * Project specific:
 * navbar headings
 * navbar headings
 * navbar headings
 * navbar headings
 * navbar headings

Participants
If you have AWB access you can run the script yourself. Get AWB Navbox.xml.
 * Dispenser