Index: trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.Surface.js |
— | — | @@ -108,7 +108,7 @@ |
109 | 109 | this.clearPollData(); |
110 | 110 | |
111 | 111 | // show cursor |
112 | | - _this.showCursorAt(range.to); |
| 112 | + _this.showCursor(range.to); |
113 | 113 | } else { |
114 | 114 | if ( method === 'set' ) { |
115 | 115 | this.addInsertionAnnotation( annotation ); |
— | — | @@ -183,7 +183,7 @@ |
184 | 184 | _this.clearPollData(); |
185 | 185 | |
186 | 186 | // place cursor |
187 | | - _this.showCursorAt( selection.start ); |
| 187 | + _this.showCursor( selection.start ); |
188 | 188 | }, 1 ); |
189 | 189 | } |
190 | 190 | }; |
— | — | @@ -214,7 +214,7 @@ |
215 | 215 | _this.clearPollData(); |
216 | 216 | |
217 | 217 | // place cursor |
218 | | - _this.showCursorAt( insertionPoint + _this.clipboard[key].length ); |
| 218 | + _this.showCursor( insertionPoint + _this.clipboard[key].length ); |
219 | 219 | } else { |
220 | 220 | alert('i can only handle copy/paste from hybrid surface. sorry. :('); |
221 | 221 | } |
— | — | @@ -424,7 +424,7 @@ |
425 | 425 | newOffset = this.documentView.model.getRelativeContentOffset( |
426 | 426 | globalOffset, -1 |
427 | 427 | ); |
428 | | - this.showCursorAt(newOffset); |
| 428 | + this.showCursor(newOffset); |
429 | 429 | e.preventDefault(); |
430 | 430 | } |
431 | 431 | } |
— | — | @@ -440,7 +440,7 @@ |
441 | 441 | newOffset = this.documentView.model.getRelativeContentOffset( |
442 | 442 | globalOffset, 1 |
443 | 443 | ); |
444 | | - this.showCursorAt(newOffset); |
| 444 | + this.showCursor(newOffset); |
445 | 445 | e.preventDefault(); |
446 | 446 | } |
447 | 447 | } |
— | — | @@ -498,53 +498,6 @@ |
499 | 499 | } |
500 | 500 | }; |
501 | 501 | |
502 | | -ve.ce.Surface.prototype.showCursorAt = function( offset ) { |
503 | | - var $node = this.documentView.getNodeFromOffset( offset ).$, |
504 | | - current = [$node.contents(), 0], |
505 | | - stack = [current], |
506 | | - node, |
507 | | - localOffset, |
508 | | - index = this.documentView.getOffsetFromNode( $node.data('view') ) + 1; |
509 | | - |
510 | | - while ( stack.length > 0 ) { |
511 | | - if ( current[1] >= current[0].length ) { |
512 | | - stack.pop(); |
513 | | - current = stack[ stack.length - 1 ]; |
514 | | - continue; |
515 | | - } |
516 | | - var item = current[0][current[1]], |
517 | | - $item = current[0].eq( current[1] ); |
518 | | - |
519 | | - if ( item.nodeType === 3 ) { |
520 | | - var length = item.textContent.length; |
521 | | - if ( offset >= index && offset <= index + length ) { |
522 | | - node = item; |
523 | | - localOffset = offset - index; |
524 | | - break; |
525 | | - } else { |
526 | | - index += length; |
527 | | - } |
528 | | - } else if ( item.nodeType === 1 ) { |
529 | | - if ( $( item ).attr('contentEditable') === 'false' ) { |
530 | | - index += 1; |
531 | | - } else { |
532 | | - stack.push( [$item.contents(), 0] ); |
533 | | - current[1]++; |
534 | | - current = stack[stack.length-1]; |
535 | | - continue; |
536 | | - } |
537 | | - } |
538 | | - current[1]++; |
539 | | - } |
540 | | - var range = document.createRange(); |
541 | | - range.collapsed = true; |
542 | | - range.setStart( node, localOffset ); |
543 | | - var sel = window.getSelection(); |
544 | | - sel.removeAllRanges(); |
545 | | - sel.addRange( range ); |
546 | | -}; |
547 | | - |
548 | | - |
549 | 502 | /** |
550 | 503 | * @method |
551 | 504 | * @returns {ve.Range} Current selection range |