r94916 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94915‎ | r94916 | r94917 >
Date:18:47, 18 August 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Added docuementation
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.Transaction.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.Transaction.js
@@ -4,6 +4,25 @@
55 * Transactions contain a series of operations, such as retain, insert, remove, start and end. Each
66 * operation describes a step that must be taken to construct a new version of a content object.
77 *
 8+ * @example
 9+ * // Given the following content...
 10+ * var content = es.Content.newFromText( 'abc' );
 11+ *
 12+ * // Build transaction
 13+ * var tx = new es.Transaction();
 14+ * tx.add( 'retain', 1 );
 15+ * tx.add( 'remove', content.getData( new es.Range( 1, 2 ) ) );
 16+ * tx.add( 'insert', es.Content.newFromText( 'B' ) );
 17+ * tx.add( 'retain', 1 );
 18+ *
 19+ * // Commit transaction to content
 20+ * var committed = tx.commit( content );
 21+ * console.log( committed.getText() ); // Logs "aBc"
 22+ *
 23+ * // Apply transaction to content
 24+ * var rolledback = tx.rollback( content );
 25+ * console.log( rolledback.getText() ); // Logs "abc"
 26+ *
827 * @class
928 * @constructor
1029 * @param content {es.Content} Content to operate on

Status & tagging log