Created
November 15, 2010 03:17
-
-
Save jiggliemon/676379 to your computer and use it in GitHub Desktop.
Simple Accordion Plugin
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
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