Here's the demonstration:
wow.nerfed.usIn order to hide document elements easily you have to be able to reference them by ID. That way you can code an element onclick event to call some function which performs the hide/unhide of another element as long as you define in the onclick what the ID of the element to hide/show is.
Fortunately even though the menu file is actually a generic code block which gets populated during interpretation we can use the <!-- Menu:Title --> command to give each of our menu elements a unique ID.
To make this work you'll need two menu header background graphics, one for the hidden state of the menu below the header and one for the shown state of the content below the header. If you want to just have a static image then just set the URLs for both graphics to the same file, or hack up the code.
Then, decide which menu elements you want shown or hidden and edit the entries under the hideSetup function which gets called in the body onload. The syntax is show_hide('
menu name','Hdr_
menu name'). The menu name is just the display name that normally shows in the rendered menu header when you look at your page (note that this automatically precludes pre-closing the
Logged In: Soandso and the
x Members Currently Online menus).
Code for layout file:The code to insert right after <title> within <head>:
<script language="Javascript" type="text/javascript">
<!--
function show_hide(tblid, timg, show) {
if (tbl = document.getElementById(tblid)) {
if (null == show) show = tbl.style.display == 'none';
tbl.style.display = (show ? '' : 'none');
document.getElementById(timg).style.background = (show ? 'url( full URL to header graphic background when section is shown )' : 'url( full URL to header graphic background when not shown )' );
}
}
function hideSetup(){
show_hide('Last Items','Hdr_Last Items');
show_hide('Ventrilo Status','Hdr_Ventrilo Status');
show_hide('DKP','Hdr_DKP');
show_hide('Resources','Hdr_Resources');
show_hide('Links','Hdr_Links');
}
//!-->
</script>
The code for <body> which calls the setup function (closes those sections you want closed from the start):
<body onload="hideSetup()">
Code for menu file:This is a complete replacement of the default menu file. If you have further customized then look at the first <td> (line 3) and the first nested <table> (line 8):<table border="0" class="Menu" cellpadding="1" cellspacing="0" width="175">
<tr>
<td class="MenuCat" id="Hdr_<!-- Menu:Title -->" height="27" width="175" align="center" valign="middle" onclick="show_hide('<!-- Menu:Title -->','Hdr_<!-- Menu:Title -->')" title="Click to expand/contract this menu."><!-- Menu:Title --></td>
</tr>
<tr>
<td>
<table border="0" width="175" cellpadding="0" cellspacing="0" id="<!-- Menu:Title -->">
<!-- Menu:StartItemList -->
<tr>
<td class="MenuChoice" align="left">
<!-- Menu:StartItem -->
<li><a href="<!-- Menu:Link -->" <!--Menu opup -->><!-- Menu:LinkName --></a></li>
<!-- Menu:EndItem -->
</tr>
<!-- Menu:EndItemList -->
<!-- Menu:StartStandAlone -->
<tr>
<td class=MenuChoice align=left>
<!-- Menu:StandAloneContent -->
</td>
</tr>
<!-- Menu:EndStandAlone -->
</table>
</td>
</tr>
</table> Code for css:Make sure you have defined the following item in your css:
.MenuCat{ background-image: url(full URL to header graphic background when section is shown); }