mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-15 12:00:51 +00:00
dccaa5bf65
Wikis like jawiki will then be able to customize the message to include honorifics as they think appropriate. Bug: T268588 Change-Id: I213fb9fd0a9ed6592ce3548a5b2c3b11a55c1abc
84 lines
1.8 KiB
JavaScript
84 lines
1.8 KiB
JavaScript
/*!
|
|
* VisualEditor ContentEditable MWPingNode class.
|
|
*
|
|
* @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* ContentEditable MediaWiki ping node.
|
|
*
|
|
* @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 () {
|
|
var 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
|
|
var $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 );
|