( 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() ), this.makeUserLine( rev.getUser() ), this.makeCommentLine( rev ), this.makePageSizeLine( rev.getSize() ), this.makeChangeSizeLine( rev.getRelativeSize() ), rev.isMinor() ? $( '
' ).text( mw.message( 'revisionslider-minoredit' ).text() ) : ''
);
return $tooltip.html();
},
/**
* Generates a link to user page or to contributions page for IP addresses
*
* @param {string} user
* @return {string}
*/
getUserPage: function ( user ) {
return ( mw.util.isIPAddress( user, false ) ? 'Special:Contributions/' : 'User:' ) + mw.html.escape( user );
},
/**
* Generates the HTML for the user label
*
* @param {string} userString
* @return {string|jQuery}
*/
makeUserLine: function ( userString ) {
if ( !userString ) {
return '';
}
return $( '' ).append( $( ' ' ).append(
mw.message( 'revisionslider-label-username', mw.html.escape( userString ), this.getUserPage( userString ) ).parseDom()
) );
},
/**
* 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()
)
)
);
},
/**
* Generates the HTML for the page size label
*
* @param {number} size
* @return {jQuery}
*/
makePageSizeLine: function ( size ) {
return $( ' ' ).append(
mw.message( 'revisionslider-label-page-size', mw.language.convertNumber( size ), size ).parseDom()
);
},
/**
* Generates the HTML for the change size label
*
* @param {number} relativeSize
* @return {jQuery}
*/
makeChangeSizeLine: function ( relativeSize ) {
var changeSizeClass = 'mw-revslider-change-none',
leadingSign = '',
$changeNumber;
if ( relativeSize > 0 ) {
changeSizeClass = 'mw-revslider-change-positive';
leadingSign = '+';
} else if ( relativeSize < 0 ) {
changeSizeClass = 'mw-revslider-change-negative';
}
$changeNumber = $( '' )
.addClass( changeSizeClass )
.text( leadingSign + mw.language.convertNumber( relativeSize ) );
return $( ' ' ).append(
mw.message( 'revisionslider-label-change-size', $changeNumber, relativeSize ).parseDom()
);
}
} );
mw.libs.revisionSlider = mw.libs.revisionSlider || {};
mw.libs.revisionSlider.RevisionListView = RevisionListView;
}( mediaWiki, jQuery ) );