Index: trunk/extensions/VisualEditor/modules/es/es.Transaction.js |
— | — | @@ -11,10 +11,21 @@ |
12 | 12 | |
13 | 13 | /* Methods */ |
14 | 14 | |
| 15 | +/** |
| 16 | + * Gets a list of all operations. |
| 17 | + * |
| 18 | + * @method |
| 19 | + * @returns {Object[]} List of operations |
| 20 | + */ |
15 | 21 | es.Transaction.prototype.getOperations = function() { |
16 | 22 | return this.operations; |
17 | 23 | }; |
18 | 24 | |
| 25 | +/** |
| 26 | + * Merges consecutive operations of the same type. |
| 27 | + * |
| 28 | + * @method |
| 29 | + */ |
19 | 30 | es.Transaction.prototype.optimize = function() { |
20 | 31 | for ( var i = 0; i < this.operations.length - 1; i++ ) { |
21 | 32 | var a = this.operations[i]; |
— | — | @@ -35,6 +46,12 @@ |
36 | 47 | } |
37 | 48 | }; |
38 | 49 | |
| 50 | +/** |
| 51 | + * Adds a retain operation. |
| 52 | + * |
| 53 | + * @method |
| 54 | + * @param {Integer} length Length of content data to retain |
| 55 | + */ |
39 | 56 | es.Transaction.prototype.pushRetain = function( length ) { |
40 | 57 | this.operations.push( { |
41 | 58 | 'type': 'retain', |
— | — | @@ -42,13 +59,25 @@ |
43 | 60 | } ); |
44 | 61 | }; |
45 | 62 | |
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 ) { |
47 | 70 | this.operations.push( { |
48 | 71 | 'type': 'insert', |
49 | | - 'data': content |
| 72 | + 'data': data |
50 | 73 | } ); |
51 | 74 | }; |
52 | 75 | |
| 76 | +/** |
| 77 | + * Adds a removal operation. |
| 78 | + * |
| 79 | + * @method |
| 80 | + * @param {Array} data Data to remove |
| 81 | + */ |
53 | 82 | es.Transaction.prototype.pushRemove = function( data ) { |
54 | 83 | this.operations.push( { |
55 | 84 | 'type': 'remove', |
— | — | @@ -56,6 +85,14 @@ |
57 | 86 | } ); |
58 | 87 | }; |
59 | 88 | |
| 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 | + */ |
60 | 97 | es.Transaction.prototype.pushChangeElementAttribute = function( method, key, value ) { |
61 | 98 | this.operations.push( { |
62 | 99 | 'type': 'attribute', |
— | — | @@ -65,6 +102,13 @@ |
66 | 103 | } ); |
67 | 104 | }; |
68 | 105 | |
| 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 | + */ |
69 | 113 | es.Transaction.prototype.pushStartAnnotating = function( method, annotation ) { |
70 | 114 | this.operations.push( { |
71 | 115 | 'type': 'annotate', |
— | — | @@ -74,6 +118,13 @@ |
75 | 119 | } ); |
76 | 120 | }; |
77 | 121 | |
| 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 | + */ |
78 | 129 | es.Transaction.prototype.pushStopAnnotating = function( method, annotation ) { |
79 | 130 | this.operations.push( { |
80 | 131 | 'type': 'annotate', |