r92654 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92653‎ | r92654 | r92655 >
Date:18:18, 20 July 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Added Range object which is used by getWordBoundaries and the new getSectionBoundaries, which will provide a way to get the boundaries of a single list item in the future - paragraphs only have 1 section however. Also tweaked the double click rate.
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.Block.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Content.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.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js
@@ -87,8 +87,26 @@
8888 this.content.annotate( method, annotation, start, end );
8989 };
9090
 91+/**
 92+ * Gets the start and end points of the word closest a given offset.
 93+ *
 94+ * @param offset {Integer} Offset to find word nearest to
 95+ * @return {Object} Range object of boundaries
 96+ */
9197 Block.prototype.getWordBoundaries = function( offset ) {
9298 return this.content.getWordBoundaries( offset );
9399 };
94100
 101+/**
 102+ * Gets the start and end points of the section closest a given offset.
 103+ *
 104+ * For a paragraph, there's only one section.
 105+ *
 106+ * @param offset {Integer} Offset to find section nearest to
 107+ * @return {Object} Range object of boundaries
 108+ */
 109+Block.prototype.getSectionBoundaries = function( offset ) {
 110+ return new Range( 0, this.content.getLength() );
 111+};
 112+
95113 extend( ParagraphBlock, Block );
Index: trunk/parsers/wikidom/lib/es/es.js
@@ -31,6 +31,18 @@
3232 }
3333
3434 /**
 35+ * Range of content.
 36+ *
 37+ * @param start {Integer} Starting point
 38+ * @param end {Integer} Ending point
 39+ * @returns {Range}
 40+ */
 41+function Range( start, end ) {
 42+ this.start = start || null;
 43+ this.end = end || null;
 44+}
 45+
 46+/**
3547 * Pixel position, a 2D position within a rendered document.
3648 *
3749 * This can also support an optional bottom field, to represent a vertical line, such as a cursor.
Index: trunk/parsers/wikidom/lib/es/es.Surface.js
@@ -15,7 +15,7 @@
1616 this.mouse = {
1717 'selecting': false,
1818 'clicks': 0,
19 - 'clickDelay': 200,
 19+ 'clickDelay': 500,
2020 'clickTimeout': null,
2121 'clickX': null,
2222 'clickY': null
@@ -285,18 +285,19 @@
286286 break;
287287 case 2:
288288 // Select word offset is within
289 - var wordBoundaries = this.location.block.getWordBoundaries( this.location.offset );
 289+ var boundaries = this.location.block.getWordBoundaries( this.location.offset );
290290 this.selection = new Selection(
291 - new Location( this.location.block, wordBoundaries.start ),
292 - new Location( this.location.block, wordBoundaries.end )
 291+ new Location( this.location.block, boundaries.start ),
 292+ new Location( this.location.block, boundaries.end )
293293 );
294294 this.drawSelection();
295295 break;
296296 case 3:
297 - // Select block offset is within
 297+ // Select section within block offset is within
 298+ var boundaries = this.location.block.getSectionBoundaries( this.location.offset );
298299 this.selection = new Selection(
299 - new Location( this.location.block, 0 ),
300 - new Location( this.location.block, this.location.block.getLength() )
 300+ new Location( this.location.block, boundaries.start ),
 301+ new Location( this.location.block, boundaries.end )
301302 );
302303 this.drawSelection();
303304 break;
Index: trunk/parsers/wikidom/lib/es/es.Block.js
@@ -108,8 +108,24 @@
109109 throw 'Block.annotateContent not implemented in this subclass.';
110110 };
111111
 112+/**
 113+ * Gets the start and end points of the word closest a given offset.
 114+ *
 115+ * @param offset {Integer} Offset to find word nearest to
 116+ * @return {Object} Range object of boundaries
 117+ */
112118 Block.prototype.getWordBoundaries = function( offset ) {
113119 throw 'Block.getWordBoundaries not implemented in this subclass.';
114120 };
115121
 122+/**
 123+ * Gets the start and end points of the section closest a given offset.
 124+ *
 125+ * @param offset {Integer} Offset to find section nearest to
 126+ * @return {Object} Range object of boundaries
 127+ */
 128+Block.prototype.getSectionBoundaries = function( offset ) {
 129+ throw 'Block.getSectionBoundaries not implemented in this subclass.';
 130+};
 131+
116132 extend( Block, EventEmitter );
Index: trunk/parsers/wikidom/lib/es/es.Content.js
@@ -531,6 +531,12 @@
532532 return out;
533533 };
534534
 535+/**
 536+ * Gets the start and end points of the word closest a given offset.
 537+ *
 538+ * @param offset {Integer} Offset to find word nearest to
 539+ * @return {Object} Range object of boundaries
 540+ */
535541 Content.prototype.getWordBoundaries = function( offset ) {
536542 if ( offset < 0 || offset > this.data.length ) {
537543 throw 'Out of bounds error. Offset expected to be >= 0 and <= to ' + this.data.length;
@@ -553,10 +559,7 @@
554560 }
555561 end++;
556562 }
557 - return {
558 - 'start': start,
559 - 'end': end
560 - };
 563+ return new Range( start, end );
561564 };
562565
563566 Content.prototype.getLines = function() {

Status & tagging log