Better JavaScript handling for return method
[lhc/web/wiklou.git] / resources / src / mediawiki.action / mediawiki.action.view.metadata.js
index 712cf29..4c75e33 100644 (file)
@@ -4,9 +4,7 @@
  * 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)
+ * See also ImagePage.php#makeMetadataTable (creates the HTML)
  */
 ( function ( mw, $ ) {
        $( function () {
                        $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 () {
+               $link = $( '<a>' )
+               .text( showText )
+               .attr( 'href', '#' )
+               .click( function () {
                        if ( $table.hasClass( 'collapsed' ) ) {
                                $( this ).text( hideText );
                        } else {