Update from upstream

Bug: 43904
Change-Id: I34e8ad3e82ffa23f03b5ddf25e92d850991abb43
This commit is contained in:
Amir E. Aharoni
2013-05-08 16:16:23 +03:00
parent 907e245684
commit b9e1fe5547

View File

@@ -1,4 +1,4 @@
/*! jquery.ime - v0.1.0 - 2013-05-06
/*! jquery.ime - v0.1.0 - 2013-05-08
* https://github.com/wikimedia/jquery.ime
* Copyright (c) 2013 Santhosh Thottingal; Licensed GPL, MIT */
( function ( $ ) {
@@ -396,8 +396,22 @@
newLines,
scrollTop;
if ( document.body.createTextRange ) {
// IE
if ( typeof element.selectionStart === 'number' && typeof element.selectionEnd === 'number' ) {
// IE9+ and all other browsers
scrollTop = element.scrollTop;
// This could be made better if range selection worked on browsers.
// But for complex scripts, browsers place cursor in unexpected places
// and it's not possible to fix cursor programmatically.
// Ref Bug https://bugs.webkit.org/show_bug.cgi?id=66630
element.value = element.value.substring( 0, start ) + replacement
+ element.value.substring( end, element.value.length );
// restore scroll
element.scrollTop = scrollTop;
// set selection
element.selectionStart = element.selectionEnd = start + replacement.length;
} else {
// IE8 and lower
selection = rangeForElementIE(element);
length = element.value.length;
// IE doesn't count \n when computing the offset, so we won't either
@@ -413,20 +427,6 @@
selection.text = replacement;
selection.collapse( false );
selection.select();
} else {
// All other browsers
scrollTop = element.scrollTop;
// This could be made better if range selection worked on browsers.
// But for complex scripts, browsers place cursor in unexpected places
// and it's not possible to fix cursor programmatically.
// Ref Bug https://bugs.webkit.org/show_bug.cgi?id=66630
element.value = element.value.substring( 0, start ) + replacement
+ element.value.substring( end, element.value.length );
// restore scroll
element.scrollTop = scrollTop;
// set selection
element.selectionStart = element.selectionEnd = start + replacement.length;
}
}