2014-02-07 14:47:00 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the MediaWiki extension MultimediaViewer.
|
|
|
|
*
|
|
|
|
* MultimediaViewer is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MultimediaViewer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MultimediaViewer. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2023-05-19 20:26:45 +00:00
|
|
|
const { HtmlUtils } = require( 'mmv.bootstrap' );
|
|
|
|
const Description = require( './mmv.ui.description.js' );
|
|
|
|
const UiElement = require( './mmv.ui.js' );
|
|
|
|
const MetadataPanelScroller = require( './mmv.ui.metadataPanelScroller.js' );
|
|
|
|
const Permission = require( './mmv.ui.permission.js' );
|
|
|
|
const ProgressBar = require( './mmv.ui.progressBar.js' );
|
|
|
|
const StripeButtons = require( './mmv.ui.stripeButtons.js' );
|
|
|
|
const TruncatableTextField = require( './mmv.ui.truncatableTextField.js' );
|
|
|
|
|
2018-11-12 16:33:24 +00:00
|
|
|
( function () {
|
2014-02-07 14:47:00 +00:00
|
|
|
|
|
|
|
/**
|
2014-02-19 02:27:30 +00:00
|
|
|
* Represents the metadata panel in the viewer
|
2014-02-07 14:47:00 +00:00
|
|
|
*/
|
2023-05-20 12:38:59 +00:00
|
|
|
class MetadataPanel extends UiElement {
|
|
|
|
/**
|
|
|
|
* @param {jQuery} $container The container for the panel (.mw-mmv-post-image).
|
|
|
|
* @param {jQuery} $aboveFold The brighter headline of the metadata panel (.mw-mmv-above-fold).
|
|
|
|
* Called "aboveFold" for historical reasons, but actually a part of the next sibling of the element
|
|
|
|
* is also above the fold (bottom of the screen).
|
|
|
|
* @param {mw.SafeStorage} localStorage the localStorage object, for dependency injection
|
|
|
|
* @param {Config} config A configuration object.
|
|
|
|
*/
|
|
|
|
constructor( $container, $aboveFold, localStorage, config ) {
|
|
|
|
super( $container );
|
|
|
|
|
|
|
|
this.$aboveFold = $aboveFold;
|
|
|
|
|
|
|
|
/** @property {Config} config - */
|
|
|
|
this.config = config;
|
|
|
|
|
|
|
|
/** @property {HtmlUtils} htmlUtils - */
|
|
|
|
this.htmlUtils = new HtmlUtils();
|
|
|
|
|
|
|
|
this.initializeHeader( localStorage );
|
|
|
|
this.initializeImageMetadata();
|
|
|
|
this.initializeAboutLinks();
|
|
|
|
}
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* FIXME this should be in the jquery.fullscreen plugin.
|
|
|
|
*
|
|
|
|
* @return {boolean}
|
|
|
|
*/
|
|
|
|
isFullscreened() {
|
|
|
|
return $( this.$container ).closest( '.jq-fullscreened' ).length > 0;
|
|
|
|
}
|
2015-06-20 05:03:28 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
attach() {
|
|
|
|
this.scroller.attach();
|
|
|
|
this.buttons.attach();
|
|
|
|
this.title.attach();
|
|
|
|
this.creditField.attach();
|
|
|
|
|
|
|
|
this.$title
|
|
|
|
.add( this.$authorAndSource )
|
|
|
|
.add( this.title.$ellipsis )
|
|
|
|
.add( this.creditField.$ellipsis )
|
|
|
|
.on( 'click.mmv-mp', ( e ) => {
|
|
|
|
const clickTargetIsLink = $( e.target ).is( 'a' );
|
|
|
|
const clickTargetIsTruncated = !!$( e.target ).closest( '.mw-mmv-ttf-truncated' ).length;
|
|
|
|
const someTextIsExpanded = !!$( e.target ).closest( '.mw-mmv-untruncated' ).length;
|
|
|
|
|
|
|
|
if ( !clickTargetIsLink && // don't interfere with clicks on links in the text
|
|
|
|
clickTargetIsTruncated && // don't expand when non-truncated text is clicked
|
|
|
|
!someTextIsExpanded // ignore clicks if text is already expanded
|
|
|
|
) {
|
|
|
|
if ( this.isFullscreened() ) {
|
|
|
|
this.revealTruncatedText();
|
|
|
|
} else {
|
|
|
|
this.scroller.toggle( 'up' );
|
|
|
|
}
|
2014-11-22 02:46:51 +00:00
|
|
|
}
|
2023-05-20 12:38:59 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
$( this.$container ).on( 'mmv-metadata-open.mmv-mp mmv-metadata-reveal-truncated-text.mmv-mp', () => {
|
|
|
|
this.revealTruncatedText();
|
|
|
|
} ).on( 'mmv-metadata-close.mmv-mp', () => {
|
|
|
|
this.hideTruncatedText();
|
|
|
|
} ).on( 'mouseleave.mmv-mp', () => {
|
|
|
|
if ( this.isFullscreened() ) {
|
|
|
|
const duration = parseFloat( this.$container.css( 'transition-duration' ) ) * 1000 || 0;
|
|
|
|
this.panelShrinkTimeout = setTimeout( () => {
|
|
|
|
this.hideTruncatedText();
|
|
|
|
}, duration );
|
2014-10-29 19:50:53 +00:00
|
|
|
}
|
2023-05-20 12:38:59 +00:00
|
|
|
} ).on( 'mouseenter.mmv-mp', () => {
|
|
|
|
clearTimeout( this.panelShrinkTimeout );
|
|
|
|
} ).on( 'mmv-permission-grow.mmv-mp', () => {
|
|
|
|
this.$permissionLink
|
|
|
|
.text( mw.message( 'multimediaviewer-permission-link-hide' ).text() );
|
|
|
|
} ).on( 'mmv-permission-shrink.mmv-mp', () => {
|
|
|
|
this.$permissionLink
|
|
|
|
.text( mw.message( 'multimediaviewer-permission-link' ).text() );
|
2014-10-29 19:50:53 +00:00
|
|
|
} );
|
2014-07-16 23:15:38 +00:00
|
|
|
|
2023-09-21 23:24:12 +00:00
|
|
|
this.handleEvent( 'fullscreenchange.lip', () => {
|
2023-05-20 12:38:59 +00:00
|
|
|
this.hideTruncatedText();
|
|
|
|
} );
|
|
|
|
}
|
2015-01-13 02:51:46 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
unattach() {
|
|
|
|
this.scroller.freezeHeight();
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$title
|
|
|
|
.add( this.title.$ellipsis )
|
|
|
|
.add( this.$authorAndSource )
|
|
|
|
.add( this.creditField.$ellipsis )
|
|
|
|
.off( 'click.mmv-mp' );
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
$( this.$container ).off( '.mmv-mp' );
|
2014-11-11 15:21:36 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.scroller.unattach();
|
|
|
|
this.buttons.unattach();
|
|
|
|
this.clearEvents();
|
|
|
|
}
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
empty() {
|
|
|
|
this.scroller.freezeHeight();
|
|
|
|
this.scroller.empty();
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.buttons.empty();
|
2014-02-25 13:43:22 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.description.empty();
|
|
|
|
this.permission.empty();
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$title.removeClass( 'error' );
|
|
|
|
this.title.empty();
|
|
|
|
this.creditField.empty();
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$license.empty().prop( 'href', '#' );
|
|
|
|
this.$licenseLi.addClass( 'empty' );
|
|
|
|
this.$permissionLink.hide();
|
|
|
|
this.$restrictions.children().hide();
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$filename.empty();
|
|
|
|
this.$filenamePrefix.empty();
|
|
|
|
this.$filenameLi.addClass( 'empty' );
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2024-02-07 17:34:34 +00:00
|
|
|
this.$datetimeCreated.empty();
|
|
|
|
this.$datetimeCreatedLi.addClass( 'empty' );
|
|
|
|
this.$datetimeUpdated.empty();
|
|
|
|
this.$datetimeUpdatedLi.addClass( 'empty' );
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$location.empty();
|
|
|
|
this.$locationLi.addClass( 'empty' );
|
2014-03-27 06:05:47 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.progressBar.empty();
|
2014-10-29 19:50:53 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$container.removeClass( 'mw-mmv-untruncated' );
|
|
|
|
}
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/* Initialization methods */
|
|
|
|
/**
|
|
|
|
* Initializes the header, which contains the title, credit, and license elements.
|
|
|
|
*
|
|
|
|
* @param {mw.SafeStorage} localStorage the localStorage object, for dependency injection
|
|
|
|
*/
|
|
|
|
initializeHeader( localStorage ) {
|
|
|
|
this.progressBar = new ProgressBar( this.$aboveFold );
|
2014-10-27 14:03:16 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.scroller = new MetadataPanelScroller( this.$container, this.$aboveFold,
|
|
|
|
localStorage );
|
2014-10-29 19:50:53 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$titleDiv = $( '<div>' )
|
|
|
|
.addClass( 'mw-mmv-title-contain' )
|
|
|
|
.appendTo( this.$aboveFold );
|
2014-10-27 14:03:16 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$container.append( this.$aboveFold );
|
2014-10-27 14:03:16 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.initializeButtons(); // float, needs to be on top
|
|
|
|
this.initializeTitle();
|
|
|
|
}
|
2014-10-27 14:03:16 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Initializes the title elements.
|
|
|
|
*/
|
|
|
|
initializeTitle() {
|
|
|
|
this.$titlePara = $( '<p>' )
|
2023-06-17 06:34:08 +00:00
|
|
|
.addClass( 'mw-mmv-title-para mw-parser-output' )
|
2023-05-20 12:38:59 +00:00
|
|
|
.appendTo( this.$aboveFold );
|
2014-10-27 14:03:16 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$title = $( '<span>' )
|
|
|
|
.addClass( 'mw-mmv-title' );
|
2014-07-03 19:12:59 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.title = new TruncatableTextField( this.$titlePara, this.$title, {
|
|
|
|
styles: [ 'mw-mmv-title-small', 'mw-mmv-title-smaller' ]
|
|
|
|
} );
|
|
|
|
this.title.setTitle(
|
|
|
|
mw.message( 'multimediaviewer-title-popup-text' ),
|
|
|
|
mw.message( 'multimediaviewer-title-popup-text-more' )
|
|
|
|
);
|
2014-03-27 06:05:47 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$title.add( this.title.$ellipsis );
|
|
|
|
}
|
2014-07-03 19:12:59 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
initializeButtons() {
|
|
|
|
this.buttons = new StripeButtons( this.$titleDiv );
|
|
|
|
}
|
2014-10-29 19:50:53 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Initializes the main body of metadata elements.
|
|
|
|
*/
|
|
|
|
initializeImageMetadata() {
|
|
|
|
this.$container.addClass( 'mw-mmv-ttf-ellipsis-container' );
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$imageMetadata = $( '<div>' )
|
|
|
|
.addClass( 'mw-mmv-image-metadata' )
|
|
|
|
.appendTo( this.$container );
|
2014-10-27 14:03:16 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$imageMetadataLeft = $( '<div>' )
|
|
|
|
.addClass( 'mw-mmv-image-metadata-column mw-mmv-image-metadata-desc-column' )
|
|
|
|
.appendTo( this.$imageMetadata );
|
2014-10-27 14:03:16 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$imageMetadataRight = $( '<div>' )
|
|
|
|
.addClass( 'mw-mmv-image-metadata-column mw-mmv-image-metadata-links-column' )
|
|
|
|
.appendTo( this.$imageMetadata );
|
2014-10-27 14:03:16 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.initializeCredit();
|
|
|
|
this.description = new Description( this.$imageMetadataLeft );
|
|
|
|
this.permission = new Permission( this.$imageMetadataLeft, this.scroller );
|
|
|
|
this.initializeImageLinks();
|
|
|
|
}
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Initializes the credit elements.
|
|
|
|
*/
|
|
|
|
initializeCredit() {
|
|
|
|
this.$credit = $( '<p>' )
|
|
|
|
.addClass( 'mw-mmv-credit empty' )
|
|
|
|
.appendTo( this.$imageMetadataLeft );
|
|
|
|
|
|
|
|
// we need an inline container for tipsy, otherwise it would be centered weirdly
|
|
|
|
this.$authorAndSource = $( '<span>' )
|
|
|
|
.addClass( 'mw-mmv-source-author' );
|
|
|
|
|
|
|
|
this.creditField = new TruncatableTextField(
|
|
|
|
this.$credit,
|
|
|
|
this.$authorAndSource,
|
|
|
|
{ styles: [] }
|
|
|
|
);
|
2015-01-13 02:51:46 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.creditField.setTitle(
|
|
|
|
mw.message( 'multimediaviewer-credit-popup-text' ),
|
|
|
|
mw.message( 'multimediaviewer-credit-popup-text-more' )
|
|
|
|
);
|
2015-01-13 02:51:46 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$authorAndSource.add( this.creditField.$ellipsis );
|
|
|
|
}
|
2015-01-13 02:51:46 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Initializes the list of image metadata on the right side of the panel.
|
|
|
|
*/
|
|
|
|
initializeImageLinks() {
|
|
|
|
this.$imageLinkDiv = $( '<div>' )
|
|
|
|
.addClass( 'mw-mmv-image-links-div' )
|
|
|
|
.appendTo( this.$imageMetadataRight );
|
|
|
|
|
|
|
|
this.$imageLinks = $( '<ul>' )
|
|
|
|
.addClass( 'mw-mmv-image-links' )
|
|
|
|
.appendTo( this.$imageLinkDiv );
|
|
|
|
|
|
|
|
this.initializeLicense();
|
|
|
|
this.initializeFilename();
|
|
|
|
this.initializeDatetime();
|
|
|
|
this.initializeLocation();
|
|
|
|
}
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Initializes the license elements.
|
|
|
|
*/
|
|
|
|
initializeLicense() {
|
|
|
|
this.$licenseLi = $( '<li>' )
|
|
|
|
.addClass( 'mw-mmv-license-li empty' )
|
|
|
|
.appendTo( this.$imageLinks );
|
|
|
|
|
|
|
|
this.$license = $( '<a>' )
|
|
|
|
.addClass( 'mw-mmv-license' )
|
|
|
|
.prop( 'href', '#' )
|
|
|
|
.appendTo( this.$licenseLi );
|
|
|
|
|
|
|
|
this.$restrictions = $( '<span>' )
|
|
|
|
.addClass( 'mw-mmv-restrictions' )
|
|
|
|
.appendTo( this.$licenseLi );
|
|
|
|
|
|
|
|
this.$permissionLink = $( '<span>' )
|
|
|
|
.addClass( 'mw-mmv-permission-link mw-mmv-label' )
|
|
|
|
.text( mw.message( 'multimediaviewer-permission-link' ).text() )
|
|
|
|
.appendTo( this.$licenseLi )
|
|
|
|
.hide()
|
|
|
|
.on( 'click', () => {
|
|
|
|
if ( this.permission.isFullSize() ) {
|
|
|
|
this.permission.shrink();
|
|
|
|
} else {
|
|
|
|
this.permission.grow();
|
|
|
|
this.scroller.toggle( 'up' );
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
} );
|
|
|
|
}
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Initializes the filename element.
|
|
|
|
*/
|
|
|
|
initializeFilename() {
|
|
|
|
this.$filenameLi = $( '<li>' )
|
|
|
|
.addClass( 'mw-mmv-filename-li empty' )
|
|
|
|
.appendTo( this.$imageLinks );
|
|
|
|
|
|
|
|
this.$filenamePrefix = $( '<span>' )
|
|
|
|
.addClass( 'mw-mmv-filename-prefix' )
|
|
|
|
.appendTo( this.$filenameLi );
|
|
|
|
|
|
|
|
this.$filename = $( '<span>' )
|
|
|
|
.addClass( 'mw-mmv-filename' )
|
|
|
|
.appendTo( this.$filenameLi );
|
|
|
|
}
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Initializes the upload date/time element.
|
|
|
|
*/
|
|
|
|
initializeDatetime() {
|
2024-02-07 17:34:34 +00:00
|
|
|
this.$datetimeCreatedLi = $( '<li>' )
|
2023-05-20 12:38:59 +00:00
|
|
|
.addClass( 'mw-mmv-datetime-li empty' )
|
|
|
|
.appendTo( this.$imageLinks );
|
|
|
|
|
2024-02-07 17:34:34 +00:00
|
|
|
this.$datetimeCreated = $( '<span>' )
|
2023-05-20 12:38:59 +00:00
|
|
|
.addClass( 'mw-mmv-datetime' )
|
2024-02-07 17:34:34 +00:00
|
|
|
.appendTo( this.$datetimeCreatedLi );
|
|
|
|
|
|
|
|
this.$datetimeUpdatedLi = $( '<li>' )
|
|
|
|
.addClass( 'mw-mmv-datetime-li empty' )
|
|
|
|
.appendTo( this.$imageLinks );
|
|
|
|
|
|
|
|
this.$datetimeUpdated = $( '<span>' )
|
|
|
|
.addClass( 'mw-mmv-datetime' )
|
|
|
|
.appendTo( this.$datetimeUpdatedLi );
|
2023-05-20 12:38:59 +00:00
|
|
|
}
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Initializes the geolocation element.
|
|
|
|
*/
|
|
|
|
initializeLocation() {
|
|
|
|
this.$locationLi = $( '<li>' )
|
|
|
|
.addClass( 'mw-mmv-location-li empty' )
|
|
|
|
.appendTo( this.$imageLinks );
|
|
|
|
|
|
|
|
this.$location = $( '<a>' )
|
|
|
|
.addClass( 'mw-mmv-location' )
|
|
|
|
.appendTo( this.$locationLi );
|
|
|
|
}
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Initializes two about links at the bottom of the panel.
|
|
|
|
*/
|
|
|
|
initializeAboutLinks() {
|
|
|
|
this.$mmvAboutLink = $( '<a>' )
|
|
|
|
.prop( 'href', mw.config.get( 'wgMultimediaViewer' ).infoLink )
|
|
|
|
.text( mw.message( 'multimediaviewer-about-mmv' ).text() )
|
|
|
|
.addClass( 'mw-mmv-about-link' );
|
|
|
|
|
|
|
|
this.$mmvAboutLinks = $( '<div>' )
|
|
|
|
.addClass( 'mw-mmv-about-links' )
|
|
|
|
.append(
|
|
|
|
this.$mmvAboutLink
|
|
|
|
)
|
|
|
|
.appendTo( this.$imageMetadata );
|
|
|
|
}
|
2024-02-13 00:44:51 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/* Setters */
|
|
|
|
/**
|
|
|
|
* Sets the image title at the top of the metadata panel.
|
|
|
|
* The title will be the first one available form the options below:
|
|
|
|
* - the image caption
|
|
|
|
* - the description from the filepage
|
|
|
|
* - the filename (without extension)
|
|
|
|
*
|
|
|
|
* @param {LightboxImage} image
|
|
|
|
* @param {Image} imageData
|
|
|
|
*/
|
|
|
|
setTitle( image, imageData ) {
|
|
|
|
let title;
|
|
|
|
|
|
|
|
if ( image.caption ) {
|
|
|
|
title = image.caption;
|
|
|
|
} else if ( imageData.description ) {
|
|
|
|
title = imageData.description;
|
|
|
|
} else {
|
|
|
|
title = image.filePageTitle.getNameText();
|
|
|
|
}
|
2014-10-29 14:46:30 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.title.set( title );
|
2014-10-29 14:46:30 +00:00
|
|
|
}
|
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Sets the file name in the panel.
|
|
|
|
*
|
|
|
|
* @param {string} filename The file name to set, without prefix
|
|
|
|
*/
|
|
|
|
setFileName( filename ) {
|
|
|
|
this.$filenamePrefix.text( 'File:' );
|
|
|
|
this.$filename.text( filename );
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$filenameLi.removeClass( 'empty' );
|
|
|
|
}
|
2015-01-13 02:51:46 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Set source and author.
|
|
|
|
*
|
|
|
|
* @param {string} attribution Custom attribution string
|
|
|
|
* @param {string} source With unsafe HTML
|
|
|
|
* @param {string} author With unsafe HTML
|
|
|
|
* @param {number} authorCount
|
|
|
|
* @param {string} filepageUrl URL of the file page (used when other data is not available)
|
|
|
|
*/
|
|
|
|
setCredit( attribution, source, author, authorCount, filepageUrl ) {
|
|
|
|
// sanitization will be done by TruncatableTextField.set()
|
|
|
|
if ( attribution && ( authorCount <= 1 || !authorCount ) ) {
|
|
|
|
this.creditField.set( this.wrapAttribution( attribution ) );
|
|
|
|
} else if ( author && source ) {
|
|
|
|
this.creditField.set(
|
|
|
|
mw.message(
|
|
|
|
'multimediaviewer-credit',
|
|
|
|
this.wrapAuthor( author, authorCount, filepageUrl ),
|
|
|
|
this.wrapSource( source )
|
|
|
|
).plain()
|
|
|
|
);
|
|
|
|
} else if ( author ) {
|
|
|
|
this.creditField.set( this.wrapAuthor( author, authorCount, filepageUrl ) );
|
|
|
|
} else if ( source ) {
|
|
|
|
this.creditField.set( this.wrapSource( source ) );
|
|
|
|
} else {
|
|
|
|
this.creditField.set(
|
|
|
|
$( '<a>' )
|
|
|
|
.addClass( 'mw-mmv-credit-fallback' )
|
|
|
|
.prop( 'href', filepageUrl )
|
|
|
|
.text( mw.message( 'multimediaviewer-credit-fallback' ).plain() )
|
|
|
|
.get( 0 ).outerHTML
|
|
|
|
);
|
|
|
|
}
|
2015-01-13 02:51:46 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$credit.removeClass( 'empty' );
|
2014-03-27 06:05:47 +00:00
|
|
|
}
|
2014-05-31 00:18:12 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Wraps a source string it with MediaViewer styles
|
|
|
|
*
|
|
|
|
* @param {string} source Warning - unsafe HTML sometimes goes here
|
|
|
|
* @return {string} unsafe HTML
|
|
|
|
*/
|
|
|
|
wrapSource( source ) {
|
|
|
|
return $( '<span>' )
|
|
|
|
.addClass( 'mw-mmv-source' )
|
|
|
|
.append( $.parseHTML( source ) )
|
|
|
|
.get( 0 ).outerHTML;
|
|
|
|
}
|
2014-03-27 06:05:47 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Wraps an author string with MediaViewer styles
|
|
|
|
*
|
|
|
|
* @param {string} author Warning - unsafe HTML sometimes goes here
|
|
|
|
* @param {number} authorCount
|
|
|
|
* @param {string} filepageUrl URL of the file page (used when some author data is not available)
|
|
|
|
* @return {string} unsafe HTML
|
|
|
|
*/
|
|
|
|
wrapAuthor( author, authorCount, filepageUrl ) {
|
|
|
|
const $wrapper = $( '<span>' )
|
|
|
|
.addClass( 'mw-mmv-author' );
|
|
|
|
|
|
|
|
if ( authorCount > 1 ) {
|
|
|
|
const moreText = this.htmlUtils.jqueryToHtml(
|
|
|
|
$( '<a>' )
|
|
|
|
.addClass( 'mw-mmv-more-authors' )
|
|
|
|
.text( mw.message( 'multimediaviewer-multiple-authors', authorCount - 1 ).text() )
|
|
|
|
.attr( 'href', filepageUrl )
|
|
|
|
);
|
|
|
|
$wrapper.append( mw.message( 'multimediaviewer-multiple-authors-combine', author, moreText ).text() );
|
|
|
|
} else {
|
|
|
|
$wrapper.append( author );
|
|
|
|
}
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
return $wrapper.get( 0 ).outerHTML;
|
2014-11-27 07:19:24 +00:00
|
|
|
}
|
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Wraps an attribution string with MediaViewer styles
|
|
|
|
*
|
|
|
|
* @param {string} attribution Warning - unsafe HTML sometimes goes here
|
|
|
|
* @return {string} unsafe HTML
|
|
|
|
*/
|
|
|
|
wrapAttribution( attribution ) {
|
|
|
|
return $( '<span>' )
|
|
|
|
.addClass( 'mw-mmv-author' )
|
|
|
|
.addClass( 'mw-mmv-source' )
|
|
|
|
.append( $.parseHTML( attribution ) )
|
|
|
|
.get( 0 ).outerHTML;
|
|
|
|
}
|
2014-12-28 21:04:22 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Sets the license display in the panel
|
|
|
|
*
|
|
|
|
* @param {License|null} license license data (could be missing)
|
|
|
|
* @param {string} filePageUrl URL of the file description page
|
|
|
|
*/
|
|
|
|
setLicense( license, filePageUrl ) {
|
|
|
|
let shortName;
|
|
|
|
let url;
|
|
|
|
let isCc;
|
|
|
|
let isPd;
|
|
|
|
|
2024-02-13 00:44:51 +00:00
|
|
|
filePageUrl += `?uselang=${ mw.config.get( 'wgUserLanguage' ) }#${ mw.message( 'license-header' ).text() }`;
|
2023-05-20 12:38:59 +00:00
|
|
|
|
|
|
|
if ( license ) {
|
|
|
|
shortName = license.getShortName();
|
|
|
|
url = license.deedUrl || filePageUrl;
|
|
|
|
isCc = license.isCc();
|
|
|
|
isPd = license.isPd();
|
|
|
|
} else {
|
|
|
|
shortName = mw.message( 'multimediaviewer-license-default' ).text();
|
|
|
|
url = filePageUrl;
|
|
|
|
isCc = isPd = false;
|
|
|
|
}
|
2014-04-19 00:25:12 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$license
|
|
|
|
.text( shortName )
|
|
|
|
.prop( 'href', url )
|
|
|
|
.prop( 'target', license && license.deedUrl ? '_blank' : '' );
|
2023-05-19 13:06:18 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$licenseLi
|
|
|
|
.toggleClass( 'cc-license', isCc )
|
|
|
|
.toggleClass( 'pd-license', isPd )
|
|
|
|
.removeClass( 'empty' );
|
2014-04-19 00:25:12 +00:00
|
|
|
}
|
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Set an extra permission text which should be displayed.
|
|
|
|
*
|
|
|
|
* @param {string} permission
|
|
|
|
*/
|
|
|
|
setPermission( permission ) {
|
|
|
|
this.$permissionLink.show();
|
|
|
|
this.permission.set( permission );
|
|
|
|
}
|
2014-02-14 00:36:10 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Sets any special restrictions that should be displayed.
|
|
|
|
*
|
|
|
|
* @param {string[]} restrictions Array of restrictions
|
|
|
|
*/
|
|
|
|
setRestrictions( restrictions ) {
|
|
|
|
const restrictionsSet = {};
|
|
|
|
let showDefault = false;
|
|
|
|
let validRestrictions = 0;
|
|
|
|
|
|
|
|
restrictions.forEach( ( value, index ) => {
|
|
|
|
// The following messages are used here:
|
|
|
|
// * multimediaviewer-restriction-2257
|
|
|
|
// * multimediaviewer-restriction-aus-reserve
|
|
|
|
// * multimediaviewer-restriction-communist
|
|
|
|
// * multimediaviewer-restriction-costume
|
|
|
|
// * multimediaviewer-restriction-currency
|
|
|
|
// * multimediaviewer-restriction-design
|
|
|
|
// * multimediaviewer-restriction-fan-art
|
|
|
|
// * multimediaviewer-restriction-ihl
|
|
|
|
// * multimediaviewer-restriction-insignia
|
|
|
|
// * multimediaviewer-restriction-ita-mibac
|
|
|
|
// * multimediaviewer-restriction-nazi
|
|
|
|
// * multimediaviewer-restriction-personality
|
|
|
|
// * multimediaviewer-restriction-trademarked
|
|
|
|
// * multimediaviewer-restriction-default
|
|
|
|
// * multimediaviewer-restriction-default-and-others
|
2024-02-13 00:44:51 +00:00
|
|
|
if ( !mw.message( `multimediaviewer-restriction-${ value }` ).exists() || value === 'default' || index + 1 > MetadataPanel.MAX_RESTRICT ) {
|
2023-05-20 12:38:59 +00:00
|
|
|
showDefault = true; // If the restriction isn't defined or there are more than MAX_RESTRICT of them, show a generic symbol at the end
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( restrictionsSet[ value ] ) {
|
|
|
|
return; // Only show one of each symbol
|
|
|
|
} else {
|
|
|
|
restrictionsSet[ value ] = true;
|
|
|
|
}
|
2015-06-20 05:03:28 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$restrictions.append( this.createRestriction( value ) );
|
|
|
|
validRestrictions++; // See how many defined restrictions are added so we know which default i18n msg to use
|
|
|
|
} );
|
2015-06-20 05:03:28 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
if ( showDefault ) {
|
|
|
|
if ( validRestrictions ) {
|
|
|
|
this.$restrictions.append( this.createRestriction( 'default-and-others' ) );
|
|
|
|
} else {
|
|
|
|
this.$restrictions.append( this.createRestriction( 'default' ) );
|
|
|
|
}
|
2015-06-20 05:03:28 +00:00
|
|
|
}
|
2015-01-15 03:14:20 +00:00
|
|
|
}
|
2015-06-20 05:03:28 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Helper function that generates restriction labels
|
|
|
|
*
|
|
|
|
* @param {string} type Restriction type
|
|
|
|
* @return {jQuery} jQuery object of label
|
|
|
|
*/
|
|
|
|
createRestriction( type ) {
|
|
|
|
const $label = $( '<span>' )
|
|
|
|
.addClass( 'mw-mmv-label mw-mmv-restriction-label' )
|
|
|
|
// Messages duplicated from above for linter
|
|
|
|
// * multimediaviewer-restriction-2257
|
|
|
|
// * multimediaviewer-restriction-aus-reserve
|
|
|
|
// * multimediaviewer-restriction-communist
|
|
|
|
// * multimediaviewer-restriction-costume
|
|
|
|
// * multimediaviewer-restriction-currency
|
|
|
|
// * multimediaviewer-restriction-design
|
|
|
|
// * multimediaviewer-restriction-fan-art
|
|
|
|
// * multimediaviewer-restriction-ihl
|
|
|
|
// * multimediaviewer-restriction-insignia
|
|
|
|
// * multimediaviewer-restriction-ita-mibac
|
|
|
|
// * multimediaviewer-restriction-nazi
|
|
|
|
// * multimediaviewer-restriction-personality
|
|
|
|
// * multimediaviewer-restriction-trademarked
|
|
|
|
// * multimediaviewer-restriction-default
|
|
|
|
// * multimediaviewer-restriction-default-and-others
|
2024-02-13 00:44:51 +00:00
|
|
|
.prop( 'title', mw.message( `multimediaviewer-restriction-${ type }` ).text() );
|
2023-05-20 12:38:59 +00:00
|
|
|
|
|
|
|
$( '<span>' )
|
|
|
|
// The following classes are used here:
|
|
|
|
// * mw-mmv-restriction-2257
|
|
|
|
// * mw-mmv-restriction-aus-reserve
|
|
|
|
// * mw-mmv-restriction-communist
|
|
|
|
// * mw-mmv-restriction-costume
|
|
|
|
// * mw-mmv-restriction-currency
|
|
|
|
// * mw-mmv-restriction-design
|
|
|
|
// * mw-mmv-restriction-fan-art
|
|
|
|
// * mw-mmv-restriction-ihl
|
|
|
|
// * mw-mmv-restriction-insignia
|
|
|
|
// * mw-mmv-restriction-ita-mibac
|
|
|
|
// * mw-mmv-restriction-nazi
|
|
|
|
// * mw-mmv-restriction-personality
|
|
|
|
// * mw-mmv-restriction-trademarked:after
|
|
|
|
// * mw-mmv-restriction-default
|
2024-02-13 00:44:51 +00:00
|
|
|
.addClass( `mw-mmv-restriction-label-inner mw-mmv-restriction-${ type === 'default-and-others' ? 'default' : type }` )
|
|
|
|
.text( mw.message( `multimediaviewer-restriction-${ type }` ).text() )
|
2023-05-20 12:38:59 +00:00
|
|
|
.appendTo( $label );
|
|
|
|
|
|
|
|
return $label;
|
|
|
|
}
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Sets location data in the interface.
|
|
|
|
*
|
|
|
|
* @param {Image} imageData
|
|
|
|
*/
|
|
|
|
setLocationData( imageData ) {
|
|
|
|
if ( !imageData.hasCoords() ) {
|
|
|
|
return;
|
|
|
|
}
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
const latitude = imageData.latitude >= 0 ? imageData.latitude : imageData.latitude * -1;
|
2024-02-13 00:44:51 +00:00
|
|
|
const latmsg = `multimediaviewer-geoloc-${ imageData.latitude >= 0 ? 'north' : 'south' }`;
|
2023-05-20 12:38:59 +00:00
|
|
|
const latdeg = Math.floor( latitude );
|
|
|
|
let latremain = latitude - latdeg;
|
|
|
|
const latmin = Math.floor( ( latremain ) * 60 );
|
|
|
|
|
|
|
|
const longitude = imageData.longitude >= 0 ? imageData.longitude : imageData.longitude * -1;
|
2024-02-13 00:44:51 +00:00
|
|
|
const longmsg = `multimediaviewer-geoloc-${ imageData.longitude >= 0 ? 'east' : 'west' }`;
|
2023-05-20 12:38:59 +00:00
|
|
|
const longdeg = Math.floor( longitude );
|
|
|
|
let longremain = longitude - longdeg;
|
|
|
|
const longmin = Math.floor( ( longremain ) * 60 );
|
|
|
|
|
|
|
|
longremain -= longmin / 60;
|
|
|
|
latremain -= latmin / 60;
|
|
|
|
const latsec = Math.round( latremain * 100 * 60 * 60 ) / 100;
|
|
|
|
const longsec = Math.round( longremain * 100 * 60 * 60 ) / 100;
|
|
|
|
|
|
|
|
this.$location.text(
|
|
|
|
mw.message( 'multimediaviewer-geolocation',
|
2014-02-07 14:47:00 +00:00
|
|
|
mw.message(
|
2023-05-20 12:38:59 +00:00
|
|
|
'multimediaviewer-geoloc-coords',
|
|
|
|
|
|
|
|
mw.message(
|
|
|
|
'multimediaviewer-geoloc-coord',
|
|
|
|
mw.language.convertNumber( latdeg ),
|
|
|
|
mw.language.convertNumber( latmin ),
|
|
|
|
mw.language.convertNumber( latsec ),
|
|
|
|
// The following messages are used here:
|
|
|
|
// * multimediaviewer-geoloc-north
|
|
|
|
// * multimediaviewer-geoloc-south
|
|
|
|
mw.message( latmsg ).text()
|
|
|
|
).text(),
|
|
|
|
|
|
|
|
mw.message(
|
|
|
|
'multimediaviewer-geoloc-coord',
|
|
|
|
mw.language.convertNumber( longdeg ),
|
|
|
|
mw.language.convertNumber( longmin ),
|
|
|
|
mw.language.convertNumber( longsec ),
|
|
|
|
// The following messages are used here:
|
|
|
|
// * multimediaviewer-geoloc-east
|
|
|
|
// * multimediaviewer-geoloc-west
|
|
|
|
mw.message( longmsg ).text()
|
|
|
|
).text()
|
2014-02-07 14:47:00 +00:00
|
|
|
).text()
|
|
|
|
).text()
|
2023-05-20 12:38:59 +00:00
|
|
|
);
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$location.prop( 'href', (
|
|
|
|
'https://geohack.toolforge.org/geohack.php?pagename=' +
|
2024-02-13 00:44:51 +00:00
|
|
|
`File:${ imageData.title.getMain()
|
2023-05-20 12:38:59 +00:00
|
|
|
}¶ms=${
|
2024-02-13 00:44:51 +00:00
|
|
|
Math.abs( imageData.latitude ) }${ imageData.latitude >= 0 ? '_N_' : '_S_'
|
|
|
|
}${ Math.abs( imageData.longitude ) }${ imageData.longitude >= 0 ? '_E_' : '_W_'
|
|
|
|
}&language=${ encodeURIComponent( mw.config.get( 'wgUserLanguage' ) ) }`
|
2023-05-20 12:38:59 +00:00
|
|
|
) );
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$locationLi.removeClass( 'empty' );
|
|
|
|
}
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Set all the image information in the panel
|
|
|
|
*
|
|
|
|
* @param {LightboxImage} image
|
|
|
|
* @param {Image} imageData
|
|
|
|
* @param {Repo} repoData
|
|
|
|
*/
|
|
|
|
setImageInfo( image, imageData, repoData ) {
|
|
|
|
if ( imageData.creationDateTime ) {
|
2024-02-07 17:34:34 +00:00
|
|
|
this.$datetimeCreated.text(
|
|
|
|
mw.message( 'multimediaviewer-datetime-created', this.formatDate( imageData.creationDateTime ) ).text()
|
|
|
|
);
|
|
|
|
this.$datetimeCreatedLi.removeClass( 'empty' );
|
|
|
|
}
|
|
|
|
if ( imageData.uploadDateTime ) {
|
|
|
|
this.$datetimeUpdated.text(
|
|
|
|
mw.message( 'multimediaviewer-datetime-uploaded', this.formatDate( imageData.uploadDateTime ) ).text()
|
|
|
|
);
|
|
|
|
this.$datetimeUpdatedLi.removeClass( 'empty' );
|
2023-05-20 12:38:59 +00:00
|
|
|
}
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.buttons.set( imageData, repoData );
|
|
|
|
this.description.set( imageData.description, image.caption );
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.setLicense( imageData.license, imageData.descriptionUrl );
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.setFileName( imageData.title.getMainText() );
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
// these handle text truncation and should be called when everything that can push text down
|
|
|
|
// (e.g. floated buttons) has already been laid out
|
|
|
|
this.setTitle( image, imageData );
|
|
|
|
this.setCredit( imageData.attribution, imageData.source, imageData.author, imageData.authorCount, imageData.descriptionUrl );
|
2015-01-13 02:51:46 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
if ( imageData.permission ) {
|
|
|
|
this.setPermission( imageData.permission );
|
|
|
|
}
|
2014-10-29 19:50:53 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
if ( imageData.restrictions ) {
|
|
|
|
this.setRestrictions( imageData.restrictions );
|
|
|
|
}
|
2014-02-14 00:36:10 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.setLocationData( imageData );
|
2015-01-15 03:14:20 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
this.resetTruncatedText();
|
|
|
|
this.scroller.unfreezeHeight();
|
|
|
|
}
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Show an error message, in case the data could not be loaded
|
|
|
|
*
|
|
|
|
* @param {string} title image title
|
|
|
|
* @param {string} error error message
|
|
|
|
*/
|
|
|
|
showError( title, error ) {
|
|
|
|
this.$credit.text( mw.message( 'multimediaviewer-metadata-error', error ).text() );
|
|
|
|
this.$title.html( title );
|
|
|
|
}
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Transforms a date string into localized, human-readable format.
|
|
|
|
* Unrecognized strings are returned unchanged.
|
|
|
|
*
|
|
|
|
* @param {string} dateString
|
|
|
|
* @return {string} formatted date
|
|
|
|
*/
|
|
|
|
formatDate( dateString ) {
|
|
|
|
let lang = mw.config.get( 'wgUserLanguage' );
|
|
|
|
if ( lang === 'en' || lang === 'qqx' ) {
|
|
|
|
// prefer "D MMMM YYYY" format
|
|
|
|
// avoid passing invalid "qqx" to native toLocaleString(),
|
|
|
|
// which would cause developer's browser locale to be used,
|
|
|
|
// and thus sometimes cause tests to fail.
|
|
|
|
lang = 'en-GB';
|
|
|
|
}
|
2024-01-24 18:17:28 +00:00
|
|
|
if ( dateString.length === 4 ) {
|
|
|
|
// assume yyyy
|
|
|
|
return dateString;
|
|
|
|
}
|
2023-05-20 12:38:59 +00:00
|
|
|
const date = new Date( dateString );
|
|
|
|
try {
|
|
|
|
if ( date instanceof Date && !isNaN( date ) ) {
|
|
|
|
return date.toLocaleString( lang, {
|
|
|
|
day: 'numeric',
|
|
|
|
month: 'long',
|
|
|
|
year: 'numeric',
|
|
|
|
timeZone: 'UTC'
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
} catch ( ignore ) { }
|
|
|
|
// fallback to original date string
|
|
|
|
return dateString;
|
|
|
|
}
|
2014-03-01 01:10:51 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Shows truncated text in the title and credit (this also rearranges the layout a bit).
|
|
|
|
*/
|
|
|
|
revealTruncatedText() {
|
|
|
|
if ( this.$container.hasClass( 'mw-mmv-untruncated' ) ) {
|
|
|
|
return;
|
2014-04-11 14:58:37 +00:00
|
|
|
}
|
2023-05-20 12:38:59 +00:00
|
|
|
this.$container.addClass( 'mw-mmv-untruncated' );
|
|
|
|
this.title.grow();
|
|
|
|
this.creditField.grow();
|
|
|
|
}
|
2014-02-07 14:47:00 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Undoes changes made by revealTruncatedText().
|
|
|
|
*/
|
|
|
|
hideTruncatedText() {
|
|
|
|
if ( !this.$container.hasClass( 'mw-mmv-untruncated' ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.title.shrink();
|
|
|
|
this.creditField.shrink();
|
|
|
|
this.$container.removeClass( 'mw-mmv-untruncated' );
|
2014-07-16 23:15:38 +00:00
|
|
|
}
|
2014-07-03 19:12:59 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/**
|
|
|
|
* Hide or reveal truncated text based on whether the panel is open. This is normally handled by
|
|
|
|
* MetadataPanelScroller, but when the panel is reset (e.g. on a prev/next event) sometimes the panel position can change without a panel , such as on a
|
|
|
|
* prev/next event; in such cases this function has to be called.
|
|
|
|
*/
|
|
|
|
resetTruncatedText() {
|
|
|
|
if ( this.scroller.panelIsOpen() ) {
|
|
|
|
this.revealTruncatedText();
|
|
|
|
} else {
|
|
|
|
this.hideTruncatedText();
|
|
|
|
}
|
2014-07-16 23:15:38 +00:00
|
|
|
}
|
2023-05-20 12:38:59 +00:00
|
|
|
}
|
2014-07-03 19:12:59 +00:00
|
|
|
|
|
|
|
/**
|
2023-05-20 12:38:59 +00:00
|
|
|
* Maximum number of restriction icons before default icon is used
|
|
|
|
*
|
|
|
|
* @property {number} MAX_RESTRICT
|
|
|
|
* @static
|
2014-07-03 19:12:59 +00:00
|
|
|
*/
|
2023-05-20 12:38:59 +00:00
|
|
|
MetadataPanel.MAX_RESTRICT = 4;
|
2014-07-03 19:12:59 +00:00
|
|
|
|
2023-05-19 20:26:45 +00:00
|
|
|
module.exports = MetadataPanel;
|
2018-11-12 16:33:24 +00:00
|
|
|
}() );
|