r102046 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102045‎ | r102046 | r102047 >
Date:21:06, 4 November 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Added documentation for es.Transaction
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/es.Transaction.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/es.Transaction.js
@@ -11,10 +11,21 @@
1212
1313 /* Methods */
1414
 15+/**
 16+ * Gets a list of all operations.
 17+ *
 18+ * @method
 19+ * @returns {Object[]} List of operations
 20+ */
1521 es.Transaction.prototype.getOperations = function() {
1622 return this.operations;
1723 };
1824
 25+/**
 26+ * Merges consecutive operations of the same type.
 27+ *
 28+ * @method
 29+ */
1930 es.Transaction.prototype.optimize = function() {
2031 for ( var i = 0; i < this.operations.length - 1; i++ ) {
2132 var a = this.operations[i];
@@ -35,6 +46,12 @@
3647 }
3748 };
3849
 50+/**
 51+ * Adds a retain operation.
 52+ *
 53+ * @method
 54+ * @param {Integer} length Length of content data to retain
 55+ */
3956 es.Transaction.prototype.pushRetain = function( length ) {
4057 this.operations.push( {
4158 'type': 'retain',
@@ -42,13 +59,25 @@
4360 } );
4461 };
4562
46 -es.Transaction.prototype.pushInsert = function( content ) {
 63+/**
 64+ * Adds an insertion operation.
 65+ *
 66+ * @method
 67+ * @param {Array} data Data to retain
 68+ */
 69+es.Transaction.prototype.pushInsert = function( data ) {
4770 this.operations.push( {
4871 'type': 'insert',
49 - 'data': content
 72+ 'data': data
5073 } );
5174 };
5275
 76+/**
 77+ * Adds a removal operation.
 78+ *
 79+ * @method
 80+ * @param {Array} data Data to remove
 81+ */
5382 es.Transaction.prototype.pushRemove = function( data ) {
5483 this.operations.push( {
5584 'type': 'remove',
@@ -56,6 +85,14 @@
5786 } );
5887 };
5988
 89+/**
 90+ * Adds an element attribute change operation.
 91+ *
 92+ * @method
 93+ * @param {String} method Method to use, either "set" or "clear"
 94+ * @param {String} key Name of attribute to change
 95+ * @param {Mixed} value Value to set attribute to, or value of attribute being cleared
 96+ */
6097 es.Transaction.prototype.pushChangeElementAttribute = function( method, key, value ) {
6198 this.operations.push( {
6299 'type': 'attribute',
@@ -65,6 +102,13 @@
66103 } );
67104 };
68105
 106+/**
 107+ * Adds a start annotating operation.
 108+ *
 109+ * @method
 110+ * @param {String} method Method to use, either "set" or "clear"
 111+ * @param {Object} annotation Annotation object to start setting or clearing from content data
 112+ */
69113 es.Transaction.prototype.pushStartAnnotating = function( method, annotation ) {
70114 this.operations.push( {
71115 'type': 'annotate',
@@ -74,6 +118,13 @@
75119 } );
76120 };
77121
 122+/**
 123+ * Adds a stop annotating operation.
 124+ *
 125+ * @method
 126+ * @param {String} method Method to use, either "set" or "clear"
 127+ * @param {Object} annotation Annotation object to stop setting or clearing from content data
 128+ */
78129 es.Transaction.prototype.pushStopAnnotating = function( method, annotation ) {
79130 this.operations.push( {
80131 'type': 'annotate',

Status & tagging log