From: Roan Kattouw Date: Tue, 15 Nov 2011 09:59:32 +0000 (+0000) Subject: (bug 32241) Fix flickering behavior in IE. Patch by Lupo. See also r102948 X-Git-Tag: 1.31.0-rc.0~26495 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=f0b2c1a92e8ab4a8d5a0b151bdc09bddcb8b94a5;p=lhc%2Fweb%2Fwiklou.git (bug 32241) Fix flickering behavior in IE. Patch by Lupo. See also r102948 --- diff --git a/resources/jquery/jquery.textSelection.js b/resources/jquery/jquery.textSelection.js index 9ba78d2d45..443722f2df 100644 --- a/resources/jquery/jquery.textSelection.js +++ b/resources/jquery/jquery.textSelection.js @@ -37,6 +37,19 @@ function rangeForElementIE( e ) { } } +/** + * Helper function for IE for activating the textarea. Called only in the + * IE-specific code paths below; makes use of IE-specific non-standard + * function setActive() if possible to avoid screen flicker. + */ +function activateElementOnIE( element ) { + if ( element.setActive ) { + element.setActive(); // bug 32241: doesn't scroll + } else { + $( element ).focus(); // may scroll (but we patched it above) + } +} + var fn = { /** * Get the contents of the textarea @@ -54,7 +67,7 @@ getSelection: function() { if ( $(e).is( ':hidden' ) ) { // Do nothing } else if ( document.selection && document.selection.createRange ) { - $(e).focus(); + activateElementOnIE( e ); var range = document.selection.createRange(); retval = range.text; } else if ( e.selectionStart || e.selectionStart == '0' ) { @@ -171,7 +184,7 @@ encapsulateSelection: function( options ) { } } else if ( document.selection && document.selection.createRange ) { // IE - $(this).focus(); + activateElementOnIE( this ); if ( context ) { context.fn.restoreCursorAndScrollTop(); } @@ -240,7 +253,7 @@ encapsulateSelection: function( options ) { // the selection ranges when textarea isn't focused. This can // lead to saving a bogus empty selection, which then screws up // whatever we do later (bug 31847). - $(e).focus(); + activateElementOnIE( e ); // IE Support var preFinished = false;