Created
April 25, 2011 16:36
-
-
Save JKirchartz/940770 to your computer and use it in GitHub Desktop.
XUIjs Accordion
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>XUIaccordion Demo</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<!--[if !IE]>--> | |
<!-- no blackberry support if you use IE conditionals to detect browser, but this is a demo so relax --> | |
<script type="text/javascript" src="http://xuijs.com/downloads/xui-2.0.0.min.js"></script> | |
<!-- sorry for hotlinking, XUI dudes, but this is a demo so deal with it. --> | |
<!--<![endif]--> | |
<!--[if IE]> | |
<script type="text/javascript" src="http://xuijs.com/downloads/xui-ie-2.0.0.min.js"></script> | |
<![endif]--> | |
<style> | |
</style> | |
</head> | |
<body> | |
<ul id="nav"> | |
<li> | |
<a href="#" class="navItem">Menu Item 1<span>▼</span></a> | |
<div class="item"> | |
Lorem Ipsum Dolar Sit Amet | |
</div> | |
</li> | |
<li> | |
<a href="#" class="navItem">Menu Item 2<span>▼</span></a> | |
<div class="item"> | |
Lorem Ipsum Dolar Sit Amet | |
</div> | |
</li> | |
<li> | |
<a href="#" class="navItem">Menu Item 3<span>▼</span></a> | |
<div class="item"> | |
Lorem Ipsum Dolar Sit Amet | |
</div> | |
</li> | |
<li> | |
<a href="#" class="navItem">Menu Item 4<span>▼</span></a> | |
<div class="item"> | |
Lorem Ipsum Dolar Sit Amet | |
</div> | |
</li> | |
<li> | |
<a href="#" class="navItem">Menu Item 5<span>▼</span></a> | |
<div class="item"> | |
Lorem Ipsum Dolar Sit Amet | |
</div> | |
</li> | |
</ul> | |
<script type="text/javascript" src="xuiAccordion.js"></script> | |
</body> | |
</html> |
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
x$.extend({ | |
'hide':function(){ | |
this.addClass('hide'); | |
this.removeClass('show'); | |
return x$(this); | |
}, | |
'show':function(){ | |
this.addClass('show'); | |
this.removeClass('hide'); | |
return x$(this); | |
}, | |
'next': function() { | |
var n = this[0]; | |
do{n = n.nextSibling;} | |
while (n && n.nodeType != 1); | |
return x$(n); | |
}, | |
'is': function(sr) { | |
sr = sr.toUpperCase(); | |
var n = this[0]; | |
if(sr == n.nodeName){ | |
return x$(n); | |
} | |
return false; | |
} | |
}); | |
window.onload = function(){ | |
x$('#nav div.item').hide(); | |
x$('#nav a.navItem').click(function(e) { | |
var next = x$(this).next(); | |
if(next.hasClass("hide")){ | |
x$('#nav div.item').hide(); | |
next.show(); | |
}else{ | |
next.hide(); | |
} | |
e.stopPropagation(); | |
e.preventDefault(); | |
return false; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a simple accordion created with XUIjs