Merge "Remove Persian from link underlining removal"
[lhc/web/wiklou.git] / resources / mediawiki.action / mediawiki.action.edit.collapsibleFooter.js
1 jQuery( document ).ready( function ( $ ) {
2 var collapsibleLists, i, handleOne;
3
4 // Collapsible lists of categories and templates
5 collapsibleLists = [
6 {
7 $list: $( '.templatesUsed ul' ),
8 $toggler: $( '.mw-templatesUsedExplanation' ),
9 cookieName: 'templates-used-list'
10 },
11 {
12 $list: $( '.hiddencats ul' ),
13 $toggler: $( '.mw-hiddenCategoriesExplanation' ),
14 cookieName: 'hidden-categories-list'
15 }
16 ];
17
18 handleOne = function ( $list, $toggler, cookieName ) {
19 var isCollapsed = $.cookie( cookieName ) !== 'expanded';
20
21 // Style the toggler with an arrow icon and add a tabIndex and a role for accessibility
22 $toggler.addClass( 'mw-editfooter-toggler' ).prop( 'tabIndex', 0 ).attr( 'role', 'button' );
23 $list.addClass( 'mw-editfooter-list' );
24
25 $list.makeCollapsible( {
26 $customTogglers: $toggler,
27 linksPassthru: true,
28 plainMode: true,
29 collapsed: isCollapsed
30 } );
31
32 $toggler.addClass( isCollapsed ? 'mw-icon-arrow-collapsed' : 'mw-icon-arrow-expanded' );
33
34 $list.on( 'beforeExpand.mw-collapsible', function () {
35 $toggler.removeClass( 'mw-icon-arrow-collapsed' ).addClass( 'mw-icon-arrow-expanded' );
36 $.cookie( cookieName, 'expanded' );
37 } );
38
39 $list.on( 'beforeCollapse.mw-collapsible', function () {
40 $toggler.removeClass( 'mw-icon-arrow-expanded' ).addClass( 'mw-icon-arrow-collapsed' );
41 $.cookie( cookieName, 'collapsed' );
42 } );
43 };
44
45 for ( i = 0; i < collapsibleLists.length; i++ ) {
46 // Pass to a function for iteration-local variables
47 handleOne( collapsibleLists[i].$list, collapsibleLists[i].$toggler, collapsibleLists[i].cookieName );
48 }
49 } );