Merge "Fix and make some types in PHPDoc and JSDoc tags more specific"
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.checkboxtoggle.js
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 ( mw, $ ) {
13 'use strict';
14
15 $( function () {
16 // FIXME: This shouldn't be a global selector to avoid conflicts
17 // with unrelated content on the same page. (T131318)
18 var $checkboxes = $( 'li input[type="checkbox"]' );
19
20 function selectAll( check ) {
21 $checkboxes.prop( 'checked', check );
22 }
23
24 $( '.mw-checkbox-all' ).click( function () {
25 selectAll( true );
26 } );
27 $( '.mw-checkbox-none' ).click( function () {
28 selectAll( false );
29 } );
30 $( '.mw-checkbox-invert' ).click( function () {
31 $checkboxes.prop( 'checked', function ( i, val ) {
32 return !val;
33 } );
34 } );
35
36 } );
37
38 }( mediaWiki, jQuery ) );