diff options
author | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
commit | fc7369835258467bf97eb64f184b93691f9a9fd5 (patch) | |
tree | daabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/extensions/Cite/modules/ve-cite/ve.ui.MWCitationDialogTool.js |
first commit
Diffstat (limited to 'www/wiki/extensions/Cite/modules/ve-cite/ve.ui.MWCitationDialogTool.js')
-rw-r--r-- | www/wiki/extensions/Cite/modules/ve-cite/ve.ui.MWCitationDialogTool.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/www/wiki/extensions/Cite/modules/ve-cite/ve.ui.MWCitationDialogTool.js b/www/wiki/extensions/Cite/modules/ve-cite/ve.ui.MWCitationDialogTool.js new file mode 100644 index 00000000..b7011fca --- /dev/null +++ b/www/wiki/extensions/Cite/modules/ve-cite/ve.ui.MWCitationDialogTool.js @@ -0,0 +1,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; +}; |