Debian Codegraph @

extensions/Cite/modules/ve-cite/ve.ui.MWReferencesListContextItem.js

raw symbols SCIP
1 'use strict';
2
3 /*!
4 * VisualEditor MWReferencesListContextItem class.
5 *
6 * @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt
7 * @license MIT
8 */
9
10 /**
11 * Context item for a MWReferencesList.
12 *
13 * @constructor
14 * @extends ve.ui.LinearContextItem
15 * @param {ve.ui.LinearContext} context Context the item is in
16 * @param {ve.dm.Model} model Model the item is related to
17 * @param {Object} [config]
18 */
19 ve.ui.MWReferencesListContextItem = function VeUiMWReferencesListContextItem() {
20 // Parent constructor
21 ve.ui.MWReferencesListContextItem.super.apply( this, arguments );
22
23 // Initialization
24 this.$element.addClass( 've-ui-mwReferencesListContextItem' );
25 };
26
27 /* Inheritance */
28
29 OO.inheritClass( ve.ui.MWReferencesListContextItem, ve.ui.LinearContextItem );
30
31 /* Static Properties */
32
33 ve.ui.MWReferencesListContextItem.static.name = 'referencesList';
34
35 ve.ui.MWReferencesListContextItem.static.icon = 'references';
36
37 ve.ui.MWReferencesListContextItem.static.label =
38 OO.ui.deferMsg( 'cite-ve-dialogbutton-referenceslist-tooltip' );
39
40 ve.ui.MWReferencesListContextItem.static.modelClasses = [ ve.dm.MWReferencesListNode ];
41
42 ve.ui.MWReferencesListContextItem.static.commandName = 'referencesList';
43
44 ve.ui.MWReferencesListContextItem.static.embeddable = false;
45
46 /* Methods */
47
48 /**
49 * @override
50 */
51 ve.ui.MWReferencesListContextItem.prototype.renderBody = function () {
52 this.$body.append(
53 $( '<div>' ).text( this.getDescription() )
54 );
55 if ( this.model.getAttribute( 'templateGenerated' ) ) {
56 this.$body.append(
57 $( '<div>' )
58 .addClass( 've-ui-mwReferenceContextItem-muted' )
59 .text( ve.msg( 'cite-ve-referenceslist-missingreflist' ) )
60 );
61 }
62 };
63
64 /**
65 * @override
66 */
67 ve.ui.MWReferencesListContextItem.prototype.getDescription = function () {
68 const group = this.model.getAttribute( 'refGroup' );
69
70 return group ?
71 ve.msg( 'cite-ve-dialog-referenceslist-contextitem-description-named', group ) :
72 ve.msg( 'cite-ve-dialog-referenceslist-contextitem-description-general' );
73 };
74
75 /* Registration */
76
77 ve.ui.contextItemFactory.register( ve.ui.MWReferencesListContextItem );