mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-11-24 07:23:41 +00:00
Add size & minor flag to tooltip
Bug: T135118 Change-Id: I2bc90a2f8a03693df092a4785cfe2fdfcc85730a
This commit is contained in:
parent
7d5de12c11
commit
8ba5d9acea
|
@ -91,6 +91,9 @@
|
|||
"dependencies": [
|
||||
"ext.RevisionSlider.Revision",
|
||||
"ext.RevisionSlider.RevisionListView"
|
||||
],
|
||||
"messages": [
|
||||
"minoredit"
|
||||
]
|
||||
},
|
||||
"ext.RevisionSlider.RevisionListView": {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
this.parsedComment = data.parsedcomment;
|
||||
this.timestamp = data.timestamp;
|
||||
this.user = data.user;
|
||||
this.minor = data.hasOwnProperty( 'minor' ) && ( data.minor || data.minor === '' );
|
||||
};
|
||||
|
||||
$.extend( Revision.prototype, {
|
||||
|
@ -25,6 +26,11 @@
|
|||
*/
|
||||
comment: '',
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
minor: false,
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
|
@ -53,6 +59,10 @@
|
|||
return this.size;
|
||||
},
|
||||
|
||||
isMinor: function () {
|
||||
return this.minor;
|
||||
},
|
||||
|
||||
getParsedComment: function () {
|
||||
return this.parsedComment;
|
||||
},
|
||||
|
|
|
@ -48,7 +48,9 @@
|
|||
var $tooltip = $( '<center/>' ) // TODO: center is deprecated since 1995
|
||||
.append( '<p><b>' + rev.getFormattedDate() + '</b></p>' )
|
||||
.append( $( '<p/>' ).text( mw.html.escape( rev.getUser() ) ) )
|
||||
.append( rev.getComment() ? $( '<p/>' ).append( '<i/>' ).text( mw.html.escape( rev.getComment() ) ) : '' );
|
||||
.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() ) : '' );
|
||||
|
||||
return $( '<div/>' ).append( $tooltip ).html();
|
||||
}
|
||||
|
|
|
@ -16,6 +16,45 @@
|
|||
assert.equal( rev.getParsedComment(), data.parsedcomment );
|
||||
assert.equal( rev.getFormattedDate(), '10:27, 26 Apr 2016' );
|
||||
assert.equal( rev.getUser(), data.user );
|
||||
assert.equal( rev.isMinor(), false );
|
||||
} );
|
||||
|
||||
QUnit.test( 'create minor Revision (minor empty string)', function ( assert ) {
|
||||
var data = {
|
||||
size: 5,
|
||||
comment: 'hello',
|
||||
parsedcomment: '<b>hello</b>',
|
||||
timestamp: '2016-04-26T10:27:14Z', // 10:27, 26 Apr 2016
|
||||
user: 'meh',
|
||||
minor: ''
|
||||
},
|
||||
rev = new mw.libs.revisionSlider.Revision( data );
|
||||
|
||||
assert.equal( rev.getSize(), data.size );
|
||||
assert.equal( rev.getComment(), data.comment );
|
||||
assert.equal( rev.getParsedComment(), data.parsedcomment );
|
||||
assert.equal( rev.getFormattedDate(), '10:27, 26 Apr 2016' );
|
||||
assert.equal( rev.getUser(), data.user );
|
||||
assert.equal( rev.isMinor(), true );
|
||||
} );
|
||||
|
||||
QUnit.test( 'create minor Revision (minor true, as if from another Revision object)', function ( assert ) {
|
||||
var data = {
|
||||
size: 5,
|
||||
comment: 'hello',
|
||||
parsedcomment: '<b>hello</b>',
|
||||
timestamp: '2016-04-26T10:27:14Z', // 10:27, 26 Apr 2016
|
||||
user: 'meh',
|
||||
minor: true
|
||||
},
|
||||
rev = new mw.libs.revisionSlider.Revision( data );
|
||||
|
||||
assert.equal( rev.getSize(), data.size );
|
||||
assert.equal( rev.getComment(), data.comment );
|
||||
assert.equal( rev.getParsedComment(), data.parsedcomment );
|
||||
assert.equal( rev.getFormattedDate(), '10:27, 26 Apr 2016' );
|
||||
assert.equal( rev.getUser(), data.user );
|
||||
assert.equal( rev.isMinor(), true );
|
||||
} );
|
||||
|
||||
QUnit.test( 'get Revision with section', function ( assert ) {
|
||||
|
|
Loading…
Reference in a new issue