mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-09-29 13:17:35 +00:00
Merge "Collect license handling code, remove unused data attribute"
This commit is contained in:
commit
9a54e155da
|
@ -251,15 +251,6 @@
|
|||
return this.thumbUrls[width];
|
||||
};
|
||||
|
||||
/**
|
||||
* Check whether the image is CC-licensed.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
IP.isCcLicensed = function () {
|
||||
return this.license && this.license.internalName &&
|
||||
this.license.internalName.substr( 0, 2 ) === 'cc';
|
||||
};
|
||||
|
||||
/**
|
||||
* Check whether the image has geolocation data.
|
||||
* @returns {boolean}
|
||||
|
|
|
@ -55,6 +55,14 @@
|
|||
}
|
||||
LP = License.prototype;
|
||||
|
||||
/**
|
||||
* Check whether this is a Creative Commons license.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
LP.isCc = function () {
|
||||
return this.internalName && this.internalName.substr( 0, 2 ) === 'cc';
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the short name of the license:
|
||||
* - if we have interface messages for this license (basically just CC and PD), use those
|
||||
|
|
|
@ -540,23 +540,25 @@
|
|||
this.setCredit( this.source, author );
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the license data in the DOM
|
||||
* @param {string} license The license this file has.
|
||||
*/
|
||||
MPP.setLicenseData = function ( license ) {
|
||||
this.$license.data( 'license', license );
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the license display in the panel
|
||||
* @param {string} license The human-readable name of the license
|
||||
* @param {string} url The URL to the license deed.
|
||||
* @param {boolean} isCc Whether this is a CC license
|
||||
* @param {mw.mmv.model.License|null} license license data (could be missing)
|
||||
* @param {string} filePageUrl URL of the file description page
|
||||
*/
|
||||
MPP.setLicense = function ( license, url, isCc ) {
|
||||
MPP.setLicense = function ( license, filePageUrl ) {
|
||||
var message, shortName, url, isCc;
|
||||
|
||||
message = 'multimediaviewer-license-' + ( license.internalName || '' );
|
||||
if ( mw.messages.exists( message ) ) {
|
||||
shortName = mw.message( message ).text();
|
||||
} else {
|
||||
shortName = mw.message( 'multimediaviewer-license-default' ).text();
|
||||
}
|
||||
url = license.deedUrl || filePageUrl;
|
||||
isCc = license.isCc();
|
||||
|
||||
this.$license
|
||||
.text( license )
|
||||
.text( shortName )
|
||||
.toggleClass( 'cc-license', isCc )
|
||||
.prop( 'href', url );
|
||||
|
||||
|
@ -654,8 +656,7 @@
|
|||
* @param {mw.mmv.model.User} user
|
||||
*/
|
||||
MPP.setImageInfo = function ( image, imageData, repoData, localUsage, globalUsage, user ) {
|
||||
var msgname,
|
||||
panel = this,
|
||||
var panel = this,
|
||||
fileTitle = image.filePageTitle;
|
||||
|
||||
this.setFileTitle( fileTitle.getNameText() );
|
||||
|
@ -690,22 +691,8 @@
|
|||
this.description.set( imageData.description, image.caption );
|
||||
this.categories.set( repoData.getArticlePath(), imageData.categories );
|
||||
|
||||
msgname = 'multimediaviewer-license-' + ( imageData.license && imageData.license.internalName || '' );
|
||||
|
||||
if ( !mw.messages.exists( msgname ) ) {
|
||||
// Cannot display, fallback or fail
|
||||
msgname = 'multimediaviewer-license-default';
|
||||
} else {
|
||||
// License found, store the license data
|
||||
this.setLicenseData( mw.message( msgname ).text() );
|
||||
}
|
||||
|
||||
if ( imageData.license ) {
|
||||
this.setLicense(
|
||||
mw.message( msgname ).text(),
|
||||
imageData.license.deedUrl || imageData.descriptionUrl,
|
||||
imageData.isCcLicensed()
|
||||
);
|
||||
this.setLicense( imageData.license, imageData.descriptionUrl );
|
||||
}
|
||||
|
||||
if ( imageData.permission ) {
|
||||
|
|
|
@ -161,7 +161,6 @@
|
|||
imageData.uploadDateTime = '2013-08-25T14:41:02Z';
|
||||
imageData.source = '<b>Lost</b><a href="foo">Bar</a>';
|
||||
imageData.author = 'Bob';
|
||||
imageData.isCcLicensed = function() { return true; };
|
||||
imageData.license = new mw.mmv.model.License( 'CC-BY-2.0', 'cc-by-2.0' );
|
||||
gender = 'female';
|
||||
imageData.lastUploader = 'Ursula';
|
||||
|
|
Loading…
Reference in a new issue