Debian Codegraph @

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

raw symbols SCIP
1 /**
2 * PingNode model. A ping is just a link to a user page, but
3 * by defining it as a node we can make is a single FocusableNode.
4 *
5 * @class
6 * @extends ve.dm.LeafNode
7 * @mixes ve.dm.FocusableNode
8 *
9 * @constructor
10 * @param {Object} [element] Reference to element in linear model
11 */
12 function DmMWPingNode() {
13 // Parent constructor
14 DmMWPingNode.super.apply( this, arguments );
15
16 // Mixin constructor
17 ve.dm.FocusableNode.call( this );
18 }
19
20 /* Inheritance */
21
22 OO.inheritClass( DmMWPingNode, ve.dm.LeafNode );
23
24 OO.mixinClass( DmMWPingNode, ve.dm.FocusableNode );
25
26 /* Static members */
27
28 DmMWPingNode.static.name = 'mwPing';
29
30 DmMWPingNode.static.isContent = true;
31
32 DmMWPingNode.static.matchTagNames = null;
33
34 DmMWPingNode.static.matchRdfaTypes = [];
35
36 DmMWPingNode.static.matchFunction = function () {
37 return false;
38 };
39
40 DmMWPingNode.static.disallowedAnnotationTypes = [ 'link' ];
41
42 DmMWPingNode.static.toDomElements = function ( dataElement, doc, converter ) {
43 const prefix = mw.msg( 'discussiontools-replywidget-mention-prefix' ),
44 suffix = mw.msg( 'discussiontools-replywidget-mention-suffix' ),
45 title = mw.Title.makeTitle( mw.config.get( 'wgNamespaceIds' ).user, dataElement.attributes.user );
46
47 dataElement = ve.dm.MWInternalLinkAnnotation.static.dataElementFromTitle( title );
48 const domElements = ve.dm.MWInternalLinkAnnotation.static.toDomElements( dataElement, doc, converter );
49 domElements[ 0 ].appendChild(
50 doc.createTextNode( title.getMainText() )
51 );
52 domElements.unshift( document.createTextNode( prefix ) );
53 domElements.push( document.createTextNode( suffix ) );
54
55 return domElements;
56 };
57
58 // toDataElement should never be called for this node
59 DmMWPingNode.static.toDataElement = null;
60
61 /* Registration */
62
63 ve.dm.modelRegistry.register( DmMWPingNode );