r100495 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100494‎ | r100495 | r100496 >
Date:02:53, 22 October 2011
Author:reedy
Status:ok
Tags:
Comment:
Merge r97604 (r96579 was being a bitch!)
Modified paths:
  • /branches/REL1_18/phase3 (modified) (history)
  • /branches/REL1_18/phase3/resources/jquery/jquery.textSelection.js (modified) (history)

Diff [purge]

Index: branches/REL1_18/phase3/resources/jquery/jquery.textSelection.js
@@ -101,13 +101,26 @@
102102 } else if ( this.selectionStart || this.selectionStart == '0' ) {
103103 // Mozilla/Opera
104104 $(this).focus();
 105+ if ( options.selectionStart !== undefined ) {
 106+ $(this).textSelection( 'setSelection', { 'start': options.selectionStart, 'end': options.selectionEnd } );
 107+ }
 108+
105109 var selText = $(this).textSelection( 'getSelection' );
106110 var startPos = this.selectionStart;
107111 var endPos = this.selectionEnd;
108112 var scrollTop = this.scrollTop;
109113 checkSelectedText();
110114
111 - var insertText = pre + selText + post;
 115+ if ( options.selectionStart !== undefined
 116+ && endPos - startPos != options.selectionEnd - options.selectionStart )
 117+ {
 118+ // This means there is a difference in the selection range returned by browser and what we passed.
 119+ // This happens for Chrome in the case of composite characters. Ref bug #30130
 120+ // Set the startPos to the correct position.
 121+ startPos = options.selectionStart;
 122+ }
 123+
 124+ var insertText = pre + selText + post;
112125 if ( options.splitlines ) {
113126 insertText = doSplitLines( selText, pre, post );
114127 }
@@ -141,6 +154,10 @@
142155 if ( context ) {
143156 context.fn.restoreCursorAndScrollTop();
144157 }
 158+ if ( options.selectionStart !== undefined ) {
 159+ $(this).textSelection( 'setSelection', { 'start': options.selectionStart, 'end': options.selectionEnd } );
 160+ }
 161+
145162 var selText = $(this).textSelection( 'getSelection' );
146163 var scrollTop = this.scrollTop;
147164 var range = document.selection.createRange();
@@ -413,7 +430,9 @@
414431 'ownline': false, // Put the inserted text on a line of its own
415432 'replace': false, // If there is a selection, replace it with peri instead of leaving it alone
416433 'selectPeri': true, // Select the peri text if it was inserted (but not if there was a selection and replace==false, or if splitlines==true)
417 - 'splitlines': false // If multiple lines are selected, encapsulate each line individually
 434+ 'splitlines': false, // If multiple lines are selected, encapsulate each line individually
 435+ 'selectionStart': undefined, // Position to start selection at
 436+ 'selectionEnd': undefined // Position to end selection at. Defaults to start
418437 }, options );
419438 break;
420439 case 'getCaretPosition':
Property changes on: branches/REL1_18/phase3
___________________________________________________________________
Modified: svn:mergeinfo
421440 Merged /branches/wmf/1.18wmf1:r97604

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96579(bug 30130) Add selectionStart and selectionEnd parameters to encapsulateSele...catrope16:05, 8 September 2011
r976041.18wmf1: MFT r96579, needed for Narayam not to breakcatrope08:41, 20 September 2011

Status & tagging log