http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97604
Revision: 97604
Author: catrope
Date: 2011-09-20 08:41:58 +0000 (Tue, 20 Sep 2011)
Log Message:
-----------
1.18wmf1: MFT r96579, needed for Narayam not to break
Modified Paths:
--------------
branches/wmf/1.18wmf1/resources/jquery/jquery.textSelection.js
Modified: branches/wmf/1.18wmf1/resources/jquery/jquery.textSelection.js
===================================================================
--- branches/wmf/1.18wmf1/resources/jquery/jquery.textSelection.js
2011-09-20 08:39:29 UTC (rev 97603)
+++ branches/wmf/1.18wmf1/resources/jquery/jquery.textSelection.js
2011-09-20 08:41:58 UTC (rev 97604)
@@ -101,13 +101,26 @@
} else if ( this.selectionStart || this.selectionStart == '0' )
{
// Mozilla/Opera
$(this).focus();
+ if ( options.selectionStart !== undefined ) {
+ $(this).textSelection( 'setSelection', {
'start': options.selectionStart, 'end': options.selectionEnd } );
+ }
+
var selText = $(this).textSelection( 'getSelection' );
var startPos = this.selectionStart;
var endPos = this.selectionEnd;
var scrollTop = this.scrollTop;
checkSelectedText();
- var insertText = pre + selText + post;
+ if ( options.selectionStart !== undefined
+ && endPos - startPos !=
options.selectionEnd - options.selectionStart )
+ {
+ // This means there is a difference in the
selection range returned by browser and what we passed.
+ // This happens for Chrome in the case of
composite characters. Ref bug #30130
+ // Set the startPos to the correct position.
+ startPos = options.selectionStart;
+ }
+
+ var insertText = pre + selText + post;
if ( options.splitlines ) {
insertText = doSplitLines( selText, pre, post );
}
@@ -141,6 +154,10 @@
if ( context ) {
context.fn.restoreCursorAndScrollTop();
}
+ if ( options.selectionStart !== undefined ) {
+ $(this).textSelection( 'setSelection', {
'start': options.selectionStart, 'end': options.selectionEnd } );
+ }
+
var selText = $(this).textSelection( 'getSelection' );
var scrollTop = this.scrollTop;
var range = document.selection.createRange();
@@ -413,7 +430,9 @@
'ownline': false, // Put the inserted text on a
line of its own
'replace': false, // If there is a selection,
replace it with peri instead of leaving it alone
'selectPeri': true, // Select the peri text if
it was inserted (but not if there was a selection and replace==false, or if
splitlines==true)
- 'splitlines': false // If multiple lines are
selected, encapsulate each line individually
+ 'splitlines': false, // If multiple lines are
selected, encapsulate each line individually
+ 'selectionStart': undefined, // Position to
start selection at
+ 'selectionEnd': undefined // Position to end
selection at. Defaults to start
}, options );
break;
case 'getCaretPosition':
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs