Index: trunk/parsers/wikidom/lib/es/es.TextFlow.js |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | * @param text {String} Text to escape |
21 | 21 | * @return {String} HTML escaped text |
22 | 22 | */ |
23 | | -TextFlow.prototype.escape = function( text ) { |
| 23 | +TextFlow.prototype.escape = function( start, end ) { |
24 | 24 | return text |
25 | 25 | // Tags |
26 | 26 | .replace( /&/g, '&' ) |
— | — | @@ -80,9 +80,9 @@ |
81 | 81 | fit = this.fitCharacters( |
82 | 82 | this.lines[line].start, this.lines[line].end, ruler, position.left |
83 | 83 | ); |
84 | | - ruler.innerHTML = this.escape( this.content.substring( this.lines[line].start, fit.end ) ); |
| 84 | + ruler.innerHTML = this.escape( this.lines[line].start, fit.end ); |
85 | 85 | var left = ruler.clientWidth; |
86 | | - ruler.innerHTML = this.escape( this.content.substring( this.lines[line].start, fit.end + 1 ) ); |
| 86 | + ruler.innerHTML = this.escape( this.lines[line].start, fit.end + 1 ); |
87 | 87 | var right = ruler.clientWidth; |
88 | 88 | var center = Math.round( left + ( ( right - left ) / 2 ) ); |
89 | 89 | $ruler.remove(); |
— | — | @@ -158,9 +158,7 @@ |
159 | 159 | if ( this.lines[line].start < offset ) { |
160 | 160 | var $ruler = $( '<div class="editSurface-line"></div>' ).appendTo( this.$ ), |
161 | 161 | ruler = $ruler[0]; |
162 | | - ruler.innerHTML = this.escape( |
163 | | - this.lines[line].text.substring( 0, offset - this.lines[line].start ) |
164 | | - ); |
| 162 | + ruler.innerHTML = this.escape( this.lines[line].start, offset ); |
165 | 163 | position.left = ruler.clientWidth; |
166 | 164 | $ruler.remove(); |
167 | 165 | } |
— | — | @@ -295,13 +293,12 @@ |
296 | 294 | * @param end {Integer} Ending of text range for line |
297 | 295 | */ |
298 | 296 | TextFlow.prototype.appendLine = function( start, end ) { |
299 | | - var lineText = this.content.substring( start, end ); |
300 | 297 | $line = $( '<div class="editSurface-line" line-index="' |
301 | | - + this.lines.length + '">' + this.escape( lineText ) + '</div>' ) |
| 298 | + + this.lines.length + '">' + this.escape( start, end ) + '</div>' ) |
302 | 299 | .appendTo( this.$ ); |
303 | 300 | // Collect line information |
304 | 301 | this.lines.push({ |
305 | | - 'text': lineText, |
| 302 | + 'text': this.content.substring( start, end ), |
306 | 303 | 'start': start, |
307 | 304 | 'end': end, |
308 | 305 | 'width': $line.outerWidth(), |
— | — | @@ -339,9 +336,7 @@ |
340 | 337 | // Place "middle" directly in the center of "start" and "end" |
341 | 338 | middle = Math.ceil( ( start + end ) / 2 ); |
342 | 339 | // Prepare the line for measurement using pre-escaped HTML |
343 | | - ruler.innerHTML = this.escape( |
344 | | - this.content.substring( this.boundaries[offset], this.boundaries[middle] ) |
345 | | - ); |
| 340 | + ruler.innerHTML = this.escape( this.boundaries[offset], this.boundaries[middle] ); |
346 | 341 | // Test for over/under using width of the rendered line |
347 | 342 | if ( ( lineWidth = ruler.clientWidth ) > width ) { |
348 | 343 | // Detect impossible fit (the first word won't fit by itself) |
— | — | @@ -356,13 +351,6 @@ |
357 | 352 | start = middle; |
358 | 353 | } |
359 | 354 | } while ( start < end ); |
360 | | - // Final measurement if start isn't at middle |
361 | | - if ( start !== middle ) { |
362 | | - ruler.innerHTML = this.escape( |
363 | | - this.content.substring( this.boundaries[offset], this.boundaries[start] ) |
364 | | - ); |
365 | | - lineWidth = ruler.clientWidth; |
366 | | - } |
367 | 355 | return { 'end': start, 'width': lineWidth }; |
368 | 356 | }; |
369 | 357 | |
— | — | @@ -387,7 +375,7 @@ |
388 | 376 | // Place "middle" directly in the center of "start" and "end" |
389 | 377 | middle = Math.ceil( ( start + end ) / 2 ); |
390 | 378 | // Fill the line with a portion of the text, escaped as HTML |
391 | | - ruler.innerHTML = this.escape( this.content.substring( offset, middle ) ); |
| 379 | + ruler.innerHTML = this.escape( offset, middle ); |
392 | 380 | // Test for over/under using width of the rendered line |
393 | 381 | if ( ( lineWidth = ruler.clientWidth ) > width ) { |
394 | 382 | // Detect impossible fit (the first character won't fit by itself) |
— | — | @@ -402,10 +390,5 @@ |
403 | 391 | start = middle; |
404 | 392 | } |
405 | 393 | } while ( start < end ); |
406 | | - // Final measurement if start isn't at middle |
407 | | - if ( start !== middle ) { |
408 | | - ruler.innerHTML = this.escape( this.content.substring( offset, start ) ); |
409 | | - lineWidth = ruler.clientWidth; |
410 | | - } |
411 | 394 | return { 'end': start, 'width': lineWidth }; |
412 | 395 | }; |