mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-14 18:45:12 +00:00
0d20873fa6
Change-Id: Ia090c417a1aa716b255613199b5e49616bf0517a
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface MediaWiki UseExistingReferenceCommand class.
|
|
*
|
|
* @copyright 2011-2017 Cite VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Use existing reference command.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.Command
|
|
*
|
|
* @constructor
|
|
*/
|
|
ve.ui.MWUseExistingReferenceCommand = function VeUiMWUseExistingReferenceCommand() {
|
|
// Parent constructor
|
|
ve.ui.MWUseExistingReferenceCommand.super.call(
|
|
this, 'reference/existing', 'window', 'open',
|
|
{ args: [ 'reference', { useExisting: true } ], supportedSelections: [ 'linear' ] }
|
|
);
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.MWUseExistingReferenceCommand, ve.ui.Command );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.MWUseExistingReferenceCommand.prototype.isExecutable = function ( fragment ) {
|
|
var groupName, groups;
|
|
|
|
// Parent method
|
|
if ( !ve.ui.MWUseExistingReferenceCommand.super.prototype.isExecutable.apply( this, arguments ) ) {
|
|
return false;
|
|
}
|
|
|
|
groups = fragment.getDocument().getInternalList().getNodeGroups();
|
|
|
|
for ( groupName in groups ) {
|
|
if ( groupName.lastIndexOf( 'mwReference/' ) === 0 && groups[ groupName ].indexOrder.length ) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ui.commandRegistry.register( new ve.ui.MWUseExistingReferenceCommand() );
|