<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
ul {
margin: 0;
padding: 0;
}
</style>
<script type="text/javascript" src="jquery-1.4.1.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
var toolbox = $("#toolBox");
var toolBoxTrigger = $("#toolBox .toolBoxTrigger");
var toolBoxAccordion = $("#toolBoxAccordion");
toolBoxAccordion.hide();
setToolBoxEvents(toolbox,toolBoxTrigger,toolBoxAccordion);
});
function setToolBoxEvents(toolbox,toolBoxTrigger,toolBoxAccordion) {
toolBoxTrigger.click(function() {
$(this).unbind("click").unbind("focus");
if (toolBoxAccordion.not(":visible")) {
openToolBox(toolbox,toolBoxTrigger,toolBoxAccordion);
}
return false;
});
toolBoxTrigger.focus(function() {
$(this).unbind("click").unbind("focus");
if (toolBoxAccordion.not(":visible")) {
openToolBox(toolbox,toolBoxTrigger,toolBoxAccordion);
}
return false;
});
}
function openToolBox(toolbox,toolBoxTrigger,toolBoxAccordion) {
toolBoxAccordion.slideDown("fast");
jQuery(document).click(function(e) {
closeToolBox(toolbox,toolBoxTrigger,toolBoxAccordion);
e.stopPropagation();
});
}
function closeToolBox(toolbox,toolBoxTrigger,toolBoxAccordion) {
toolBoxAccordion.slideUp("fast");
setToolBoxEvents(toolbox,toolBoxTrigger,toolBoxAccordion);
jQuery(document).unbind("click");
return false;
}
</script>
</head>
<body>
<div id="toolBox" class="toolBox">
<a href="#" class="toolBoxTrigger"><span>Tools</span></a>
<ul id="toolBoxAccordion" class="toolBoxAccordion">
<li>
<a href="">Test</a>
<a href="">Test</a>
<a href="">Test</a>
<a href="">Test</a>
<a href="">Test</a>
</li>
</ul>
</div>
</body>
</html>
|