r91701 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91700‎ | r91701 | r91702 >
Date:00:16, 8 July 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Prevent calling rendering while rendering is already taking place, and automatically re-render if something changed while rendering was taking place.
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js
@@ -10,6 +10,8 @@
1111 .data( 'block', this );
1212 this.flow = new TextFlow( this.$ );
1313 this.updateText();
 14+ this.rendering = false;
 15+ this.reRender = false;
1416 }
1517
1618 Block.prototype.getLength = function() {
@@ -45,7 +47,7 @@
4648 lineOffset += this.lines[i].text.length;
4749 }
4850 this.updateText();
49 - this.flow.render();
 51+ this.renderContent();
5052 };
5153
5254 /**
@@ -96,7 +98,7 @@
9799 this.lines.splice( from.index + 1, to.index - from.index );
98100 }
99101 this.updateText();
100 - this.flow.render();
 102+ this.renderContent();
101103 };
102104
103105 /**
@@ -105,7 +107,20 @@
106108 * @param $container {jQuery Selection} Container to render into
107109 */
108110 ParagraphBlock.prototype.renderContent = function() {
109 - this.flow.render();
 111+ if ( !this.rendering ) {
 112+ this.rendering = true;
 113+ var block = this;
 114+ this.flow.render( 0, function() {
 115+ block.rendering = false;
 116+ var reRender = block.reRender;
 117+ block.reRender = false;
 118+ if ( reRender ) {
 119+ block.renderContent();
 120+ }
 121+ });
 122+ } else {
 123+ this.reRender = true;
 124+ }
110125 };
111126
112127 /**

Status & tagging log