' )
.addClass( 'mw-mlb-mmv-about-links' )
.append(
this.$mmvAboutLink,
' | ',
this.$mmvDiscussLink
)
.appendTo( this.$imageMetadata );
};
LIP.initializeNavigation = function () {
this.handleKeyDown = this.handleKeyDown || function ( e ) {
var isRtl = $( document.body ).hasClass( 'rtl' );
switch ( e.keyCode ) {
case 37:
// Left arrow
if ( isRtl ) {
mw.mediaViewer.nextImage();
} else {
mw.mediaViewer.prevImage();
}
break;
case 39:
// Right arrow
if ( isRtl ) {
mw.mediaViewer.prevImage();
} else {
mw.mediaViewer.nextImage();
}
break;
}
};
this.$nextButton = $( '
' )
.addClass( 'mw-mlb-next-image disabled' )
.html( ' ' )
.click( function () {
mw.mediaViewer.nextImage();
} );
this.$prevButton = $( '
' )
.addClass( 'mw-mlb-prev-image disabled' )
.html( ' ' )
.click( function () {
mw.mediaViewer.prevImage();
} );
};
LIP.toggleMetadata = function () {
var scrollTopWhenOpen = $( '.mlb-post-image' ).height() - $( '.mlb-controls' ).height(),
scrollTopTarget = $.scrollTo().scrollTop() > 0 ? 0 : scrollTopWhenOpen;
$.scrollTo( scrollTopTarget, 400 );
};
/**
* @method
* Sets the display name of the repository
* @param {string} displayname
* @param {string} favIcon
* @param {boolean} isLocal true if this is the local repo ( the file has been uploaded locally)
*/
LIP.setRepoDisplay = function ( displayname, favIcon, isLocal ) {
if ( isLocal ) {
this.$repo.text(
mw.message( 'multimediaviewer-repository-local' ).text()
);
} else {
displayname = displayname || mw.config.get( 'wgSiteName' );
this.$repo.text(
mw.message( 'multimediaviewer-repository', displayname ).text()
);
}
// This horror exists because the CSS uses a :before pseudo-class to
// define the repo icon. This is the only way to override it.
if ( favIcon ) {
if ( !this.$repoLiInlineStyle ) {
this.$repoLiInlineStyle = $( '' ).appendTo( 'head' );
}
this.$repoLiInlineStyle.html( '.mw-mlb-image-links li.mw-mlb-repo-li:before '
+ '{ background-image: url("'
+ favIcon
+ '"); }'
);
} else if ( this.$repoLiInlineStyle ) {
this.$repoLiInlineStyle.html( '' );
}
};
/**
* @method
* Sets the URL for the File: page of the image
* @param {string} url
*/
LIP.setFilePageLink = function ( url ) {
this.$repo.prop( 'href', url );
this.$license.prop( 'href', url );
};
/**
* @method
* Sets the image location data in the interface.
* @param {number} latdeg Number of degrees in latitude
* @param {number} latmin Number of minutes in latitude
* @param {number} latsec Number of seconds, rounded to two places, in latitude
* @param {number} latmsg The message representing the cardinal direction of the latitude
* @param {number} longdeg Number of degrees in longitude
* @param {number} longmin Number of minutes in longitude
* @param {number} longsec Number of seconds, rounded to two places, in longitude
* @param {number} longmsg The message representing the cardinal direction of the longitude
* @param {number} latitude The initial, decimal latitude
* @param {number} longitude The initial, decimal longitude
* @param {string} langcode Code for the language being used - like 'en', 'zh', or 'en-gb'
* @param {string} titleText Title of the file
*/
LIP.setLocationData = function (
latdeg, latmin, latsec, latmsg,
longdeg, longmin, longsec, longmsg,
latitude, longitude, langcode, titleText
) {
this.$location.text(
mw.message(
'multimediaviewer-geoloc-coords',
mw.message(
'multimediaviewer-geoloc-coord',
mw.language.convertNumber( latdeg ),
mw.language.convertNumber( latmin ),
mw.language.convertNumber( latsec ),
mw.message( latmsg ).text()
).text(),
mw.message(
'multimediaviewer-geoloc-coord',
mw.language.convertNumber( longdeg ),
mw.language.convertNumber( longmin ),
mw.language.convertNumber( longsec ),
mw.message( longmsg ).text()
).text()
).text()
);
this.$location.prop( 'href', (
'//tools.wmflabs.org/geohack/geohack.php?pagename=' +
'File:' + titleText +
'¶ms=' +
latitude + '_N_' +
longitude + '_E_' +
'&language=' + langcode
) );
};
/**
* @method
* Saves some data about the image on the $useFile element for later setup.
* @param {mw.Title} title
* @param {string} src The URL for the full-size image
* @param {boolean} isLocal Whether the file is on this wiki or not
*/
LIP.initUseFileData = function ( title, src, isLocal ) {
this.$useFile.data( 'title', title );
this.$useFile.data( 'src', src );
this.$useFile.data( 'isLocal', isLocal );
};
/**
* @method
* Sets the link to the user page where possible
* @param {mw.mmv.model.Repo} repoData
* @param {string} username
* @param {string} gender
*/
LIP.setUserPageLink = function ( repoData, username, gender ) {
var userlink,
userpage = 'User:' + username;
if ( repoData instanceof mw.mmv.model.ForeignDbRepo ) {
// We basically can't do anything about this; fail
this.$username.addClass( 'empty' );
} else {
if ( repoData.absoluteArticlePath ) {
userlink = repoData.absoluteArticlePath;
} else {
userlink = mw.config.get( 'wgArticlePath' );
}
userlink = userlink.replace( '$1', userpage );
this.$username
.text(
mw.message( 'multimediaviewer-userpage-link', username, gender ).text()
)
.prop( 'href', userlink );
this.$usernameLi.toggleClass( 'empty', !username );
}
};
LIP.replaceImageWith = function ( imageEle ) {
var $image = $( imageEle );
this.currentImage.src = imageEle.src;
this.$image.replaceWith( $image );
this.$image = $image;
this.$image.css( {
maxHeight: $image.parent().height(),
maxWidth: $image.parent().width()
} );
};
mw.LightboxInterface = LightboxInterface;
}( mediaWiki, jQuery, OO, window.LightboxInterface ) );