r97602 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97601‎ | r97602 | r97603 >
Date:08:36, 20 September 2011
Author:catrope
Status:ok
Tags:
Comment:
1.17wmf1: MFT r96579
Modified paths:
  • /branches/wmf/1.17wmf1/resources/jquery/jquery.textSelection.js (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/resources/jquery/jquery.textSelection.js
@@ -72,11 +72,23 @@
7373 } else if ( this.selectionStart || this.selectionStart == '0' ) {
7474 // Mozilla/Opera
7575 $(this).focus();
 76+ if ( options.selectionStart !== undefined ) {
 77+ $(this).textSelection( 'setSelection', { 'start': options.selectionStart, 'end': options.selectionEnd } );
 78+ }
 79+
7680 var selText = $(this).textSelection( 'getSelection' );
7781 var startPos = this.selectionStart;
7882 var endPos = this.selectionEnd;
7983 var scrollTop = this.scrollTop;
8084 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+ }
8193 if ( options.ownline ) {
8294 if ( startPos != 0 && this.value.charAt( startPos - 1 ) != "\n" ) {
8395 options.pre = "\n" + options.pre;
@@ -108,6 +120,10 @@
109121 if ( context ) {
110122 context.fn.restoreCursorAndScrollTop();
111123 }
 124+ if ( options.selectionStart !== undefined ) {
 125+ $(this).textSelection( 'setSelection', { 'start': options.selectionStart, 'end': options.selectionEnd } );
 126+ }
 127+
112128 var selText = $(this).textSelection( 'getSelection' );
113129 var scrollTop = this.scrollTop;
114130 var range = document.selection.createRange();
@@ -366,7 +382,9 @@
367383 'post': '', // Text to insert after the cursor/selection
368384 'ownline': false, // Put the inserted text on a line of its own
369385 '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
371389 }, options );
372390 break;
373391 case 'getCaretPosition':
Property changes on: branches/wmf/1.17wmf1/resources/jquery/jquery.textSelection.js
___________________________________________________________________
Modified: svn:mergeinfo
374392 Merged /trunk/phase3/resources/jquery/jquery.textSelection.js:r96579

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96579(bug 30130) Add selectionStart and selectionEnd parameters to encapsulateSele...catrope16:05, 8 September 2011

Status & tagging log