DropDown Menu
You can easily add a beault
(and CSS formatable) drop-down menu to a web with
accessibility navigation based on a simple TWiki list.
Your menu HTML code will stay being a list of links
(the best semantics for that). Good for google and other search bots, and good for text browsers. Some people need to navigate with the tab, because they are blind or has degenerative disease... this code enable to open sub-menus with tab focus.
Example
You only need a list. Better if it is a TWiki list. All list items must be links, except the parents of the sub-menus like this:
<div id="some-id">
* [[Link 1]]
* Link 2
* [[Link 2.1]]
* [[Link 2.2]]
* [[Link 2.3]]
* Link 3
* [[Link 3.1]]
* Link 3.2
* [[Link 3.2.1]]
* [[Link 3.2.2]]
* [[Link 3.3]]
</div>
This TWiki code makes the menu above as a big example
(not really useful):
<div id="menuTeste">
* [[Web Home]]
* TWiki Services
* WebNotify
* WebIndex
* WebSearch
* TWiki Groups
%SEARCH{ "TWiki"
web="Main"
topic="*Group"
nonoise="on"
limit="6"
format=" * $web.$topic" }%
* [[TWiki.TWikiRegistration][Registration]]
* Admin Docs
%SEARCH{ "AdminDocumentationCategory"
excludetopic="AdminDocumentationCategory"
web="TWiki"
nonoise="on"
limit="6"
format=" * $web.$topic"}%
* [[Main.TWikiUsers][Users]]
</div>
You can see the real world using this hire:
This websites are TWiki based and the site menu uses this DropDown Menu.
Features
- Multiple sub-menus suport
- Open sub-menus with mouse over or with tab focus
- Close sub-menus with mouse out or with tab blur
- Formatable as easy you want with CSS
- The generated HTML code is a common TWiki list with links, best semantics for search bots and text based browsers
Not happy? Some cull feature missing? Please,
make a proposal!
How to add the drop-down codebase?
To have a DropDown menu on your web add this two red lines:
- On your CSS:
<style>
(...)
%INCLUDE{"TWiki21Nov.DropDownMenu" section="css" MENU_ID="your-menu-id"}%
(and you can add more css for the menu hire, to make it personal)
(...)
</style>
- Below your menu list:
%INCLUDE{"TWiki21Nov.DropDownMenu" section="js" MENU_ID="your-menu-id"}%
If you already use
prototype.js
on your TWikiWeb template, you can set
DO_NOT_LOAD_PROTOTYPE="on"
in the
%INCLUDE%
to it do not load the script again.
%INCLUDE{"TWiki21Nov.DropDownMenu" section="js" DO_NOT_LOAD_PROTOTYPE="on" MENU_ID="your-menu-id"}%
If you want to load the prototype in the
<head>
block
(and that is better) put this line on your template:
<script type="text/javascript" src="%PUBURL%/TWiki21Nov/DropDownMenu/prototype.js"></script>
and use the
DO_NOT_LOAD_PROTOTYPE="on"
in the
%INCLUDE%
.
How can i change the menu appearance?
Think in CSS ever.
All new repeated sets, resets the old set. So... Replace everything that you want by CSS after the
%INCLUDE%
section css.
Example:
<style> /* <pre> disable TWiki parser */
body {
color: #777;
font-family: sans-serif;
}
%INCLUDE{"this topic" section="css" MENU_ID="menu"}%
#menu ul ul a{
padding: 3px 2px 3px 15px;
background-color: #DCDCDC;
}
#menu ul ul a.linkSubMenu {
color: red;
}
#menu ul ul a.linkSubMenu:hover {
color: green;
}
</style>
linkSubMenu
is the class added to the link created to open the sub-menus.
Work around IE CSS bugs:
If your personalization is getting some problem with IE, don't cry.
The script add a msie class on the div parent of the menu list.
So, you cam make that:
#menu {
/* a code for all */
}
#menu.msie {
/* a code replace for IE */
}
And your CSS will not break the standards as the common CSS hacks.
Copying
This AddOn is a licenced in the
GPL version 2
or (at your option) a later version.
When copy this to your TWiki, don't forget to copy the
prototype.js
attached in this topic or a newer version from
http://www.prototypejs.org
--
Contributors: AurelioAHeckert - 29 Aug 2007
Source URL:
TWiki:Plugins.DropDownMenuAddOn
--
PeterJones - 18 Apr 2008