mediawiki-extensions-Visual.../modules/ve/ve.ActionFactory.js
Trevor Parscal 735ed96f5f Add ve.Action, ve.ActionFactory, subclasses
Moved implementation of all the tools into a reusable action
system. To execute an action just call

surface.execute( actionName, method, param1, param2, ... );

This helps keep tools simple, and opens the door to key commands
reusing the same code.

Change-Id: Ie786fa3d38d1ea17d39b5dfb8eeeb5f2256267ce
2012-10-26 14:44:17 -07:00

44 lines
956 B
JavaScript

/**
* VisualEditor ActionFactory class.
*
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* Action factory.
*
* @class
* @constructor
* @extends {ve.Factory}
*/
ve.ActionFactory = function VeActionFactory() {
// Parent constructor
ve.Factory.call( this );
};
/* Inheritance */
ve.inheritClass( ve.ActionFactory, ve.Factory );
/* Methods */
/**
* Checks if a given action supports a given method.
*
* @method
* @param {String} action Name of action
* @param {String} method Name of method
* @returns {Boolean} The action supports the method
*/
ve.ActionFactory.prototype.doesActionSupportMethod = function ( action, method ) {
if ( action in this.registry ) {
return this.registry[action].static.methods.indexOf( method ) !== -1;
}
throw new Error( 'Unknown action: ' + action );
};
/* Initialization */
ve.actionFactory = new ve.ActionFactory();