Debian Codegraph @

extensions/Cite/modules/ve-cite/ve.ui.MWReferencesListCommand.js

raw symbols SCIP
1 'use strict';
2
3 /*!
4 * VisualEditor UserInterface MediaWiki ReferencesListCommand class.
5 *
6 * @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt
7 * @license MIT
8 */
9
10 /**
11 * References list command.
12 *
13 * If a references list node is selected, opens the dialog to edit it.
14 * Otherwise inserts the references list for the default group.
15 *
16 * @constructor
17 * @extends ve.ui.Command
18 */
19 ve.ui.MWReferencesListCommand = function VeUiMWReferencesListCommand() {
20 // Parent constructor
21 ve.ui.MWReferencesListCommand.super.call(
22 this, 'referencesList', null, null,
23 { supportedSelections: [ 'linear' ] }
24 );
25 };
26
27 /* Inheritance */
28
29 OO.inheritClass( ve.ui.MWReferencesListCommand, ve.ui.Command );
30
31 /* Methods */
32
33 /**
34 * @override
35 */
36 ve.ui.MWReferencesListCommand.prototype.execute = function ( surface ) {
37 const fragment = surface.getModel().getFragment();
38 const selectedNode = fragment.getSelectedNode();
39 const isReflistNodeSelected = selectedNode &&
40 selectedNode instanceof ve.dm.MWReferencesListNode;
41
42 if ( isReflistNodeSelected ) {
43 return surface.execute( 'window', 'open', 'referencesList' );
44 } else {
45 fragment.collapseToEnd().insertContent( [
46 {
47 type: 'mwReferencesList',
48 attributes: {
49 listGroup: 'mwReference/',
50 refGroup: '',
51 isResponsive: mw.config.get( 'wgCiteResponsiveReferences' )
52 }
53 },
54 { type: '/mwReferencesList' }
55 ] );
56 return true;
57 }
58 };
59
60 /* Registration */
61
62 ve.ui.commandRegistry.register( new ve.ui.MWReferencesListCommand() );