mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 06:46:26 +00:00
get rid of separate undoState function
This commit is contained in:
parent
b7cc76acd8
commit
0f12bd9b59
|
@ -118,12 +118,12 @@ es.SurfaceModel.prototype.transact = function( transaction, combine ) {
|
||||||
* @param {Integer} Number of document-changing states to reverse
|
* @param {Integer} Number of document-changing states to reverse
|
||||||
*/
|
*/
|
||||||
es.SurfaceModel.prototype.undo = function( transactionsToUndo ) {
|
es.SurfaceModel.prototype.undo = function( transactionsToUndo ) {
|
||||||
/**
|
|
||||||
* Undo a state.
|
while ( transactionsToUndo ) {
|
||||||
* @return {Boolean} whether visible change was undone.
|
|
||||||
*/
|
|
||||||
function undoState( state ) {
|
|
||||||
var hadTransaction = false;
|
var hadTransaction = false;
|
||||||
|
|
||||||
|
var state = this.currentState;
|
||||||
|
|
||||||
var i = state.length - 1;
|
var i = state.length - 1;
|
||||||
while ( i-- ) {
|
while ( i-- ) {
|
||||||
if ( state[i] instanceof es.TransactionModel ) {
|
if ( state[i] instanceof es.TransactionModel ) {
|
||||||
|
@ -132,11 +132,7 @@ es.SurfaceModel.prototype.undo = function( transactionsToUndo ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.emit( 'undo', state );
|
this.emit( 'undo', state );
|
||||||
return hadTransaction;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ( transactionsToUndo ) {
|
|
||||||
var hadTransaction = undoState( this.currentState );
|
|
||||||
if ( hadTransaction ) {
|
if ( hadTransaction ) {
|
||||||
transactionsToUndo--;
|
transactionsToUndo--;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue