From a85fc78386e85a0b8df6d4fcc66ed4bb783cc0d7 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Fri, 6 Dec 2013 22:36:26 +0100 Subject: [PATCH] Only show 'Show extended details' for file metadata having extra rows 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 | 4 +++- .../mediawiki.action/mediawiki.action.view.metadata.js | 6 +++++- skins/common/shared.css | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 93cef53fee..05e1899360 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -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 .= "\n"; $r .= "{$v['name']}\n"; diff --git a/resources/mediawiki.action/mediawiki.action.view.metadata.js b/resources/mediawiki.action/mediawiki.action.view.metadata.js index ce3c674b8b..9b27e2492a 100644 --- a/resources/mediawiki.action/mediawiki.action.view.metadata.js +++ b/resources/mediawiki.action/mediawiki.action.view.metadata.js @@ -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; } diff --git a/skins/common/shared.css b/skins/common/shared.css index 2e61f630a9..310294af50 100644 --- a/skins/common/shared.css +++ b/skins/common/shared.css @@ -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; } -- 2.20.1