mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-17 13:12:26 +00:00
bca14cbe03
Depends-On: I49733aa6aa2c1e61a88e7c88e84f1f4338acfac1 Change-Id: I9586d07ded0e41afdcfbd6e46364bb1f837cf1c0
87 lines
1.7 KiB
JavaScript
87 lines
1.7 KiB
JavaScript
/*!
|
|
* VisualEditor ContentEditable MWPingNode class.
|
|
*
|
|
* @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* @external DmMWPingNode
|
|
*/
|
|
|
|
/**
|
|
* 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' ),
|
|
user = model.getAttribute( 'user' ),
|
|
title = mw.Title.makeTitle( mw.config.get( 'wgNamespaceIds' ).user, user ),
|
|
$link;
|
|
|
|
// Parent method
|
|
CeMWPingNode.super.prototype.initialize.call( this );
|
|
|
|
// DOM changes
|
|
$link = $( '<a>' )
|
|
.addClass( 'dt-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
|
|
);
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ce.nodeFactory.register( CeMWPingNode );
|