User:Happy-melon/vector.js

/** * Collapsible tables and divs. * * Users can create tables and nested divs which collapse either on-click or on-load, * to save space on a page, or to conceal information at first sight. Eg: * *     *    *    *   	Content which will always be visible *  	 Click me! *  	  *   		This content will be hidden until the span above is clicked *  	  *    *    * If the user does not create a toggle-button manually, one will be created, * in the top-right header cell for tables, and at the beginning of the outer * div's content for a collapsible div. */ $('.collapsible2').each( function{	var $x = $j(this);	if( $('.collapsible-expander', $x).size ){		$('.collapsible-expander', $x)			.click(function(e){ e.preventDefault; $(this) .toggleClass('show') .trigger('mw-toggle-collapse'); return false; });	} else {		$expander = $j(' ')			.text( '[' + mediaWiki.msg( 'hide' ) + ']' )			.click(function(e, rmClass){ rmClass = rmClass == false ? false : true e.preventDefault; $(this) .toggleClass('show') .trigger('mw-toggle-collapse', [rmClass]) .text(						'[' + 						($(this).is('.collapsible2.collapsed .collapsible-expander') ? mediaWiki.msg( 'show' ) : mediaWiki.msg( 'hide' )) + 						']'					); return true; })			.before('[').after(']');		if( $x.is('div.collapsible2')){			$x.prepend($expander);		} else {			$('tr:first th:last',$x).append($expander);		}	} });

$('table.collapsible2').live( 'mw-toggle-collapse', function(e, rmClass){	e.stopPropagation;	$('tr:gt(0) > *',$(this))		.slideToggle;	if( rmClass ){		$(this).toggleClass('collapsed');	}	return true; });

$('div.collapsible2').live( 'mw-toggle-collapse', function(e){	e.stopPropagation;	$('div.collapsible2 > *:not(.collapsible-expander)',$(this))		.slideToggle;	$(this).toggleClass('collapsed');	return true; });

$('.collapsible2.collapsed .collapsible-expander').trigger( 'click', [false] );