2014-11-11 16:45:02 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface MediaWiki UseExistingReferenceCommand class.
|
|
|
|
*
|
2015-01-08 23:54:03 +00:00
|
|
|
* @copyright 2011-2015 VisualEditor Team and others; see http://ve.mit-license.org
|
2014-11-11 16:45:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-11-23 18:04:00 +00:00
|
|
|
* Use existing reference command.
|
2014-11-11 16:45:02 +00:00
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.Command
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
ve.ui.MWUseExistingReferenceCommand = function VeUiMWUseExistingReferenceCommand() {
|
|
|
|
// Parent constructor
|
|
|
|
ve.ui.MWUseExistingReferenceCommand.super.call(
|
|
|
|
this, 'reference/existing', 'window', 'open',
|
2015-07-22 22:13:09 +00:00
|
|
|
{ args: [ 'reference', { useExisting: true } ], supportedSelections: [ 'linear' ] }
|
2014-11-11 16:45:02 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ui.MWUseExistingReferenceCommand, ve.ui.Command );
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWUseExistingReferenceCommand.prototype.isExecutable = function ( fragment ) {
|
2015-08-19 18:05:01 +00:00
|
|
|
var groupName, groups;
|
|
|
|
|
2014-11-11 16:45:02 +00:00
|
|
|
// Parent method
|
|
|
|
if ( !ve.ui.MWUseExistingReferenceCommand.super.prototype.isExecutable.apply( this, arguments ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-08-19 18:05:01 +00:00
|
|
|
groups = fragment.getDocument().getInternalList().getNodeGroups();
|
2014-11-11 16:45:02 +00:00
|
|
|
|
|
|
|
for ( groupName in groups ) {
|
2015-08-19 17:33:02 +00:00
|
|
|
if ( groupName.lastIndexOf( 'mwReference/' ) === 0 && groups[ groupName ].indexOrder.length ) {
|
2014-11-11 16:45:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.ui.commandRegistry.register( new ve.ui.MWUseExistingReferenceCommand() );
|