mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-28 00:40:12 +00:00
1eb405eb54
Bug: T343220 Change-Id: I769f0bfaa5af14d6ea4861ea738b44c98feb6193
64 lines
1.5 KiB
JavaScript
64 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
/*!
|
|
* VisualEditor UserInterface MediaWiki ReferencesListCommand class.
|
|
*
|
|
* @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt
|
|
* @license MIT
|
|
*/
|
|
|
|
/**
|
|
* 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 ) {
|
|
const fragment = surface.getModel().getFragment();
|
|
const selectedNode = fragment.getSelectedNode();
|
|
const 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: '',
|
|
isResponsive: mw.config.get( 'wgCiteResponsiveReferences' )
|
|
}
|
|
},
|
|
{ type: '/mwReferencesList' }
|
|
] );
|
|
return true;
|
|
}
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ui.commandRegistry.register( new ve.ui.MWReferencesListCommand() );
|