1 jQuery( document ).ready( function ( $ ) {
2 var collapsibleLists, i, handleOne;
4 // Collapsible lists of categories and templates
7 $list: $( '.templatesUsed ul' ),
8 $toggler: $( '.mw-templatesUsedExplanation' ),
9 cookieName: 'templates-used-list'
12 $list: $( '.hiddencats ul' ),
13 $toggler: $( '.mw-hiddenCategoriesExplanation' ),
14 cookieName: 'hidden-categories-list'
17 $list: $( '.preview-limit-report-wrapper' ),
18 $toggler: $( '.mw-limitReportExplanation' ),
19 cookieName: 'preview-limit-report'
23 handleOne = function ( $list, $toggler, cookieName ) {
24 var isCollapsed = $.cookie( cookieName ) !== 'expanded';
26 // Style the toggler with an arrow icon and add a tabIndex and a role for accessibility
27 $toggler.addClass( 'mw-editfooter-toggler' ).prop( 'tabIndex', 0 ).attr( 'role', 'button' );
28 $list.addClass( 'mw-editfooter-list' );
30 $list.makeCollapsible( {
31 $customTogglers: $toggler,
34 collapsed: isCollapsed
37 $toggler.addClass( isCollapsed ? 'mw-icon-arrow-collapsed' : 'mw-icon-arrow-expanded' );
39 $list.on( 'beforeExpand.mw-collapsible', function () {
40 $toggler.removeClass( 'mw-icon-arrow-collapsed' ).addClass( 'mw-icon-arrow-expanded' );
41 $.cookie( cookieName, 'expanded' );
44 $list.on( 'beforeCollapse.mw-collapsible', function () {
45 $toggler.removeClass( 'mw-icon-arrow-expanded' ).addClass( 'mw-icon-arrow-collapsed' );
46 $.cookie( cookieName, 'collapsed' );
50 for ( i = 0; i < collapsibleLists.length; i++ ) {
51 // Pass to a function for iteration-local variables
52 handleOne( collapsibleLists[i].$list, collapsibleLists[i].$toggler, collapsibleLists[i].cookieName );