ListToggle: Avoid href="#" for JavaScript buttons
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.checkboxtoggle.js
index 62760d2..36090ea 100644 (file)
        'use strict';
 
        $( function () {
-               var $checkboxes = $( 'li input[type=checkbox]' );
+               // FIXME: This shouldn't be a global selector to avoid conflicts
+               // with unrelated content on the same page. (T131318)
+               var $checkboxes = $( 'li input[type="checkbox"]' );
 
                function selectAll( check ) {
                        $checkboxes.prop( 'checked', check );
                }
 
-               $( '.mw-checkbox-all' ).click( function ( e ) {
+               $( '.mw-checkbox-all' ).click( function () {
                        selectAll( true );
-                       e.preventDefault();
                } );
-               $( '.mw-checkbox-none' ).click( function ( e ) {
+               $( '.mw-checkbox-none' ).click( function () {
                        selectAll( false );
-                       e.preventDefault();
                } );
-               $( '.mw-checkbox-invert' ).click( function ( e ) {
-                       $checkboxes.each( function () {
-                               $( this ).prop( 'checked', !$( this ).is( ':checked' ) );
+               $( '.mw-checkbox-invert' ).click( function () {
+                       $checkboxes.prop( 'checked', function ( i, val ) {
+                               return !val;
                        } );
-                       e.preventDefault();
                } );
 
        } );
 
 }( mediaWiki, jQuery ) );
-