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
# @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";
*
* 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;
}
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;
}