Merge "(bug 47070) check content model namespace on import."
[lhc/web/wiklou.git] / resources / mediawiki.action / mediawiki.action.view.metadata.js
index ce3c674..d23a937 100644 (file)
@@ -3,6 +3,10 @@
  *
  * 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 () {
@@ -12,7 +16,7 @@
                        $table = $( '#mw_metadata' ),
                        $tbody = $table.find( 'tbody' );
 
-               if ( !$tbody.length ) {
+               if ( !$tbody.length || !$tbody.find( '.collapsable' ).length ) {
                        return;
                }
 
@@ -22,7 +26,7 @@
                $link = $( '<a>', {
                        text: showText,
                        href: '#'
-               }).click(function () {
+               } ).click( function () {
                        if ( $table.hasClass( 'collapsed' ) ) {
                                $( this ).text( hideText );
                        } else {
@@ -30,7 +34,7 @@
                        }
                        $table.toggleClass( 'expanded collapsed' );
                        return false;
-               });
+               } );
 
                $col.append( $link );
                $row.append( $col );