Created
May 7, 2010 12:35
-
-
Save eerne/393364 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEvent('domready', function(){ | |
/* # Turns ul/li list into an Accordion, using MooTools 1.2.4.4 | |
<ul> | |
<li><a href="#">Link A</a></li> | |
<li><a href="#">Link B</a></li> | |
<li class="active"> | |
<a href="#">Link C</a> | |
<ul> | |
<li><a href="#">Sub A</a></li> | |
<li><a href="#">Sub B</a></li> | |
<li class="active"><a href="#">Sub C</a></li> | |
</ul> | |
</li> | |
<li> | |
<a href="#">Link D</a> | |
<ul> | |
<li><a href="#">Sub A</a></li> | |
<li><a href="#">Sub B</a></li> | |
</ul> | |
</li> | |
</ul> | |
*/ | |
var nav = document.id('nav').getElement('ul'), | |
subnav = nav.getElements('ul'), | |
subnavParents = subnav.getParent('li'), | |
tabs = subnavParents.getChildren('a'), | |
active = -1; | |
subnavParents.each(function(el, i){ | |
el.getElement('a').addEvent('click', function(e){ | |
e.preventDefault(); | |
}); | |
if (el.getElement('li.active')) active = i; | |
}); | |
new Fx.Accordion(nav, tabs, subnav, { | |
display: active, | |
initialDisplayFx: false | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment