MediaWiki:CollapsibleList.js

//converts some lists to collapsible ones (function ($) {   function convertEl($e) {        var $el = $e.clone,        $toggler = $(' ', { text: $el.text.slice(1), class: 'ctgglr collapsed' }),       $ul = $e.next('ul, ol'),        $wrap = $('', { class: 'cul' });       $wrap.append($toggler);        $wrap.append($ul);        $e.replaceWith($wrap);        $ul.toggle;    }

function tgglr(e) { e.stopPropagation; //there are dupl evnts for nested .cul li .cul li       var $e = $(e.target), $ul = $e.parent.next('ul, ol, li'); if (e.target.nodeName === 'SPAN') { $e.siblings.toggle; $e.toggleClass('collapsed expanded'); } else { if (!$e.children.length) return; $e.children.toggle; $e.toggleClass('collapsed expanded'); }   }    $(function  {        var $content = $('#mw-content-text');        $content.find(':contains(+)').each(function  { var $this = $(this), nname = ($this.next.get(0) || {}).nodeName; if (!($this.text.startsWith('+') && (nname === 'UL' || nname === 'OL'))) return; convertEl($this); });       mw.util.addCSS('\ .cul .expanded:before {content:"-"}\ .cul .collapsed:before {content:"+"}\ .cul {padding-left:0}\ .cul ul {list-style-type: none}\ ');       $('.cul li').children.toggle;        $('.cul li').children.parent.addClass('collapsed');    }); $('body').on('click', '.cul li, .ctgglr', tgglr); })(jQuery);