Menu avec JQuery
Works with mouse over
Affichage du menu
<?php $subPageId = explode('/', $_SERVER['REQUEST_URI']); $level2=$subPageId[1]; $level3=$subPageId[2]; $level4=$subPageId[3]; ?>
<div class="menu_list" id="secondpane"> <!--Code for menu starts here-->
<p class="menu_head"><a href="<?php echo URL_PUBLIC; ?>">Home</p>
<?php foreach($this->find('/')->children() as $menu): ?>
<p class="menu_head"><?php echo $menu->link(); ?></p>
<div class="menu_body">
<?php if($menu->childrenCount() > 0) : ?>
<?php foreach ($menu->children() as $subMenu) : ?>
<?php echo $subMenu->link(); ?>
<?php endforeach; ?>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
Code CSS et JS
Entre <HEAD> et </HEAD>
<script type="text/javascript" language="javascript" src="<?php echo URL_PUBLIC; ?>public/menuv/jquery.js"></script>
<script type="text/javascript">
<!--//---------------------------------+
// Developed by Roshan Bhattarai
// Visit http://roshanbh.com.np for this script and more.
// This notice MUST stay intact for legal use
// --------------------------------->
$(document).ready(function()
{
//slides the element with class "menu_body" when mouse is over the paragraph
$("#secondpane p.menu_head").mouseover(function()
{
$(this).css({}).next("div.menu_body").slideDown(500).siblings("div.menu_body").slideUp("slow");
$(this).siblings().css({});
});
});
</script>
<style type="text/css">
.menu_list {
width: 150px;
}
.menu_head {
padding: 5px 10px;
cursor: pointer;
position: relative;
margin:1px;
font-weight:bold;
background: #eef4d3;
}
.menu_body {
display:none;
}
.menu_body a{
display:block;
color:#006699;
background-color:#EFEFEF;
padding-left:10px;
font-weight:bold;
text-decoration:none;
}
.menu_body a:hover{
color: #000000;
text-decoration:underline;
}
</style>
Téléchargement
Le fichier Jquery.js utilisé dans cet exemple.
Note
Il semble qu'il y ait un bug avec le thème graphique que j'utilise...
Crédits
Script original : http://roshanbh.com.np par Roshan Bhattarai
