2 * Exif metadata display for MediaWiki file uploads
4 * Add an expand/collapse link and collapse by default if set to
5 * (with JS disabled, user will see all items)
7 * See also ImagePage.php#makeMetadataTable (creates the HTML)
11 var $tables
= $( '.mw_metadata' );
12 if ( !$tables
.find( '.mw-metadata-collapsible, .collapsable' ).length
) {
13 // No collapsible rows present on this page
16 $tables
.each( function () {
18 expandText
= mw
.msg( 'metadata-expand' ),
19 collapseText
= mw
.msg( 'metadata-collapse' ),
28 .on( 'click keypress', function ( e
) {
31 e
.type
=== 'keypress' && e
.which
=== 13
33 // eslint-disable-next-line no-jquery/no-class-state
34 if ( $table
.hasClass( 'collapsed' ) ) {
35 // From collapsed to expanded. Button will now collapse.
36 $( this ).text( collapseText
);
38 // From expanded to collapsed. Button will now expand.
39 $( this ).text( expandText
);
41 // eslint-disable-next-line no-jquery/no-class-state
42 $table
.toggleClass( 'collapsed' );
46 $table
.find( 'tbody' ).append(
47 $( '<tr>' ).addClass( 'mw-metadata-show-hide-extended' ).append(
48 $( '<td>' ).prop( 'colspan', 2 ).append( $link
)