mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-18 11:46:01 +00:00
61ddfb76e4
Objective: * Make ve.Factory behave like ve.NamedClassFactory * Remove the only remaining use of ve.Factory (actions) * Remove ve.NamedClassFactory Change-Id: Ie302ef5ea31081de7ab0db6091058a59946aef4c
66 lines
1.2 KiB
JavaScript
66 lines
1.2 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface HistoryAction class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* History action.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.Action
|
|
* @constructor
|
|
* @param {ve.ui.Surface} surface Surface to act on
|
|
*/
|
|
ve.ui.HistoryAction = function VeUiHistoryAction( surface ) {
|
|
// Parent constructor
|
|
ve.ui.Action.call( this, surface );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ui.HistoryAction, ve.ui.Action );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.ui.HistoryAction.static.name = 'history';
|
|
|
|
/**
|
|
* List of allowed methods for the action.
|
|
*
|
|
* @static
|
|
* @property
|
|
*/
|
|
ve.ui.HistoryAction.static.methods = [ 'undo', 'redo' ];
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Step backwards in time.
|
|
*
|
|
* @method
|
|
*/
|
|
ve.ui.HistoryAction.prototype.undo = function () {
|
|
var range = this.surface.getModel().undo();
|
|
if ( range ) {
|
|
this.surface.getModel().change( null, range );
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Step forwards in time.
|
|
*
|
|
* @method
|
|
*/
|
|
ve.ui.HistoryAction.prototype.redo = function () {
|
|
var range = this.surface.getModel().redo();
|
|
if ( range ) {
|
|
this.surface.getModel().change( null, range );
|
|
}
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ui.actionFactory.register( ve.ui.HistoryAction );
|