mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-28 00:40:12 +00:00
18f616b9b8
This code has been developed over three years now in the repo of MediaWiki's integration of VisualEditor. It has grown and developed significantly during that time, but now is pretty stable. A number of hacks inside the MediaWiki- VisualEditor code base have been used to prevent this code from being loaded on wikis where the Cite extension is not deployed, but this state of affairs is and always was meant to be temporary. This code is under the MIT licence which is a tad messy, but not impossible. It's clearly labelled as such. The list of authors has been updated to take into account the influx of new functionality. Bug: T41621 Bug: T104928 Change-Id: I39936ed83d5a60471a0a75da753f498e80aef234
61 lines
1.4 KiB
JavaScript
61 lines
1.4 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface MediaWiki ReferencesListCommand class.
|
|
*
|
|
* @copyright 2011-2016 VisualEditor Team and others; see http://ve.mit-license.org
|
|
*/
|
|
|
|
/**
|
|
* 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() );
|