diff --git a/extension.json b/extension.json index 61f823a6..a0e643d2 100755 --- a/extension.json +++ b/extension.json @@ -91,6 +91,9 @@ "dependencies": [ "ext.RevisionSlider.Revision", "ext.RevisionSlider.RevisionListView" + ], + "messages": [ + "minoredit" ] }, "ext.RevisionSlider.RevisionListView": { diff --git a/modules/ext.RevisionSlider.Revision.js b/modules/ext.RevisionSlider.Revision.js index 7c2d53ad..5912125e 100644 --- a/modules/ext.RevisionSlider.Revision.js +++ b/modules/ext.RevisionSlider.Revision.js @@ -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; }, diff --git a/modules/ext.RevisionSlider.RevisionListView.js b/modules/ext.RevisionSlider.RevisionListView.js index 0931358c..dc2dcd0e 100644 --- a/modules/ext.RevisionSlider.RevisionListView.js +++ b/modules/ext.RevisionSlider.RevisionListView.js @@ -48,7 +48,9 @@ var $tooltip = $( '
' ) // TODO: center is deprecated since 1995 .append( '

' + rev.getFormattedDate() + '

' ) .append( $( '

' ).text( mw.html.escape( rev.getUser() ) ) ) - .append( rev.getComment() ? $( '

' ).append( '' ).text( mw.html.escape( rev.getComment() ) ) : '' ); + .append( rev.getComment() ? $( '

' ).append( '' ).text( mw.html.escape( rev.getComment() ) ) : '' ) + .append( $( '

' ).html( rev.getSize() + ' bytes' ) ) + .append( rev.isMinor() ? $( '

' ).html( mw.message( 'minoredit' ).text() ) : '' ); return $( '

' ).append( $tooltip ).html(); } diff --git a/tests/RevisionSlider.Revision.test.js b/tests/RevisionSlider.Revision.test.js index 68d1080d..275b70a4 100644 --- a/tests/RevisionSlider.Revision.test.js +++ b/tests/RevisionSlider.Revision.test.js @@ -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: 'hello', + 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: 'hello', + 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 ) {