mediawiki-extensions-Revisi.../modules/ext.RevisionSlider.RevisionList.js
Jakob Warkotsch 139368093e Adds the missing first revision to the slider.
The first revision was previously not included because revision size was
calculated by subtracting the size in bytes of a revision from the size
of the previous revision which lead to a problem with the first
revision. The first revision's relative size is now equal to its actual
size.

Bug: T135003
Change-Id: I71441ed33673b06407be0fc566c96c3955dddbf9
2016-05-12 15:25:37 +00:00

57 lines
1.1 KiB
JavaScript

( function ( mw, $ ) {
var RevisionList = function ( revs ) {
this.revisions = [];
this.initialize( revs );
this.view = new mw.libs.revisionSlider.RevisionListView( this );
};
$.extend( RevisionList.prototype, {
/**
* @type {Revision[]}
*/
revisions: [],
/**
* @type {RevisionListView}
*/
view: null,
initialize: function ( revs ) {
var i, rev;
for ( i = 0; i < revs.length; i++ ) {
rev = new mw.libs.revisionSlider.Revision( revs[ i ] );
rev.setRelativeSize( i > 0 ? revs[ i ].size - revs[ i - 1 ].size : revs[ i ].size );
this.revisions.push( rev );
}
},
getBiggestChangeSize: function () {
var max = 0,
i;
for ( i = 0; i < this.revisions.length; i++ ) {
max = Math.max( max, Math.abs( this.revisions[ i ].getRelativeSize() ) );
}
return max;
},
getRevisions: function () {
return this.revisions;
},
getLength: function () {
return this.revisions.length;
},
getView: function () {
return this.view;
}
} );
mw.libs.revisionSlider = mw.libs.revisionSlider || {};
mw.libs.revisionSlider.RevisionList = RevisionList;
}( mediaWiki, jQuery ) );