mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-16 20:58:28 +00:00
31f6d44bf6
After recent changes allowing ThreadItems to have IDs, they can now also have warnings about duplicate IDs. Bug: T267035 Change-Id: If3edfe34e6e29741e29fac8946a3c88badc4ab7f
53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
var ThreadItem = require( './ThreadItem.js' );
|
|
|
|
/**
|
|
* @external moment
|
|
* @external HeadingItem
|
|
*/
|
|
|
|
/**
|
|
* A comment item
|
|
*
|
|
* @class CommentItem
|
|
* @extends ThreadItem
|
|
* @constructor
|
|
* @param {number} level
|
|
* @param {Object} range
|
|
* @param {Object[]} [signatureRanges] Objects describing the extent of signatures (plus
|
|
* timestamps) for this comment. There is always at least one signature, but there may be
|
|
* multiple. The author and timestamp of the comment is determined from the first signature.
|
|
* The last node in every signature range is a node containing the timestamp.
|
|
* @param {moment} [timestamp] Timestamp (Moment object)
|
|
* @param {string} [author] Comment author's username
|
|
*/
|
|
function CommentItem( level, range, signatureRanges, timestamp, author ) {
|
|
// Parent constructor
|
|
CommentItem.super.call( this, 'comment', level, range );
|
|
|
|
this.signatureRanges = signatureRanges || [];
|
|
this.timestamp = timestamp || null;
|
|
this.author = author || null;
|
|
|
|
/**
|
|
* @member {ThreadItem} Parent thread item
|
|
*/
|
|
this.parent = null;
|
|
}
|
|
|
|
OO.inheritClass( CommentItem, ThreadItem );
|
|
|
|
/**
|
|
* @return {HeadingItem} Closest ancestor which is a HeadingItem
|
|
*/
|
|
CommentItem.prototype.getHeading = function () {
|
|
var parent = this;
|
|
while ( parent && parent.type !== 'heading' ) {
|
|
parent = parent.parent;
|
|
}
|
|
return parent;
|
|
};
|
|
|
|
// TODO: Implement getBodyRange/getBodyHTML/getBodyText/getMentions if required
|
|
|
|
module.exports = CommentItem;
|