Merge "Make infused and non-infused DateInputWidget consistent"
[lhc/web/wiklou.git] / resources / src / mediawiki.action / mediawiki.action.view.metadata.js
index 25b5acc..a3a82d5 100644 (file)
                        $table = $( '#mw_metadata' ),
                        $tbody = $table.find( 'tbody' );
 
-               if ( !$tbody.length || !$tbody.find( '.collapsable' ).length ) {
+               if ( !$tbody.find( '.collapsable' ).length ) {
                        return;
                }
 
                $row = $( '<tr class="mw-metadata-show-hide-extended"></tr>' );
                $col = $( '<td colspan="2"></td>' );
 
-               $link = $( '<a>', {
-                       text: showText,
-                       href: '#'
-               } ).click( function () {
-                       if ( $table.hasClass( 'collapsed' ) ) {
-                               $( this ).text( hideText );
-                       } else {
-                               $( this ).text( showText );
+               $link = $( '<a>' )
+               .text( showText )
+               .attr( {
+                       role: 'button',
+                       tabindex: 0
+               } )
+               .on( 'click keypress', function ( e ) {
+                       if (
+                               e.type === 'click' ||
+                               e.type === 'keypress' && e.which === 13
+                       ) {
+                               if ( $table.hasClass( 'collapsed' ) ) {
+                                       $( this ).text( hideText );
+                               } else {
+                                       $( this ).text( showText );
+                               }
+                               $table.toggleClass( 'expanded collapsed' );
                        }
-                       $table.toggleClass( 'expanded collapsed' );
-                       return false;
                } );
 
                $col.append( $link );