User:Gary/smaller templates.js

Source: Wikipedia, the free encyclopedia.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/*
	SMALLER TEMPLATES
	Description: Makes maintenance templates such as {cleanup} appear smaller so that they take up less space.
*/

function smallerTemplates()
{
	mw.util.addCSS('\
		.mbox-image div, .mbox-image .image, .mbox-imageright { display: none; }\
		table.ambox { margin: 0 15%; }\
		table.ambox { border-radius: 0px; }\
	');
	
	formatBoxes('ambox-content');
	formatBoxes('ambox-delete');
	formatBoxes('ambox-move');
	formatBoxes('ambox-notice');
	formatBoxes('ambox-protection');
	formatBoxes('ambox-style');
}

function formatBoxes(className)
{
	mw.util.addCSS('.' + className + ' td { padding: 0 0.25em !important; font-size: 10px !important; line-height: 1.5em; }');
	$('.' + className).each(function() { boxInit($(this)); });
}

function boxInit(box)
{	
	// Collapse the box, using Wikipedia's own "hide" button.
	var collapseButton = $('.collapseButton:first > a:first', box);
	if (collapseButton.text() == 'hide') collapseButton.click();
}

if (mw.util.getParamValue('disable') != 'smalltemplates' && ((mw.config.get('wgCanonicalNamespace') == '' || mw.config.get('wgPageName') == 'User:Gary_King/Sandbox' || mw.config.get('wgPageName') == 'Wikipedia:Template_messages/Cleanup') && mw.config.get('wgAction') == 'view')) $(smallerTemplates);