Emit a transact event on the ve.dm.Document when a transaction occurs

We'll need this to let a MetaList observe a Document and adjust to changes.
We should probably also have SurfaceFragment listen to this event instead.

Change-Id: I9e811e242969eb44afe0b4fa8153d0fb1b0071cd
This commit is contained in:
Catrope 2013-03-14 21:03:13 -07:00
parent 031b96dd2a
commit dadf005a67
3 changed files with 17 additions and 0 deletions

View file

@ -147,6 +147,14 @@ ve.dm.Document = function VeDmDocument( data, parentDocument ) {
ve.inheritClass( ve.dm.Document, ve.Document );
/* Events */
/**
* @event transact
* @param {ve.dm.Transaction} tx Transaction that was just processed
* @param {boolean} reversed Whether the transaction was processed in reverse
*/
/* Static methods */
/**

View file

@ -144,6 +144,8 @@ ve.dm.TransactionProcessor.prototype.process = function () {
}
// Mark the transaction as committed or rolled back, as appropriate
this.transaction.toggleApplied();
// Emit an event on the document
this.document.emit( 'transact', this.transaction, this.reversed );
};
/**

View file

@ -9,14 +9,21 @@
* Generic document.
*
* @class
* @extends ve.EventEmitter
* @constructor
* @param {ve.Node} model Model to observe
*/
ve.Document = function VeDocument( documentNode ) {
// Parent constructor
ve.EventEmitter.call( this );
// Properties
this.documentNode = documentNode;
};
/* Inheritance */
ve.inheritClass( ve.Document, ve.EventEmitter );
/* Methods */
/**