- $row = $( '<tr class="mw-metadata-show-hide-extended"></tr>' );
- $col = $( '<td colspan="2"></td>' );
-
- $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 );
+ $link = $( '<a>' )
+ .text( expandText )
+ .attr( {
+ role: 'button',
+ tabindex: 0
+ } )
+ .on( 'click keypress', function ( e ) {
+ if (
+ e.type === 'click' ||
+ e.type === 'keypress' && e.which === 13
+ ) {
+ if ( $table.hasClass( 'collapsed' ) ) {
+ // From collapsed to expanded. Button will now collapse.
+ $( this ).text( collapseText );
+ } else {
+ // From expanded to collapsed. Button will now expand.
+ $( this ).text( expandText );
+ }
+ $table.toggleClass( 'collapsed' );