mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-24 23:05:31 +00:00
18f616b9b8
This code has been developed over three years now in the repo of MediaWiki's integration of VisualEditor. It has grown and developed significantly during that time, but now is pretty stable. A number of hacks inside the MediaWiki- VisualEditor code base have been used to prevent this code from being loaded on wikis where the Cite extension is not deployed, but this state of affairs is and always was meant to be temporary. This code is under the MIT licence which is a tad messy, but not impossible. It's clearly labelled as such. The list of authors has been updated to take into account the influx of new functionality. Bug: T41621 Bug: T104928 Change-Id: I39936ed83d5a60471a0a75da753f498e80aef234
65 lines
1.7 KiB
JavaScript
65 lines
1.7 KiB
JavaScript
/*!
|
|
* VisualEditor MediaWiki UserInterface citation dialog tool class.
|
|
*
|
|
* @copyright 2011-2016 Cite VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* 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;
|
|
};
|