Index: trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js |
— | — | @@ -87,8 +87,26 @@ |
88 | 88 | this.content.annotate( method, annotation, start, end ); |
89 | 89 | }; |
90 | 90 | |
| 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 | + */ |
91 | 97 | Block.prototype.getWordBoundaries = function( offset ) { |
92 | 98 | return this.content.getWordBoundaries( offset ); |
93 | 99 | }; |
94 | 100 | |
| 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 | + |
95 | 113 | extend( ParagraphBlock, Block ); |
Index: trunk/parsers/wikidom/lib/es/es.js |
— | — | @@ -31,6 +31,18 @@ |
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
| 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 | +/** |
35 | 47 | * Pixel position, a 2D position within a rendered document. |
36 | 48 | * |
37 | 49 | * 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 @@ |
16 | 16 | this.mouse = { |
17 | 17 | 'selecting': false, |
18 | 18 | 'clicks': 0, |
19 | | - 'clickDelay': 200, |
| 19 | + 'clickDelay': 500, |
20 | 20 | 'clickTimeout': null, |
21 | 21 | 'clickX': null, |
22 | 22 | 'clickY': null |
— | — | @@ -285,18 +285,19 @@ |
286 | 286 | break; |
287 | 287 | case 2: |
288 | 288 | // 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 ); |
290 | 290 | 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 ) |
293 | 293 | ); |
294 | 294 | this.drawSelection(); |
295 | 295 | break; |
296 | 296 | 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 ); |
298 | 299 | 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 ) |
301 | 302 | ); |
302 | 303 | this.drawSelection(); |
303 | 304 | break; |
Index: trunk/parsers/wikidom/lib/es/es.Block.js |
— | — | @@ -108,8 +108,24 @@ |
109 | 109 | throw 'Block.annotateContent not implemented in this subclass.'; |
110 | 110 | }; |
111 | 111 | |
| 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 | + */ |
112 | 118 | Block.prototype.getWordBoundaries = function( offset ) { |
113 | 119 | throw 'Block.getWordBoundaries not implemented in this subclass.'; |
114 | 120 | }; |
115 | 121 | |
| 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 | + |
116 | 132 | extend( Block, EventEmitter ); |
Index: trunk/parsers/wikidom/lib/es/es.Content.js |
— | — | @@ -531,6 +531,12 @@ |
532 | 532 | return out; |
533 | 533 | }; |
534 | 534 | |
| 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 | + */ |
535 | 541 | Content.prototype.getWordBoundaries = function( offset ) { |
536 | 542 | if ( offset < 0 || offset > this.data.length ) { |
537 | 543 | throw 'Out of bounds error. Offset expected to be >= 0 and <= to ' + this.data.length; |
— | — | @@ -553,10 +559,7 @@ |
554 | 560 | } |
555 | 561 | end++; |
556 | 562 | } |
557 | | - return { |
558 | | - 'start': start, |
559 | | - 'end': end |
560 | | - }; |
| 563 | + return new Range( start, end ); |
561 | 564 | }; |
562 | 565 | |
563 | 566 | Content.prototype.getLines = function() { |