mediawiki-extensions-Visual.../modules/ve-mw/ui/tools/ve.ui.MWCitationDialogTool.js
James D. Forrester 31bafa183d Update VE core submodule to master (a942301)
New changes:
2cc219a Update OOjs UI to v0.1.0-pre (571f26d0ab)
3543cb7 Protect against offset=-1 in insertContent()
7a3d456 [BREAKING CHANGE] Move selection restrictions from tools to commands
3d847bb Disable desktop context on table selections
41282dd Missed function rename from RangeFix change
dd6c8b8 Support toDomElements returning an empty array
9be6464 Placholder -> placeholder
9bdd0a8 Restore basic styling to toolbar in core target (only)

Local changes:
Move selection restrictions from tools to commands

Change-Id: I88f3d04946bd1d03ed001d747475a8b495a0f64c
2014-11-04 14:11:04 -08:00

67 lines
1.8 KiB
JavaScript

/*!
* VisualEditor MediaWiki UserInterface citation dialog tool class.
*
* @copyright 2011-2014 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';
ve.ui.MWCitationDialogTool.static.modelClasses = [ ve.dm.MWReferenceNode ];
/**
* Only display tool for single-template transclusions of these templates.
*
* @property {string|string[]|null}
* @static
* @inheritable
*/
ve.ui.MWCitationDialogTool.static.template = null;
/* 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;
};