protected function makeMetadataTable( $metadata ) {
$r = "<div class=\"mw-imagepage-section-metadata\">";
$r .= $this->getContext()->msg( 'metadata-help' )->plain();
- $r .= "<table id=\"mw_metadata\" class=\"mw_metadata\">\n";
+ // Intial state is collapsed
+ // see filepage.css and mediawiki.action.view.metadata module.
+ $r .= "<table id=\"mw_metadata\" class=\"mw_metadata collapsed\">\n";
foreach ( $metadata as $type => $stuff ) {
foreach ( $stuff as $v ) {
$class = str_replace( ' ', '_', $v['id'] );
if ( $type == 'collapsed' ) {
- // Handled by mediawiki.action.view.metadata module.
- $class .= ' collapsable';
+ $class .= ' mw-metadata-collapsible';
}
$r .= Html::rawElement( 'tr',
[ 'class' => $class ],
# Collapsible
$collapsedState = $this->getRequest()->getCookie( 'changeslist-state' );
$collapsedClass = $collapsedState === 'collapsed' ? ' mw-collapsed' : '';
+ # Enhanced mode
+ $enhancedMode = $this->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
+ $enhancedClass = $enhancedMode ? ' mw-enhanced' : '';
+
+ $legendClasses = $collapsedClass . $enhancedClass;
$legend =
- '<div class="mw-changeslist-legend mw-collapsible' . $collapsedClass . '">' .
+ '<div class="mw-changeslist-legend mw-collapsible' . $legendClasses . '">' .
$legendHeading .
'<div class="mw-collapsible-content">' . $legend . '</div>' .
'</div>';
$warnings['was-deleted'] = $filename;
}
- $dupes = $this->checkAgainstExistingDupes( $hash );
+ // If a file with the same name exists locally then the local file has already been tested
+ // for duplication of content
+ $ignoreLocalDupes = isset( $warnings[ 'exists '] );
+ $dupes = $this->checkAgainstExistingDupes( $hash, $ignoreLocalDupes );
if ( $dupes ) {
$warnings['duplicate'] = $dupes;
}
/**
* @param string $hash sha1 hash of the file to check
+ * @param bool $ignoreLocalDupes True to ignore local duplicates
*
* @return File[] Duplicate files, if found.
*/
- private function checkAgainstExistingDupes( $hash ) {
+ private function checkAgainstExistingDupes( $hash, $ignoreLocalDupes ) {
$dupes = RepoGroup::singleton()->findBySha1( $hash );
$title = $this->getTitle();
- // Remove all matches against self
foreach ( $dupes as $key => $dupe ) {
- if ( $title->equals( $dupe->getTitle() ) ) {
+ if (
+ ( $dupe instanceof LocalFile ) &&
+ $ignoreLocalDupes &&
+ $title->equals( $dupe->getTitle() )
+ ) {
unset( $dupes[$key] );
}
}
'metadata-expand',
'metadata-collapse',
],
+ 'dependencies' => 'mediawiki.action.view.filepage',
],
'mediawiki.action.view.categoryPage.styles' => [
'styles' => 'resources/src/mediawiki.action/mediawiki.action.view.categoryPage.less',
padding-left: 5px;
margin: 0;
}
+
+.client-js .mw_metadata.collapsed .mw-metadata-collapsible,
+/* Keep tr.collapsible for back-compat with cached HTML */
+.client-js .mw_metadata.collapsed tr.collapsable {
+ display: none;
+}
/*!
- * Hide collapsable rows in a collapsed table.
+ * Styles for metadata.js.
*/
-table.collapsed tr.collapsable {
- display: none;
-}
/*
* Exclude user interface elements from selection.
*/
.mw-metadata-show-hide-extended {
- -moz-user-select: none;
-webkit-user-select: none;
+ -moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@media print {
- tr.mw-metadata-show-hide-extended {
+ .mw_metadata .mw-metadata-show-hide-extended {
display: none;
}
}
*/
( function ( mw, $ ) {
$( function () {
- var $row, $col, $link,
- showText = mw.msg( 'metadata-expand' ),
- hideText = mw.msg( 'metadata-collapse' ),
- $table = $( '#mw_metadata' ),
- $tbody = $table.find( 'tbody' );
-
- if ( !$tbody.find( '.collapsable' ).length ) {
+ var $tables = $( '.mw_metadata' );
+ if ( !$tables.find( '.mw-metadata-collapsible, .collapsable' ).length ) {
+ // No collapsible rows present on this page
return;
}
+ $tables.each( function () {
+ var $link,
+ expandText = mw.msg( 'metadata-expand' ),
+ collapseText = mw.msg( 'metadata-collapse' ),
+ $table = $( this );
- $row = $( '<tr class="mw-metadata-show-hide-extended"></tr>' );
- $col = $( '<td colspan="2"></td>' );
-
- $link = $( '<a>' )
- .text( showText )
- .attr( {
- role: 'button',
- tabindex: 0
- } )
- .on( 'click keypress', function ( e ) {
- if (
- e.type === 'click' ||
- e.type === 'keypress' && e.which === 13
- ) {
- if ( $table.hasClass( 'collapsed' ) ) {
- $( this ).text( hideText );
- } else {
- $( this ).text( showText );
+ $link = $( '<a>' )
+ .text( expandText )
+ .attr( {
+ role: 'button',
+ tabindex: 0
+ } )
+ .on( 'click keypress', function ( e ) {
+ if (
+ e.type === 'click' ||
+ e.type === 'keypress' && e.which === 13
+ ) {
+ if ( $table.hasClass( 'collapsed' ) ) {
+ // From collapsed to expanded. Button will now collapse.
+ $( this ).text( collapseText );
+ } else {
+ // From expanded to collapsed. Button will now expand.
+ $( this ).text( expandText );
+ }
+ $table.toggleClass( 'collapsed' );
}
- $table.toggleClass( 'expanded collapsed' );
- }
- } );
+ } );
- $col.append( $link );
- $row.append( $col );
- $tbody.append( $row );
+ $table.find( 'tbody' ).append(
+ $( '<tr class="mw-metadata-show-hide-extended"></tr>' ).append(
+ $( '<td colspan="2"></td>' ).append( $link )
+ )
+ );
+ } );
- // And collapse!
- $table.addClass( 'collapsed' );
+ // Initial collapsed state
+ // (For back-compat with cached HTML from before ImagePage.php
+ // did this by default)
+ $tables.addClass( 'collapsed' );
} );
}( mediaWiki, jQuery ) );
}
}
+ &-enhancedView {
+ .mw-changeslist-legend {
+ z-index: 1;
+
+ &:not( .mw-collapsed ) {
+ .box-shadow( 0 1px 1px rgba( 0, 0, 0, 0.15 ) );
+ }
+ }
+ }
+
.mw-changeslist-legend {
background-color: @background-color-base;
+ border: 1px solid @colorGray12;
}
// Correction for Enhanced RC
// Regular RC
$content.find( 'ul.special li' )
.prepend( $highlights.clone() );
+
+ $content.removeClass( 'mw-rcfilters-ui-changesListWrapperWidget-enhancedView' );
}
};
.mw-changeslist-legend.mw-collapsed .mw-collapsible-content {
display: none;
}
+
+/* Prevent pushing down of content if legend is initially collapsed */
+.mw-changeslist-legend.mw-collapsed ~ ul.special > li:first-child {
+ clear: right;
+}
+
+/* Absolute positioning to avoid table overlap with floating elements */
+.mw-changeslist-legend.mw-enhanced {
+ background-color: #fff;
+ position: absolute;
+ right: 0;
+ margin-top: -0.5em;
+}