Skip to content

Instantly share code, notes, and snippets.

@jiggliemon
Created November 15, 2010 03:17
Show Gist options
  • Save jiggliemon/676379 to your computer and use it in GitHub Desktop.
Save jiggliemon/676379 to your computer and use it in GitHub Desktop.
Simple Accordion Plugin
var Accordion = this.Accordion = function(element, options) {
this.element = jQuery(element);
this.options = jQuery.extend({}, this.defaults, options);
this.baffles = [];
this.initialize();
}; Accordion.prototype = {
defaults: {
title: 'h3',
preactivate: [0]
},
initialize: function(){
this.element.addClass('ui-accordion ui-widget ui-helper-reset ui-accordion-icons');
this.setupBaffles();
this.activate(this.options.preactivate);
},
setupBaffles: function(){
var self = this;
this.element.find(this.options.title).each(function(){
self.baffles.push(new Accordion.Baffle(jQuery(this)));
});
},
activate: function(baffles){
var self = this;
$.each(baffles, function(){
self.baffles[this].activate();
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment