*
* Add an expand/collapse link and collapse by default if set to
* (with JS disabled, user will see all items)
+ *
+ * See also:
+ * - ImagePage.php#makeMetadataTable (creates the HTML)
+ * - skins/common/shared.css (hides tr.collapsable inside table.collapsed)
*/
( function ( mw, $ ) {
$( function () {
$table = $( '#mw_metadata' ),
$tbody = $table.find( 'tbody' );
- if ( !$tbody.length ) {
+ if ( !$tbody.length || !$tbody.find( '.collapsable' ).length ) {
return;
}
$link = $( '<a>', {
text: showText,
href: '#'
- }).click(function () {
+ } ).click( function () {
if ( $table.hasClass( 'collapsed' ) ) {
$( this ).text( hideText );
} else {
}
$table.toggleClass( 'expanded collapsed' );
return false;
- });
+ } );
$col.append( $link );
$row.append( $col );