Index: branches/wmf/1.17wmf1/resources/jquery/jquery.textSelection.js |
— | — | @@ -72,11 +72,23 @@ |
73 | 73 | } else if ( this.selectionStart || this.selectionStart == '0' ) { |
74 | 74 | // Mozilla/Opera |
75 | 75 | $(this).focus(); |
| 76 | + if ( options.selectionStart !== undefined ) { |
| 77 | + $(this).textSelection( 'setSelection', { 'start': options.selectionStart, 'end': options.selectionEnd } ); |
| 78 | + } |
| 79 | + |
76 | 80 | var selText = $(this).textSelection( 'getSelection' ); |
77 | 81 | var startPos = this.selectionStart; |
78 | 82 | var endPos = this.selectionEnd; |
79 | 83 | var scrollTop = this.scrollTop; |
80 | 84 | checkSelectedText(); |
| 85 | + if ( options.selectionStart !== undefined |
| 86 | + && endPos - startPos != options.selectionEnd - options.selectionStart ) |
| 87 | + { |
| 88 | + // This means there is a difference in the selection range returned by browser and what we passed. |
| 89 | + // This happens for Chrome in the case of composite characters. Ref bug #30130 |
| 90 | + // Set the startPos to the correct position. |
| 91 | + startPos = options.selectionStart; |
| 92 | + } |
81 | 93 | if ( options.ownline ) { |
82 | 94 | if ( startPos != 0 && this.value.charAt( startPos - 1 ) != "\n" ) { |
83 | 95 | options.pre = "\n" + options.pre; |
— | — | @@ -108,6 +120,10 @@ |
109 | 121 | if ( context ) { |
110 | 122 | context.fn.restoreCursorAndScrollTop(); |
111 | 123 | } |
| 124 | + if ( options.selectionStart !== undefined ) { |
| 125 | + $(this).textSelection( 'setSelection', { 'start': options.selectionStart, 'end': options.selectionEnd } ); |
| 126 | + } |
| 127 | + |
112 | 128 | var selText = $(this).textSelection( 'getSelection' ); |
113 | 129 | var scrollTop = this.scrollTop; |
114 | 130 | var range = document.selection.createRange(); |
— | — | @@ -366,7 +382,9 @@ |
367 | 383 | 'post': '', // Text to insert after the cursor/selection |
368 | 384 | 'ownline': false, // Put the inserted text on a line of its own |
369 | 385 | 'replace': false, // If there is a selection, replace it with peri instead of leaving it alone |
370 | | - 'selectPeri': true // Select the peri text if it was inserted (but not if there was a selection and replace==false) |
| 386 | + 'selectPeri': true, // Select the peri text if it was inserted (but not if there was a selection and replace==false) |
| 387 | + 'selectionStart': undefined, // Position to start selection at |
| 388 | + 'selectionEnd': undefined // Position to end selection at. Defaults to start |
371 | 389 | }, options ); |
372 | 390 | break; |
373 | 391 | case 'getCaretPosition': |
Property changes on: branches/wmf/1.17wmf1/resources/jquery/jquery.textSelection.js |
___________________________________________________________________ |
Modified: svn:mergeinfo |
374 | 392 | Merged /trunk/phase3/resources/jquery/jquery.textSelection.js:r96579 |