User:Oh! Tea/sandbox.js

/*** Collapse sections ***/

// Adds an arrow to sections to make them collasible // Documentation at User:BrandonXLF/CollaspeSections // By User:BrandonXLF

// window.collapseSections - Set to true to collapse all sections by default

mw.hook('wikipage.content').add(function(content) {	if (mw.config.get('skin') === 'minerva') return;

mw.util.addCSS('[class*="hide-sec"]{display:none!important}');

content.find('.mw-parser-output :header:has(*)').each(function {		var level = +this.nodeName[1],			heading = $(this),			icon = $('');

icon.click(function {			var levelMatch = 'h1';			for (var i = 2; i <= level; i++) levelMatch += ',h' + i + ':has(*)';

icon.toggleClass('mw-ui-icon-mf-collapse'); icon.toggleClass('mw-ui-icon-mf-expand'); heading.nextUntil(levelMatch).toggleClass('hide-sect-h' + level); });

if (window.collapseSections) icon.click; heading.prepend(icon); }); });

mw.loader.load(['mediawiki.ui.icon', 'oojs-ui.styles.icons-movement']); mw.util.addCSS('[class*="hide-sec"]{display:none!important}');