mediawiki.checkboxtoggle: Run after document ready

Bug: T131318
Change-Id: I74d7de03e7338affbf7f0013937ec38a30cded27
This commit is contained in:
Kunal Mehta 2016-06-09 10:31:20 -07:00 committed by Krinkle
parent d2f540f7c3
commit 870c5e28e6

View file

@ -12,25 +12,28 @@
( function ( mw, $ ) { ( function ( mw, $ ) {
'use strict'; 'use strict';
var $checkboxes = $( 'li input[type=checkbox]' ); $( function () {
var $checkboxes = $( 'li input[type=checkbox]' );
function selectAll( check ) { function selectAll( check ) {
$checkboxes.prop( 'checked', check ); $checkboxes.prop( 'checked', check );
} }
$( '.mw-checkbox-all' ).click( function ( e ) { $( '.mw-checkbox-all' ).click( function ( e ) {
selectAll( true ); selectAll( true );
e.preventDefault(); e.preventDefault();
} );
$( '.mw-checkbox-none' ).click( function ( e ) {
selectAll( false );
e.preventDefault();
} );
$( '.mw-checkbox-invert' ).click( function ( e ) {
$checkboxes.each( function () {
$( this ).prop( 'checked', !$( this ).is( ':checked' ) );
} ); } );
e.preventDefault(); $( '.mw-checkbox-none' ).click( function ( e ) {
selectAll( false );
e.preventDefault();
} );
$( '.mw-checkbox-invert' ).click( function ( e ) {
$checkboxes.each( function () {
$( this ).prop( 'checked', !$( this ).is( ':checked' ) );
} );
e.preventDefault();
} );
} ); } );
}( mediaWiki, jQuery ) ); }( mediaWiki, jQuery ) );