r91625 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91624‎ | r91625 | r91626 >
Date:00:42, 7 July 2011
Author:inez
Status:deferred
Tags:
Comment:
Make navigating between blocks (with cursor left and right) works
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.Block.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Surface.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.TextFlow.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js
@@ -12,6 +12,10 @@
1313 this.updateText();
1414 }
1515
 16+Block.prototype.getLength = function() {
 17+ return this.flow.length;
 18+};
 19+
1620 /**
1721 * Update text given to the flow object
1822 */
Index: trunk/parsers/wikidom/lib/es/es.Surface.js
@@ -221,10 +221,10 @@
222222 */
223223 Surface.prototype.moveCursorRight = function() {
224224 var location = this.getCursor();
225 - if ( 1 || location.block.length > location.offset + 1 ) {
 225+ if ( location.block.getLength() > location.offset + 1 ) {
226226 location.offset++;
227227 } else {
228 - var next = location.block.next();
 228+ var next = location.block.nextBlock();
229229 if ( next ) {
230230 location.block = next;
231231 location.offset = 0;
@@ -241,10 +241,10 @@
242242 if ( location.offset > 0 ) {
243243 location.offset--;
244244 } else {
245 - var previous = location.block.previous();
 245+ var previous = location.block.previousBlock();
246246 if ( previous ) {
247247 location.block = previous;
248 - location.offset = location.block.length - 1;
 248+ location.offset = location.block.getLength() - 1;
249249 }
250250 }
251251 this.setCursor( location );
Index: trunk/parsers/wikidom/lib/es/es.Block.js
@@ -6,6 +6,10 @@
77 this.document = null;
88 }
99
 10+Block.prototype.getLength = function() {
 11+ throw 'Block.getLength not implemented in this subclass.';
 12+};
 13+
1014 /**
1115 * Gets the index of the block within it's document.
1216 *
@@ -28,7 +32,7 @@
2933 throw 'Missing document error. Block is not attached to a document.';
3034 }
3135 var index = this.index() + 1;
32 - return this.document.blocks.length < index ? this.document.blocks[index] : null;
 36+ return this.document.blocks.length > index ? this.document.blocks[index] : null;
3337 };
3438
3539 /**
Index: trunk/parsers/wikidom/lib/es/es.TextFlow.js
@@ -6,6 +6,7 @@
77 */
88 function TextFlow( $container, text ) {
99 this.$ = $container;
 10+ this.length = 0;
1011 this.boundaries = [];
1112 this.words = [];
1213 this.lines = [];
@@ -206,8 +207,10 @@
207208 this.boundaries.push( text.length );
208209 this.words.push( this.escape( text.substring( end, text.length ) ) );
209210 }
 211+ this.length = text.length;
210212 // Force re-flow
211213 this.width = null;
 214+
212215 };
213216
214217 /**

Status & tagging log