mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-12-23 21:33:48 +00:00
ca5157156a
Leave rule off for now as manual fixes are required. Also temporarily disable prefer-const rule as that will also require some manual fixes. Change-Id: I8c3478f26f51287acb943bd38c9c1020c06b9f39
77 lines
1.6 KiB
JavaScript
77 lines
1.6 KiB
JavaScript
/**
|
|
* PingNode view.
|
|
*
|
|
* @class
|
|
* @extends ve.ce.LeafNode
|
|
* @mixes ve.ce.FocusableNode
|
|
*
|
|
* @constructor
|
|
* @param {DmMWPingNode} model Model to observe
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
function CeMWPingNode() {
|
|
// Parent constructor
|
|
CeMWPingNode.super.apply( this, arguments );
|
|
|
|
// Mixin constructor
|
|
ve.ce.FocusableNode.call( this );
|
|
}
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( CeMWPingNode, ve.ce.LeafNode );
|
|
|
|
OO.mixinClass( CeMWPingNode, ve.ce.FocusableNode );
|
|
|
|
/* Static Properties */
|
|
|
|
CeMWPingNode.static.name = 'mwPing';
|
|
|
|
CeMWPingNode.static.tagName = 'span';
|
|
|
|
CeMWPingNode.static.deleteCommandName = 'insertAndOpenMWUsernameCompletions';
|
|
|
|
CeMWPingNode.static.getDescription = function ( model ) {
|
|
return model.getAttribute( 'user' );
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
CeMWPingNode.prototype.initialize = function () {
|
|
const model = this.getModel(),
|
|
prefix = mw.msg( 'discussiontools-replywidget-mention-prefix' ),
|
|
suffix = mw.msg( 'discussiontools-replywidget-mention-suffix' ),
|
|
user = model.getAttribute( 'user' ),
|
|
title = mw.Title.makeTitle( mw.config.get( 'wgNamespaceIds' ).user, user );
|
|
|
|
// Parent method
|
|
CeMWPingNode.super.prototype.initialize.call( this );
|
|
|
|
// DOM changes
|
|
const $link = $( '<a>' )
|
|
.addClass( 'ext-discussiontools-ce-mwPingNode' )
|
|
.attr( {
|
|
href: title.getUrl(),
|
|
title: user
|
|
} )
|
|
.text( model.getAttribute( 'user' ) );
|
|
|
|
ve.init.platform.linkCache.styleElement(
|
|
title.getPrefixedText(),
|
|
$link
|
|
);
|
|
|
|
this.$element.append(
|
|
prefix,
|
|
$link,
|
|
suffix
|
|
);
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ce.nodeFactory.register( CeMWPingNode );
|