ListToggle: Avoid href="#" for JavaScript buttons
authorFomafix <fomafix@googlemail.com>
Tue, 1 Aug 2017 20:57:45 +0000 (22:57 +0200)
committerFomafix <fomafix@googlemail.com>
Tue, 1 Aug 2017 20:57:45 +0000 (22:57 +0200)
<a href="#"> is problematic because it allows to open a new tab on
middleclick and it shows a status line.

Change-Id: Id8d7f79a2894693a82f86ae46900e6f0aecba4f3

includes/ListToggle.php
resources/src/mediawiki/mediawiki.checkboxtoggle.js

index 2c87b8b..7a5fd9a 100644 (file)
@@ -42,7 +42,7 @@ class ListToggle {
        private function checkboxLink( $checkboxType ) {
                return Html::element(
                        // CSS classes: mw-checkbox-all, mw-checkbox-none, mw-checkbox-invert
-                       'a', [ 'href' => '#', 'class' => 'mw-checkbox-' . $checkboxType ],
+                       'a', [ 'class' => 'mw-checkbox-' . $checkboxType, 'role' => 'button', 'tabindex' => 0 ],
                        $this->output->msg( 'checkbox-' . $checkboxType )->text()
                );
        }
index 901f875..36090ea 100644 (file)
                        $checkboxes.prop( 'checked', check );
                }
 
-               $( '.mw-checkbox-all' ).click( function ( e ) {
-                       e.preventDefault();
+               $( '.mw-checkbox-all' ).click( function () {
                        selectAll( true );
                } );
-               $( '.mw-checkbox-none' ).click( function ( e ) {
-                       e.preventDefault();
+               $( '.mw-checkbox-none' ).click( function () {
                        selectAll( false );
                } );
-               $( '.mw-checkbox-invert' ).click( function ( e ) {
-                       e.preventDefault();
+               $( '.mw-checkbox-invert' ).click( function () {
                        $checkboxes.prop( 'checked', function ( i, val ) {
                                return !val;
                        } );