| 1 | /*! |
| 2 | * VisualEditor UserInterface Action class. |
| 3 | * |
| 4 | * @copyright See AUTHORS.txt |
| 5 | */ |
| 6 | |
| 7 | /** |
| 8 | * Generic action. |
| 9 | * |
| 10 | * An action is built around a surface for one-time use. It is a generic way of extending the |
| 11 | * functionality of a surface. Actions are accessible via {ve.ui.Surface.prototype.execute}. |
| 12 | * |
| 13 | * @class |
| 14 | * |
| 15 | * @constructor |
| 16 | * @param {ve.ui.Surface} surface Surface to act on |
| 17 | * @param {string} [source] Label for the source of the action. |
| 18 | * One of 'trigger', 'sequence', 'tool', or 'context' |
| 19 | */ |
| 20 | ve.ui.Action = function VeUiAction( surface, source ) { |
| 21 | // Properties |
| 22 | this.surface = surface; |
| 23 | this.source = source; |
| 24 | }; |
| 25 | |
| 26 | /* Inheritance */ |
| 27 | |
| 28 | OO.initClass( ve.ui.Action ); |
| 29 | |
| 30 | /* Static Properties */ |
| 31 | |
| 32 | /** |
| 33 | * @property {string[]} List of allowed methods for the action. |
| 34 | * |
| 35 | * To avoid use of methods not intended to be executed via surface.execute(), the allowed methods |
| 36 | * must be listed here. This information is checked by ve.ui.Surface before executing an action. |
| 37 | * |
| 38 | * If a method returns a value, it will be cast to boolean and be used to determine if the action |
| 39 | * was canceled. Not returning anything, or returning undefined will be treated the same as |
| 40 | * returning true. A canceled action will yield to other default behavior. For example, when |
| 41 | * triggering an action from a keystroke, a canceled action will allow normal insertion behavior to |
| 42 | * be carried out. |
| 43 | * |
| 44 | * @static |
| 45 | * @inheritable |
| 46 | */ |
| 47 | ve.ui.Action.static.methods = []; |