All files / src/ui/actions ve.ui.HistoryAction.js

58.33% Statements 7/12
100% Branches 0/0
0% Functions 0/3
58.33% Lines 7/12

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                                1x             1x       1x   1x                 1x                   1x             1x  
/*!
 * VisualEditor UserInterface HistoryAction class.
 *
 * @copyright See AUTHORS.txt
 */
 
/**
 * History action.
 *
 * @class
 * @extends ve.ui.Action
 *
 * @constructor
 * @param {ve.ui.Surface} surface Surface to act on
 * @param {string} [source]
 */
ve.ui.HistoryAction = function VeUiHistoryAction() {
	// Parent constructor
	ve.ui.HistoryAction.super.apply( this, arguments );
};
 
/* Inheritance */
 
OO.inheritClass( ve.ui.HistoryAction, ve.ui.Action );
 
/* Static Properties */
 
ve.ui.HistoryAction.static.name = 'history';
 
ve.ui.HistoryAction.static.methods = [ 'undo', 'redo' ];
 
/* Methods */
 
/**
 * Step backwards in time.
 *
 * @return {boolean} Action was executed
 */
ve.ui.HistoryAction.prototype.undo = function () {
	this.surface.getModel().undo();
	return true;
};
 
/**
 * Step forwards in time.
 *
 * @return {boolean} Action was executed
 */
ve.ui.HistoryAction.prototype.redo = function () {
	this.surface.getModel().redo();
	return true;
};
 
/* Registration */
 
ve.ui.actionFactory.register( ve.ui.HistoryAction );