Only show 'Show extended details' for file metadata having extra rows
authorumherirrender <umherirrender_de.wp@web.de>
Fri, 6 Dec 2013 21:36:26 +0000 (22:36 +0100)
committerBrian Wolff <bawolff+wn@gmail.com>
Sat, 14 Dec 2013 04:23:42 +0000 (04:23 +0000)
When a file only has default visible metadata, there is no need
to allow extending the optional metadata, because there are none.

Also added comments in ImagePage.php and shared.css because this
system is scattered all over and each piece seems disconnected
(the shared.css block was incorrectly documented as only being
used to initially hide rows, wheareas in practice that never
happens and instead the collapsed state is toggled on click).

Change-Id: I595fed425135c1e8dd341258633217428bcb4154

includes/ImagePage.php
resources/mediawiki.action/mediawiki.action.view.metadata.js
skins/common/shared.css

index 93cef53..05e1899 100644 (file)
@@ -262,7 +262,9 @@ class ImagePage extends Article {
                                # @todo FIXME: Why is this using escapeId for a class?!
                                $class = Sanitizer::escapeId( $v['id'] );
                                if ( $type == 'collapsed' ) {
-                                       $class .= ' collapsable'; // sic
+                                       // Handled by mediawiki.action.view.metadata module
+                                       // and skins/common/shared.css.
+                                       $class .= ' collapsable';
                                }
                                $r .= "<tr class=\"$class\">\n";
                                $r .= "<th>{$v['name']}</th>\n";
index ce3c674..9b27e24 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;
                }
 
index 2e61f63..310294a 100644 (file)
@@ -533,7 +533,11 @@ table.wikitable > caption {
        font-weight: bold;
 }
 
-/* hide initially collapsed collapsable tables */
+/**
+ * Hide collapsable rows in a collapsed table.
+ *
+ * Used by ImagePage and the mediawiki.action.view.metadata module.
+ */
 table.collapsed tr.collapsable {
        display: none;
 }