Cleanup minor code duplication/complication in various places

Change-Id: Icffe9551d633470ccec1b63ea570e138db48dee8
This commit is contained in:
thiemowmde 2023-10-24 16:08:50 +02:00 committed by WMDE-Fisch
parent d85496a2a8
commit 3f0aae5e73
4 changed files with 11 additions and 18 deletions

View file

@ -154,18 +154,20 @@ $.extend( PointerLine.prototype, {
/**
* Adds colored top-borders for the diff columns fitting the line colors between pointers and columns
*
* @param {boolean} [show=true]
*/
addColoredColumnBorders: function () {
$( '#mw-diff-otitle1' ).addClass( 'mw-revslider-older-diff-column' );
$( '#mw-diff-ntitle1' ).addClass( 'mw-revslider-newer-diff-column' );
addColoredColumnBorders: function ( show ) {
show = show !== false;
$( '#mw-diff-otitle1' ).toggleClass( 'mw-revslider-older-diff-column', show );
$( '#mw-diff-ntitle1' ).toggleClass( 'mw-revslider-newer-diff-column', show );
},
/**
* Remove colored top-borders for the diff columns fitting the line colors between pointers and columns
*/
removeColoredColumnBorders: function () {
$( '#mw-diff-otitle1' ).removeClass( 'mw-revslider-older-diff-column' );
$( '#mw-diff-ntitle1' ).removeClass( 'mw-revslider-newer-diff-column' );
this.addColoredColumnBorders( false );
},
/**

View file

@ -61,7 +61,7 @@ $.extend( Revision.prototype, {
userGender: '',
/**
* @type {number}
* @type {number} Warning, only set for Revision objects that are part of a RevisionList
*/
relativeSize: 0,

View file

@ -147,13 +147,11 @@ $.extend( RevisionList.prototype, {
* Transforms an array of revision data returned by MediaWiki API (including user gender information) into
* an array of Revision objects
*
* @param {Array} revs
* @param {Object[]} revs
* @return {Revision[]}
*/
function makeRevisions( revs ) {
return revs.map( function ( revData ) {
return new Revision( revData );
} );
return revs.map( ( data ) => new Revision( data ) );
}
module.exports = {

View file

@ -12,7 +12,6 @@ let expanded = autoExpand;
function initialize() {
const startTime = mw.now();
const api = new RevisionSliderApi( mw.util.wikiScript( 'api' ) );
let changeTags = [];
toggleButton.$element.children().attr( {
'aria-expanded': autoExpand,
@ -29,13 +28,7 @@ function initialize() {
HelpDialog.init();
api.fetchAvailableChangeTags().then( function ( data ) {
if ( typeof data === 'object' &&
data.query &&
data.query.tags &&
data.query.tags.length > 0
) {
changeTags = data.query.tags;
}
const changeTags = data && data.query && data.query.tags || [];
api.fetchRevisionData( mw.config.get( 'wgPageName' ), {
startId: Math.max( mw.config.get( 'wgDiffOldId' ), mw.config.get( 'wgDiffNewId' ) ),
limit: utils.calculateRevisionsPerWindow( 160, 16 ),