MOOTOOLS V1.2 - ACCORDION EXTENSION

Extension for Accordion plugin in Mootools v1.2 to allow to multiple open accordion sections. Example meant to show how easy it is to extend mootools classes using the new framework.

Back to examples list

Toggle Section One
Here is extension code

var multipleOpenAccordion = new Class({
	Extends: Accordion,
	options: {
		allowMultipleOpen: true
	},
	initialize: function(togglers,togglees,options){
		this.parent(togglers,togglees,this.options);
	},
	display: function(index){
		index = ($type(index) == 'element') ? this.elements.indexOf(index) : index;
		if ((this.timer && this.options.wait) || (index === this.previous && !this.options.alwaysHide)) return this;
		
		var obj = {};
		if(this.options.allowMultipleOpen){
			var el = this.elements[index];
			console.log($type(el));
			obj[index] = {};
			var hide = (el.offsetHeight > 0);
			this.fireEvent(hide ? 'onBackground' : 'onActive', [this.togglers[index], el]);
			for (var fx in this.effects) obj[index][fx] = hide ? 0 : el[this.effects[fx]];
		}else{
			this.previous = index;
			this.elements.each(function(el, i){
				obj[i] = {};
				var hide = (i != index) || (this.options.alwaysHide && (el.offsetHeight > 0));
				this.fireEvent(hide ? 'onBackground' : 'onActive', [this.togglers[i], el]);
				for (var fx in this.effects) obj[i][fx] = hide ? 0 : el[this.effects[fx]];
			}, this);
			
		}
		return this.start(obj);
	}
});
				
Toggle Section Two
More variable length content












END.
Toggle Secion Three
More variable length content






END.
Toggle Section Four
Toggle Section Five