Index: trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js |
— | — | @@ -96,19 +96,6 @@ |
97 | 97 | this.data.splice( this.cursor, op.data.length ); |
98 | 98 | } |
99 | 99 | |
100 | | - function indexOfAnnotation( character, annotation ) { |
101 | | - if ( $.isArray( character ) ) { |
102 | | - // Find the index of a comparable annotation (checking for same value, not reference) |
103 | | - var index; |
104 | | - for ( var i = 0; i < character.length; i++ ) { |
105 | | - if ( character[i].hash === op.annotation.hash ) { |
106 | | - return index; |
107 | | - } |
108 | | - } |
109 | | - } |
110 | | - return -1; |
111 | | - } |
112 | | - |
113 | 100 | function attribute( op, invert ) { |
114 | 101 | var element = this.data[this.cursor]; |
115 | 102 | if ( element.type === undefined ) { |
— | — | @@ -158,7 +145,7 @@ |
159 | 146 | for ( var i = 0, length = this.clear.length; i < length; i++ ) { |
160 | 147 | var annotation = this.clear[i]; |
161 | 148 | for ( var j = this.cursor; j < to; j++ ) { |
162 | | - var index = indexOfAnnotation( this.data[j], annotation ); |
| 149 | + var index = es.DocumentModel.getIndexOfAnnotation( this.data[j], annotation ); |
163 | 150 | if ( index !== -1 ) { |
164 | 151 | this.data[j].splice( index, 1 ); |
165 | 152 | } |
— | — | @@ -181,7 +168,7 @@ |
182 | 169 | if ( op.bias === 'start' ) { |
183 | 170 | target.push( op.annotation ); |
184 | 171 | } else if ( op.bias === 'end' ) { |
185 | | - var index = indexOfAnnotation( target[i], op.annotation ); |
| 172 | + var index = es.DocumentModel.getIndexOfAnnotation( target[i], op.annotation ); |
186 | 173 | if ( index === -1 ) { |
187 | 174 | throw 'Annotation stack error. Annotation is missing.'; |
188 | 175 | } |
— | — | @@ -271,6 +258,19 @@ |
272 | 259 | return hash; |
273 | 260 | }; |
274 | 261 | |
| 262 | +es.DocumentModel.getIndexOfAnnotation = function( character, annotation ) { |
| 263 | + if ( $.isArray( character ) ) { |
| 264 | + // Find the index of a comparable annotation (checking for same value, not reference) |
| 265 | + var index; |
| 266 | + for ( var i = 0; i < character.length; i++ ) { |
| 267 | + if ( character[i].hash === op.annotation.hash ) { |
| 268 | + return index; |
| 269 | + } |
| 270 | + } |
| 271 | + } |
| 272 | + return -1; |
| 273 | +}; |
| 274 | + |
275 | 275 | /** |
276 | 276 | * Creates an es.ContentModel object from a plain content object. |
277 | 277 | * |