mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-11 06:36:17 +00:00
0d20873fa6
Change-Id: Ia090c417a1aa716b255613199b5e49616bf0517a
62 lines
1.4 KiB
JavaScript
62 lines
1.4 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface MediaWiki ReferencesListCommand class.
|
|
*
|
|
* @copyright 2011-2017 Cite VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* References list command.
|
|
*
|
|
* If a references list node is selected, opens the dialog to edit it.
|
|
* Otherwise inserts the references list for the default group.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.Command
|
|
*
|
|
* @constructor
|
|
*/
|
|
ve.ui.MWReferencesListCommand = function VeUiMWReferencesListCommand() {
|
|
// Parent constructor
|
|
ve.ui.MWReferencesListCommand.super.call(
|
|
this, 'referencesList', null, null,
|
|
{ supportedSelections: [ 'linear' ] }
|
|
);
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.MWReferencesListCommand, ve.ui.Command );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.MWReferencesListCommand.prototype.execute = function ( surface ) {
|
|
var
|
|
fragment = surface.getModel().getFragment(),
|
|
selectedNode = fragment.getSelectedNode(),
|
|
isReflistNodeSelected = selectedNode && selectedNode instanceof ve.dm.MWReferencesListNode;
|
|
|
|
if ( isReflistNodeSelected ) {
|
|
return surface.execute( 'window', 'open', 'referencesList' );
|
|
} else {
|
|
fragment.collapseToEnd().insertContent( [
|
|
{
|
|
type: 'mwReferencesList',
|
|
attributes: {
|
|
listGroup: 'mwReference/',
|
|
refGroup: ''
|
|
}
|
|
},
|
|
{ type: '/mwReferencesList' }
|
|
] );
|
|
return true;
|
|
}
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ui.commandRegistry.register( new ve.ui.MWReferencesListCommand() );
|