Debian Codegraph @

resources/src/mediawiki.checkboxtoggle.js

raw symbols SCIP
1 /*!
2 * Allows users to perform all / none / invert operations on a list of
3 * checkboxes on the page.
4 *
5 * @licence GNU GPL v2+
6 * @author Luke Faraone <luke at faraone dot cc>
7 *
8 * Based on ext.nuke.js from https://www.mediawiki.org/wiki/Extension:Nuke by
9 * Jeroen De Dauw <jeroendedauw at gmail dot com>
10 */
11
12 ( function () {
13 'use strict';
14
15 $( () => {
16 // FIXME: This shouldn't be a global selector to avoid conflicts
17 // with unrelated content on the same page. (T131318)
18 const $checkboxes = $( 'li input[type="checkbox"]' );
19
20 function selectAll( check ) {
21 $checkboxes.prop( 'checked', check ).trigger( 'change' );
22 }
23
24 $( '.mw-checkbox-all' ).on( 'click', () => {
25 selectAll( true );
26 } );
27 $( '.mw-checkbox-none' ).on( 'click', () => {
28 selectAll( false );
29 } );
30 $( '.mw-checkbox-invert' ).on( 'click', () => {
31 $checkboxes.prop( 'checked', ( i, val ) => !val ).trigger( 'change' );
32 } );
33
34 } );
35
36 }() );