2016-05-10 12:42:05 +00:00
|
|
|
( function ( mw, $ ) {
|
|
|
|
var RevisionListView = function ( revisionList ) {
|
|
|
|
this.revisionList = revisionList;
|
|
|
|
};
|
|
|
|
|
|
|
|
$.extend( RevisionListView.prototype, {
|
|
|
|
/**
|
|
|
|
* @type {RevisionList}
|
|
|
|
*/
|
|
|
|
revisionList: null,
|
|
|
|
|
2016-05-12 11:34:16 +00:00
|
|
|
render: function ( revisionTickWidth ) {
|
2016-05-10 12:42:05 +00:00
|
|
|
var $html = $( '<div class="revisions"/>' ),
|
|
|
|
revs = this.revisionList.getRevisions(),
|
|
|
|
maxChangeSizeLogged = Math.log( this.revisionList.getBiggestChangeSize() ),
|
|
|
|
i, diffSize, $tooltip, relativeChangeSize;
|
|
|
|
|
2016-05-12 13:52:54 +00:00
|
|
|
for ( i = 0; i < revs.length; i++ ) {
|
|
|
|
diffSize = revs[ i ].getRelativeSize();
|
2016-05-13 15:54:53 +00:00
|
|
|
relativeChangeSize = diffSize !== 0 ? Math.ceil( 65.0 * Math.log( Math.abs( diffSize ) ) / maxChangeSizeLogged ) + 5 : 0;
|
2016-05-12 11:31:08 +00:00
|
|
|
$tooltip = this.makeTooltip( revs[ i ] );
|
2016-05-10 12:42:05 +00:00
|
|
|
|
|
|
|
$html
|
2016-05-12 13:52:54 +00:00
|
|
|
.append( $( '<div class="revision" data-revid="' + revs[ i ].getId() + '" data-pos="' + ( i + 1 ) + '" title="' + $tooltip + '"/>' )
|
2016-05-10 12:42:05 +00:00
|
|
|
.css( {
|
2016-05-12 13:52:54 +00:00
|
|
|
left: revisionTickWidth * i + 'px',
|
2016-05-10 12:42:05 +00:00
|
|
|
height: relativeChangeSize + 'px',
|
|
|
|
width: revisionTickWidth + 'px',
|
|
|
|
top: diffSize > 0 ? '-' + relativeChangeSize + 'px' : 0,
|
2016-05-12 11:34:16 +00:00
|
|
|
background: 'black'
|
2016-05-10 12:42:05 +00:00
|
|
|
} )
|
|
|
|
.tipsy( {
|
|
|
|
gravity: 's',
|
|
|
|
html: true,
|
|
|
|
fade: true
|
|
|
|
} ) )
|
|
|
|
.append( $( '<div class="stopper"/>' )
|
|
|
|
.css( {
|
2016-05-12 13:52:54 +00:00
|
|
|
left: revisionTickWidth * i + 'px',
|
2016-05-10 12:42:05 +00:00
|
|
|
width: revisionTickWidth + 'px'
|
|
|
|
} ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
},
|
|
|
|
|
2016-05-12 11:31:08 +00:00
|
|
|
makeTooltip: function ( rev ) {
|
2016-05-10 12:42:05 +00:00
|
|
|
var $tooltip = $( '<center/>' ) // TODO: center is deprecated since 1995
|
|
|
|
.append( '<p><b>' + rev.getFormattedDate() + '</b></p>' )
|
|
|
|
.append( $( '<p/>' ).text( mw.html.escape( rev.getUser() ) ) )
|
2016-05-12 12:00:00 +00:00
|
|
|
.append( rev.getComment() ? $( '<p/>' ).append( '<i/>' ).text( mw.html.escape( rev.getComment() ) ) : '' )
|
|
|
|
.append( $( '<p/>' ).html( rev.getSize() + ' bytes' ) )
|
|
|
|
.append( rev.isMinor() ? $( '<p/>' ).html( mw.message( 'minoredit' ).text() ) : '' );
|
2016-05-10 12:42:05 +00:00
|
|
|
|
|
|
|
return $( '<div/>' ).append( $tooltip ).html();
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
mw.libs.revisionSlider = mw.libs.revisionSlider || {};
|
|
|
|
mw.libs.revisionSlider.RevisionListView = RevisionListView;
|
|
|
|
}( mediaWiki, jQuery ) );
|