Debian Codegraph @

extensions/VisualEditor/modules/ve-mw/ce/annotations/ve.ce.MWExternalLinkAnnotation.js

raw symbols SCIP
1 /*!
2 * VisualEditor ContentEditable MWExternalLinkAnnotation class.
3 *
4 * @copyright See AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
6 */
7
8 /**
9 * ContentEditable MediaWiki external link annotation.
10 *
11 * @class
12 * @extends ve.ce.LinkAnnotation
13 * @constructor
14 * @param {ve.dm.MWExternalLinkAnnotation} model Model to observe
15 * @param {ve.ce.ContentBranchNode} [parentNode] Node rendering this annotation
16 * @param {Object} [config] Configuration options
17 */
18 ve.ce.MWExternalLinkAnnotation = function VeCeMWExternalLinkAnnotation( model ) {
19 // Parent constructor
20 ve.ce.MWExternalLinkAnnotation.super.apply( this, arguments );
21
22 // DOM changes
23 const rel = model.getAttribute( 'rel' ) || '';
24 const relValues = rel.split( /\s+/ );
25 if ( relValues.indexOf( 'mw:WikiLink/Interwiki' ) >= 0 ) {
26 this.$anchor.addClass( 'extiw' );
27 } else {
28 this.$anchor.addClass( 'external' );
29 }
30 };
31
32 /* Inheritance */
33
34 OO.inheritClass( ve.ce.MWExternalLinkAnnotation, ve.ce.LinkAnnotation );
35
36 /* Static Properties */
37
38 ve.ce.MWExternalLinkAnnotation.static.name = 'link/mwExternal';
39
40 /* Registration */
41
42 ve.ce.annotationFactory.register( ve.ce.MWExternalLinkAnnotation );