( function ( mw, $ ) { /** * @param {RevisionList} revisionList * @constructor */ var RevisionListView = function ( revisionList ) { this.revisionList = revisionList; }; $.extend( RevisionListView.prototype, { /** * @type {RevisionList} */ revisionList: null, /** * @type {number} */ tooltipTimeout: -1, /** * @type {jQuery} */ currentTooltip: null, /** * @param {number} revisionTickWidth * @return {jQuery} */ render: function ( revisionTickWidth ) { var $html = $( '
' ).append(
mw.message( 'revisionslider-label-date', rev.getFormattedDate() ).parseDom()
),
rev.getUser() ?
$( '' ).append( $( ' ' ).append(
mw.message( 'revisionslider-label-username', mw.html.escape( rev.getUser() ) ).parseDom()
) )
: '',
this.makeCommentLine( rev ),
$( ' ' ).append(
mw.message( 'revisionslider-label-page-size', mw.language.convertNumber( rev.getSize() ), rev.getSize() ).parseDom()
),
this.makeChangeSizeLine( rev ),
rev.isMinor() ? $( ' ' ).text( mw.message( 'minoredit' ).text() ) : '' );
return $tooltip.html();
},
/**
* Generates the HTML for the comment label
*
* @param {Revision} rev
* @return {string|jQuery}
*/
makeCommentLine: function ( rev ) {
if ( rev.hasEmptyComment() ) {
return '';
}
return $( '' ).append(
$( ' ' ).append(
$( '' ).text( mw.message( 'revisionslider-label-comment' ).text() ),
$( '' ).append(
rev.getParsedComment()
)
)
);
},
makeChangeSizeLine: function ( rev ) {
var changeSizeClass = 'mw-no-change',
leadingSign = '',
$changeNumber;
if ( rev.getRelativeSize() > 0 ) {
changeSizeClass = 'mw-positive-change';
leadingSign = '+';
} else if ( rev.getRelativeSize() < 0 ) {
changeSizeClass = 'mw-negative-change';
}
$changeNumber = $( '' )
.addClass( changeSizeClass )
.text( leadingSign + mw.language.convertNumber( rev.getRelativeSize() ) );
return $( ' ' ).append(
mw.message( 'revisionslider-label-change-size', $changeNumber, rev.getRelativeSize() ).parseDom()
);
}
} );
mw.libs.revisionSlider = mw.libs.revisionSlider || {};
mw.libs.revisionSlider.RevisionListView = RevisionListView;
}( mediaWiki, jQuery ) );