After messing around in the debugger for a while, I figured out how to
make an Accordion act the way I wanted. Here are the methods that I
added to allow the described behavior.
Accordion.implement({
setHeight: function(size) {
// Allow height to be changed after instantiation
var previous = this.previous;
this.effects.height = 'fullHeight';
this.options.fixedHeight = size;
this.previous = -1;
this.elements.each(function(el, i){
el.fullHeight = size;
if ( previous == i )
this.display(i);
}, this);
},
setWidth: function(size) {
// Allow width to be changed after instantiation
var previous = this.previous;
this.effects.height = 'fullWidth';
this.options.fixedWidth = size;
this.previous = -1;
this.elements.each(function(el, i){
el.fullWidth = size;
if ( previous == i )
this.display(i);
}, this);
},
fitToWindow: function() {
// Stretch the accordion to reach the bottom of the window
var bottom = this.elements.getLast().getCoordinates().bottom;
var windowHeight = window.getSize().y;
var selectedHeight = ( this.previous < 0 ) ? 0 :
this.elements[this.previous].getStyle('height').toInt();
var fullHeight = windowHeight - bottom + selectedHeight;
this.setHeight(fullHeight + 'px');
}
});