mediawiki-extensions-Revisi.../modules/ext.RevisionSlider.RevisionList.js
Jakob Warkotsch 11ceffab2f Enhance code documentation.
Bug: T137965
Change-Id: Ice393838545f1545ee085ecdcddfa35f60b32ecd
2016-06-21 13:25:50 +02:00

78 lines
1.4 KiB
JavaScript

( function ( mw, $ ) {
/**
* @param {Revision[]} revs
* @constructor
*/
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,
/**
* Inititializes the RevisionList from a list of Revisions
*
* @param {Revision[]} revs
*/
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 );
}
},
/**
* @return {number}
*/
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;
},
/**
* @return {Revision[]}
*/
getRevisions: function () {
return this.revisions;
},
/**
* @return {number}
*/
getLength: function () {
return this.revisions.length;
},
/**
* @return {RevisionListView}
*/
getView: function () {
return this.view;
}
} );
mw.libs.revisionSlider = mw.libs.revisionSlider || {};
mw.libs.revisionSlider.RevisionList = RevisionList;
}( mediaWiki, jQuery ) );