2023-08-21 08:08:23 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-02-03 21:03:41 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface MediaWiki UseExistingReferenceCommand class.
|
|
|
|
*
|
2018-01-03 01:05:45 +00:00
|
|
|
* @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt
|
2017-12-29 12:12:35 +00:00
|
|
|
* @license MIT
|
2016-02-03 21:03:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Use existing reference command.
|
|
|
|
*
|
|
|
|
* @constructor
|
2024-02-28 08:57:24 +00:00
|
|
|
* @extends ve.ui.Command
|
2016-02-03 21:03:41 +00:00
|
|
|
*/
|
|
|
|
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 */
|
|
|
|
|
|
|
|
/**
|
2024-02-28 08:57:24 +00:00
|
|
|
* @override
|
2016-02-03 21:03:41 +00:00
|
|
|
*/
|
|
|
|
ve.ui.MWUseExistingReferenceCommand.prototype.isExecutable = function ( fragment ) {
|
2024-02-22 18:28:17 +00:00
|
|
|
return ve.ui.MWUseExistingReferenceCommand.super.prototype.isExecutable.apply( this, arguments ) &&
|
|
|
|
!ve.ui.MWReferenceSearchWidget.static.isIndexEmpty( fragment.getDocument().getInternalList() );
|
2016-02-03 21:03:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.ui.commandRegistry.register( new ve.ui.MWUseExistingReferenceCommand() );
|