Debian Codegraph @

extensions/VisualEditor/lib/ve/src/ui/tools/ve.ui.WindowTool.js

raw symbols SCIP
1 /*!
2 * VisualEditor UserInterface WindowTool class.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * UserInterface dialog tool.
9 *
10 * @abstract
11 * @class
12 * @extends ve.ui.Tool
13 * @constructor
14 * @param {OO.ui.ToolGroup} toolGroup
15 * @param {Object} [config] Configuration options
16 */
17 ve.ui.WindowTool = function VeUiWindowTool() {
18 // Parent constructor
19 ve.ui.WindowTool.super.apply( this, arguments );
20 };
21
22 /* Inheritance */
23
24 OO.inheritClass( ve.ui.WindowTool, ve.ui.Tool );
25
26 /* Static Properties */
27
28 /**
29 * Name of the associated windows, if there is more than one possible value, or if it can't be
30 * deduced from the tool's command.
31 *
32 * @static
33 * @property {string[]}
34 * @inheritable
35 */
36 ve.ui.WindowTool.static.associatedWindows = null;
37
38 /* Methods */
39
40 /**
41 * @inheritdoc
42 */
43 ve.ui.WindowTool.prototype.onUpdateState = function ( fragment, contextDirection, activeDialogs ) {
44 let myWindowNames = [];
45
46 // Parent method
47 ve.ui.WindowTool.super.prototype.onUpdateState.apply( this, arguments );
48
49 if ( this.constructor.static.associatedWindows !== null ) {
50 myWindowNames = this.constructor.static.associatedWindows;
51 } else {
52 const command = this.getCommand();
53 if ( command && command.getAction() === 'window' ) {
54 myWindowNames = [ command.getArgs()[ 0 ] ];
55 }
56 }
57
58 // Show the tool as active if any of its associated windows is open
59 this.setActive( $( activeDialogs ).filter( myWindowNames ).length !== 0 );
60 };
61
62 // Deprecated alias
63 ve.ui.DialogTool = ve.ui.WindowTool;
64
65 /**
66 * Command help tool.
67 *
68 * @class
69 * @extends ve.ui.WindowTool
70 * @constructor
71 * @param {OO.ui.ToolGroup} toolGroup
72 * @param {Object} [config] Configuration options
73 */
74 ve.ui.CommandHelpDialogTool = function VeUiCommandHelpDialogTool() {
75 ve.ui.CommandHelpDialogTool.super.apply( this, arguments );
76 };
77 OO.inheritClass( ve.ui.CommandHelpDialogTool, ve.ui.WindowTool );
78 ve.ui.CommandHelpDialogTool.static.name = 'commandHelp';
79 ve.ui.CommandHelpDialogTool.static.group = 'help';
80 ve.ui.CommandHelpDialogTool.static.icon = 'keyboard';
81 ve.ui.CommandHelpDialogTool.static.title =
82 OO.ui.deferMsg( 'visualeditor-dialog-command-help-title' );
83 ve.ui.CommandHelpDialogTool.static.autoAddToCatchall = false;
84 ve.ui.CommandHelpDialogTool.static.commandName = 'commandHelp';
85 ve.ui.toolFactory.register( ve.ui.CommandHelpDialogTool );