User:GhostInTheMachine/FoldSections.js

// Adds an arrow to sections to make them collapsible // Cloned from User:BrandonXLF/CollapseSections

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

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

// repair the contributions list after phab T298638 mw.util.addCSS('h4.mw-index-pager-list-header { width: inherit; height: inherit; padding-top: 7px; position: relative !important; background-color: cornsilk; }');

mainpart = $('.mw-parser-output, .mw-pager-body', content); mainpart.find(':header').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-next'); icon.toggleClass('mw-ui-icon-expand'); heading.nextUntil(levelMatch).toggleClass('hide-sect-h' + level); });

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