var Tabs = new Class({
Implements: Options,
togglers: [],
elements: [],
currentRequest: false,
options: {
'defaultTab': false,
'loadingImage': false,
'game': null,
'mode': null,
'extra': []
},
initialize: function(container, togglers, options) {
this.setOptions(options);
this.container = $(container);
$splat(togglers).map(this.addTab, this);
},
addTab: function(toggler) {
this.togglers.include(toggler);
toggler.addEvent('click', this.loadTab.bind(this, [toggler, this.togglers.indexOf(toggler)]));
if ( toggler.id.replace(/^tab_/, '') == this.options.defaultTab )
{
this.loadTab(toggler, this.togglers.indexOf(toggler));
}
},
updateTab: function(txt) {
$(this.loading).destroy();
this.elements[this.currentRequest.options.currentTab] = new Element('div').set('html', txt).injectInside(this.container);
//Evaluate the response AFTER it's been created
txt.stripScripts(true);
this.currentRequest = false;
},
refreshTab: function(change) {
this.options.extra = $merge(this.options.extra, change);
for ( i=0; i