mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-11-24 07:23:41 +00:00
Cleanup minor code duplication/complication in various places
Change-Id: Icffe9551d633470ccec1b63ea570e138db48dee8
This commit is contained in:
parent
d85496a2a8
commit
3f0aae5e73
|
@ -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 );
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -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,
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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 ),
|
||||
|
|
Loading…
Reference in a new issue