r92442 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92441‎ | r92442 | r92443 >
Date:15:54, 18 July 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Fixed scanBoundaries being called after render instead of before, because change events are later than insert/delete/annotate
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.TextFlow.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.TextFlow.js
@@ -22,16 +22,16 @@
2323
2424 // Events
2525 var flow = this;
26 - this.content.on( 'change', function() {
 26+ this.content.on( 'insert', function( args ) {
2727 flow.scanBoundaries();
28 - } );
29 - this.content.on( 'insert', function( args ) {
3028 flow.render( args.offset );
3129 } );
3230 this.content.on( 'remove', function( args ) {
 31+ flow.scanBoundaries();
3332 flow.render( args.start );
3433 } );
3534 this.content.on( 'annotate', function( args ) {
 35+ flow.scanBoundaries();
3636 flow.render( args.start );
3737 } );
3838
@@ -239,6 +239,7 @@
240240 if ( rs.wordFit.width > rs.width ) {
241241 // The first word didn't fit, we need to split it up
242242 rs.charOffset = rs.lineStart;
 243+ var lineOffset = rs.wordOffset;
243244 rs.wordOffset++;
244245 rs.lineEnd = this.boundaries[rs.wordOffset];
245246 do {
@@ -250,20 +251,21 @@
251252 rs.wordOffset, rs.wordCount - 1, rs.ruler, rs.width - rs.charFit.width
252253 );
253254 if ( rs.wordFit.end > rs.wordOffset ) {
 255+ lineOffset = rs.wordOffset;
254256 rs.wordOffset = rs.wordFit.end;
255257 rs.charFit.end = rs.lineEnd = this.boundaries[rs.wordOffset];
256258 }
257259 }
258 - this.appendLine( rs.charOffset, rs.charFit.end, rs.wordOffset, fractional );
 260+ this.appendLine( rs.charOffset, rs.charFit.end, lineOffset, fractional );
259261 // Move on to another line
260262 rs.charOffset = rs.charFit.end;
261263 // Mark the next line as fractional
262264 fractional = true;
263265 } while ( rs.charOffset < rs.lineEnd );
264266 } else {
 267+ rs.lineEnd = this.boundaries[rs.wordFit.end];
 268+ this.appendLine( rs.lineStart, rs.lineEnd, rs.wordOffset, fractional );
265269 rs.wordOffset = rs.wordFit.end;
266 - rs.lineEnd = this.boundaries[rs.wordOffset];
267 - this.appendLine( rs.lineStart, rs.lineEnd, rs.wordOffset, fractional );
268270 }
269271 rs.lineStart = rs.lineEnd;
270272 }
@@ -276,7 +278,6 @@
277279 .nextAll()
278280 .remove();
279281 rs.timeout = undefined;
280 - console.log( this.lines.length );
281282 this.emit( 'render' );
282283 } else {
283284 rs.ruler.innerHTML = '';

Status & tagging log