Skip to content

Instantly share code, notes, and snippets.

@gabrielstuff
Created October 18, 2011 09:46
Show Gist options
  • Save gabrielstuff/1295061 to your computer and use it in GitHub Desktop.
Save gabrielstuff/1295061 to your computer and use it in GitHub Desktop.
Accordeon
(function (c) {
var b = {
openClass: "enoise-accordion-open",
heightClosed: 100
};
var a = function (d, e) {
return function (g) {
var f = d.openClass;
g = g || e.first();
e.each(function (index, el) {
var h = c(this);
if (h.hasClass(f)) {
h.animate({
height: d.heightClosed + "px"
}, 300).removeClass(f)
}
});
var totalHeight = 0;
g.children().each(function(){
totalHeight = totalHeight + $(this).outerHeight();
});
g.animate({
height: totalHeight + "px"
}, 300).addClass(f, "slow");
}
};
c.fn.enoiseAccordion = function (f) {
var d = c.extend(b, f),
g = c(this).children(),
e = a(d, g);
g.click(function (i) {
if(this.tagName.toLowerCase!="span"){
var h = c(this);
if (h.hasClass(d.openClass)) {
return
}
e(h)
}
});
e()
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment