Debian Codegraph @

extensions/DiscussionTools/modules/dt-ve/dt.ce.PingNode.js

raw symbols SCIP
1 /**
2 * PingNode view.
3 *
4 * @class
5 * @extends ve.ce.LeafNode
6 * @mixes ve.ce.FocusableNode
7 *
8 * @constructor
9 * @param {DmMWPingNode} model Model to observe
10 * @param {Object} [config] Configuration options
11 */
12 function CeMWPingNode() {
13 // Parent constructor
14 CeMWPingNode.super.apply( this, arguments );
15
16 // Mixin constructor
17 ve.ce.FocusableNode.call( this );
18 }
19
20 /* Inheritance */
21
22 OO.inheritClass( CeMWPingNode, ve.ce.LeafNode );
23
24 OO.mixinClass( CeMWPingNode, ve.ce.FocusableNode );
25
26 /* Static Properties */
27
28 CeMWPingNode.static.name = 'mwPing';
29
30 CeMWPingNode.static.tagName = 'span';
31
32 CeMWPingNode.static.deleteCommandName = 'insertAndOpenMWUsernameCompletions';
33
34 CeMWPingNode.static.getDescription = function ( model ) {
35 return model.getAttribute( 'user' );
36 };
37
38 /* Methods */
39
40 /**
41 * @inheritdoc
42 */
43 CeMWPingNode.prototype.initialize = function () {
44 const model = this.getModel(),
45 prefix = mw.msg( 'discussiontools-replywidget-mention-prefix' ),
46 suffix = mw.msg( 'discussiontools-replywidget-mention-suffix' ),
47 user = model.getAttribute( 'user' ),
48 title = mw.Title.makeTitle( mw.config.get( 'wgNamespaceIds' ).user, user );
49
50 // Parent method
51 CeMWPingNode.super.prototype.initialize.call( this );
52
53 // DOM changes
54 const $link = $( '<a>' )
55 .addClass( 'ext-discussiontools-ce-mwPingNode' )
56 .attr( {
57 href: title.getUrl(),
58 title: user
59 } )
60 .text( model.getAttribute( 'user' ) );
61
62 ve.init.platform.linkCache.styleElement(
63 title.getPrefixedText(),
64 $link
65 );
66
67 this.$element.append(
68 prefix,
69 $link,
70 suffix
71 );
72 };
73
74 /* Registration */
75
76 ve.ce.nodeFactory.register( CeMWPingNode );