Debian Codegraph @

extensions/VisualEditor/modules/ve-mw/ui/contextitems/ve.ui.MWAnnotationContextItem.js

raw symbols SCIP
1 /*!
2 * VisualEditor MWAnnotationContextItem class.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * Context item for a MWAnnotation
9 *
10 * @class
11 * @extends ve.ui.LinearContextItem
12 *
13 * @constructor
14 * @param {ve.ui.LinearContext} context Context the item is in
15 * @param {ve.dm.Model} model Model the item is related to
16 * @param {Object} [config]
17 */
18 ve.ui.MWAnnotationContextItem = function VeUiMWAnnotationContextItem() {
19 // Parent constructor
20 ve.ui.MWAnnotationContextItem.super.apply( this, arguments );
21
22 // Initialization
23 this.$element.addClass( 've-ui-mwAnnotationContextItem' );
24
25 this.setLabel( this.getLabelMessage() );
26
27 this.$actions.remove();
28 };
29
30 /* Inheritance */
31
32 OO.inheritClass( ve.ui.MWAnnotationContextItem, ve.ui.LinearContextItem );
33
34 /* Static Properties */
35
36 ve.ui.MWAnnotationContextItem.static.editable = false;
37
38 ve.ui.MWAnnotationContextItem.static.name = 'mwAnnotation';
39
40 ve.ui.MWAnnotationContextItem.static.icon = 'markup';
41
42 ve.ui.MWAnnotationContextItem.static.modelClasses = [
43 ve.dm.MWAnnotationNode
44 ];
45
46 /* Methods */
47
48 /**
49 * @inheritdoc
50 */
51 ve.ui.MWAnnotationContextItem.prototype.renderBody = function () {
52 this.$body.empty();
53
54 const $desc = this.getDescriptionMessage();
55 if ( $desc ) {
56 this.$body.append( $desc, $( document.createTextNode( mw.msg( 'word-separator' ) ) ) );
57 }
58
59 if ( this.model.getAttribute( 'mw' ) ) {
60 if ( this.model.getAttribute( 'mw' ).extendedRange ) {
61 // eslint-disable-next-line no-jquery/no-append-html
62 this.$body.append( mw.message( 'visualeditor-annotations-extended-documentation' ).parseDom() );
63 }
64 }
65 };