blob: b7011fca018f06df6cae5abd09f1e217459685e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/*!
* VisualEditor MediaWiki UserInterface citation dialog tool class.
*
* @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt
* @license MIT
*/
/**
* MediaWiki UserInterface citation dialog tool.
*
* @class
* @abstract
* @extends ve.ui.MWReferenceDialogTool
* @constructor
* @param {OO.ui.Toolbar} toolbar
* @param {Object} [config] Configuration options
*/
ve.ui.MWCitationDialogTool = function VeUiMWCitationDialogTool( toolbar, config ) {
// Parent method
ve.ui.MWCitationDialogTool.super.call( this, toolbar, config );
};
/* Inheritance */
OO.inheritClass( ve.ui.MWCitationDialogTool, ve.ui.MWReferenceDialogTool );
/* Static Properties */
ve.ui.MWCitationDialogTool.static.group = 'cite';
/**
* Only display tool for single-template transclusions of these templates.
*
* @property {string|string[]|null}
* @static
* @inheritable
*/
ve.ui.MWCitationDialogTool.static.template = null;
/* Static Methods */
/**
* @inheritdoc
*/
ve.ui.MWCitationDialogTool.static.isCompatibleWith = function ( model ) {
var internalItem, branches, leaves,
compatible = ve.ui.MWCitationDialogTool.super.static.isCompatibleWith.call( this, model );
if ( compatible && this.template ) {
// Check if content of the reference node contains only a template with the same name as
// this.template
internalItem = model.getInternalItem();
branches = internalItem.getChildren();
if ( branches.length === 1 && branches[ 0 ].canContainContent() ) {
leaves = branches[ 0 ].getChildren();
if ( leaves.length === 1 && leaves[ 0 ] instanceof ve.dm.MWTransclusionNode ) {
return leaves[ 0 ].isSingleTemplate( this.template );
}
}
return false;
}
return compatible;
};
|