Skip to content

Instantly share code, notes, and snippets.

@pnomolos
Created April 17, 2009 20:19
Show Gist options
  • Save pnomolos/97236 to your computer and use it in GitHub Desktop.
Save pnomolos/97236 to your computer and use it in GitHub Desktop.
window.addEvent('domready',function(){
if ($('section-menu')) {
$('section-menu').getElements('a.menuitem').each(function(n){
n.addEvent('click',function(ev){
new Event(ev).preventDefault();
})
})
var accordion = new Accordion('a.menuitem', 'ul.submenu', {
opacity: false,
onActive: function(toggler, element){
toggler.addClass('current');
element.addClass('current');
},
onBackground: function(toggler, element){
toggler.removeClass('current');
element.removeClass('current');
}
}, $('section-menu'));
$$('#section-menu a').each(function(n){
if (n.href.match(window.location)) {
accordion.display($$('#section-menu > ul > li').indexOf(n.getParents('li')[1]) + 1);
}
});
}
});
<div class="block" id="section-menu">
<ul class="section menu">
<li>
<a class="menuitem">Menu 1</a>
<ul class="submenu">
<li>
<a>Submenu 1</a>
</li>
<li>
<a>Submenu 2</a>
</li>
<li>
<a class="active">Submenu 3</a>
</li>
<li>
<a>Submenu 4</a>
</li>
<li>
<a>Submenu 5</a>
</li>
</ul>
</li>
<li>
<a class="menuitem">Menu 2</a>
<ul class="submenu">
<li>
<a>Submenu 1</a>
</li>
<li>
<a>Submenu 2</a>
</li>
<li>
<a>Submenu 3</a>
</li>
<li>
<a>Submenu 4</a>
</li>
<li>
<a>Submenu 5</a>
</li>
</ul>
</li>
<li>
<a class="menuitem">Menu 3</a>
<ul class="submenu">
<li>
<a>Submenu 1</a>
</li>
<li>
<a>Submenu 2</a>
</li>
<li>
<a>Submenu 3</a>
</li>
<li>
<a>Submenu 4</a>
</li>
<li>
<a>Submenu 5</a>
</li>
</ul>
</li>
<li>
<a class="menuitem">Menu 4</a>
<ul class="submenu">
<li>
<a>Submenu 1</a>
</li>
<li>
<a>Submenu 2</a>
</li>
<li>
<a>Submenu 3</a>
</li>
<li>
<a>Submenu 4</a>
</li>
<li>
<a>Submenu 5</a>
</li>
</ul>
</li>
</ul>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment