2 * JavaScript for Special:EditWatchlist
6 let checkAllChangeOngoing = false;
7 let multiselectChangeOngoing = false;
9 const checkAllCheckboxes = $( '.mw-watchlistedit-checkall .oo-ui-checkboxInputWidget' )
11 .map( ( element ) => OO.ui.infuse( element ) );
13 const multiselects = $( '.mw-watchlistedit-check .oo-ui-checkboxMultiselectInputWidget' )
15 .map( ( element ) => OO.ui.infuse( element ).checkboxMultiselectWidget );
17 checkAllCheckboxes.forEach( ( checkbox, index ) => {
18 checkbox.on( 'change', ( isChecked ) => {
19 if ( multiselectChangeOngoing ) {
22 checkAllChangeOngoing = true;
24 // Select or de-select all the title checkboxes for this namespace
25 const multiselect = multiselects[ index ];
26 multiselect.selectItems( isChecked ? multiselect.items : [] );
28 checkAllChangeOngoing = false;
32 multiselects.forEach( ( multiselect, index ) => {
33 multiselect.on( 'change', () => {
34 if ( checkAllChangeOngoing ) {
37 multiselectChangeOngoing = true;
39 // Update the state of the check-all checkbox for this namespace
40 const checkAllCheckbox = checkAllCheckboxes[ index ];
41 const numSelectedItems = multiselect.findSelectedItems().length;
42 if ( numSelectedItems === multiselect.items.length ) {
43 checkAllCheckbox.setSelected( true );
44 checkAllCheckbox.setIndeterminate( false );
45 } else if ( numSelectedItems === 0 ) {
46 checkAllCheckbox.setSelected( false );
47 checkAllCheckbox.setIndeterminate( false );
49 checkAllCheckbox.setIndeterminate( true );
52 multiselectChangeOngoing = false;