Using YADM

Changing the look and feel

YADM enhances a nested list (UL) in the markup, and applies different classes to the elements when they become "interactive".

The markup has to be something like this:

<ul id="nav">
 <li><a href="index.html">Home/News</a></li>
 <li><a href="examples.html">Examples</a>
  <ul>
   <li><a href="dropdown.html">Absolute Dropdown</a></li>
   <li><a href="reldropdown.html">Relative Dropdown</a></li>
   <li><a href="flyout.html">Flyout menu</a></li>
   <li><a href="expanding.html">Expanding Menu</a></li>
   <li><a href="others.html">Submitted examples</a></li>
  </ul>
 </li>
 <li><a href="report.php">Contribute</a></li>
 <li><a href="using.html">Using YADM</a>
  <ul>
   <li><a href="using.html#css">Changing look and feel</a></li>
   <li><a href="using.html#js">How it works</a></li>
   <li><a href="using.html#other">Working with other scripts</a></li>
   <li><a href="using.html#not">What it does not do</a></li>
  </ul>
 </li>
</ul>

All YADM needs is the nav ID on the first UL. You can change this ID to something else in the script, if necessary. If you don't want YADM to apply hover states to the list (for example when creating an expanding and collapsing menu), add a class called nohover to the nav UL:

<ul id="nav" class="nohover">
[...]
</ul>

If you don't want one of the nested lists to be collapsed, add a class called current to either the LI containing the list, or any of its elements.

<ul id="nav">
 <li><a href="index.html">Home/News</a></li>
 <li><a href="examples.html">Examples</a>
  <ul>
   <li><a href="dropdown.html">Absolute Dropdown</a></li>
   <li class="current"><a href="reldropdown.html">Relative Dropdown</a></li>
   <li><a href="flyout.html">Flyout menu</a></li>
   <li><a href="expanding.html">Expanding Menu</a></li>
   <li><a href="others.html">Submitted examples</a></li>
  </ul>
 </li>
 <li><a href="report.php">Contribute</a></li>
[...]
</ul>

To achieve the functionality of showing and hiding the nested lists, YADM applies different classes to the elements. This means you can control the look and the way the elements are hidden completely in CSS:

Applied classes
Class name element desired effect
dhtml main UL indicates when Javascript/DOM is available, you can use this class to differentiate the presentation of the UL. For example UL#nav{width:auto;} and UL#nav.dhtml{width:10em;}
isParent any LI containing a nested list indicates that this LI contains a menu and is not just a link. In the above example this class adds the downward arrows.
isActive LI containing the currently visible nested list indicates the current open menu item, in this case here it changes the background of the LI to a light yellow.
hiddenChild all nested lists (UL element) hides the element, apply any CSS technique you want (off-left, or display:none or or or).
shownChild currently active nested list (UL element) shows the currently active nested list.

Check the examples page to see how you can use these classes.

You can change the name of these classes in the variable section of the script.

How it works

YADM uses DOM to enhance a nested list by adding and removing different CSS classes to and from it. I will not get into details of the Javascript here, as the script itself has loads of comments in it. What it does is the following:

Working with other scripts

If YADM were a pupil, its yearbook would sport a smiley face stating "plays well with others". There are no global variables or functions outside the main function yadm and you can easily add your own functions to the onload construct at the bottom of the script.

What it does not do

YADM was developed to help you create navigations that make sense, not to create whizz-bang navigations that are there for the sake of being flashy. The backbone of every web site is a good information architecture. If you need to reproduce the sitemap on every page then something is wrong. Therefore YADM does not support:

You can easily turn the navigation into a graphical one by using background images or even image replacement techniques, though.