All files / src/ui/tools ve.ui.WindowTool.js

58.33% Statements 14/24
0% Branches 0/6
0% Functions 0/3
58.33% Lines 14/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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