r102948 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102947‎ | r102948 | r102949 >
Date:08:37, 14 November 2011
Author:catrope
Status:resolved
Tags:
Comment:
(bug 32241) WikiEditor scrolls the browser and does not insert in IE7, IE8, IE9 if the textarea doesn't fit on the screen. Patch by Lupo
Modified paths:
  • /trunk/phase3/CREDITS (modified) (history)
  • /trunk/phase3/resources/jquery/jquery.textSelection.js (modified) (history)

Diff [purge]

Index: trunk/phase3/CREDITS
@@ -118,6 +118,7 @@
119119 * Louperivois
120120 * Lucas Garczewski
121121 * Luigi Corsaro
 122+* Lupo
122123 * Manuel Menal
123124 * Marcin Cieślak
124125 * Marcus Buck
Index: trunk/phase3/resources/jquery/jquery.textSelection.js
@@ -2,6 +2,26 @@
33 * These plugins provide extra functionality for interaction with textareas.
44 */
55 ( function( $ ) {
 6+
 7+if (document.selection && document.selection.createRange) {
 8+ // On IE, patch the focus() method to restore the windows' scroll position
 9+ // (bug 32241)
 10+ $.fn.extend({
 11+ focus : (function ( _focus ) {
 12+ return function () {
 13+ if ( arguments.length == 0 ) {
 14+ var $w = $( window );
 15+ var state = {top: $w.scrollTop(), left: $w.scrollLeft()};
 16+ var result = _focus.apply( this, arguments );
 17+ window.scrollTo( state.top, state.left );
 18+ return result;
 19+ }
 20+ return _focus.apply( this, arguments );
 21+ };
 22+ })( $.fn.focus )
 23+ });
 24+}
 25+
626 $.fn.textSelection = function( command, options ) {
727
828 /**
@@ -34,7 +54,7 @@
3555 if ( $(e).is( ':hidden' ) ) {
3656 // Do nothing
3757 } else if ( document.selection && document.selection.createRange ) {
38 - e.focus();
 58+ $(e).focus();
3959 var range = document.selection.createRange();
4060 retval = range.text;
4161 } else if ( e.selectionStart || e.selectionStart == '0' ) {
@@ -215,12 +235,12 @@
216236 getCaretPosition: function( options ) {
217237 function getCaret( e ) {
218238 var caretPos = 0, endPos = 0;
219 - if ( $.browser.msie ) {
 239+ if ( document.selection && document.selection.createRange ) {
220240 // IE doesn't properly report non-selected caret position through
221241 // the selection ranges when textarea isn't focused. This can
222242 // lead to saving a bogus empty selection, which then screws up
223243 // whatever we do later (bug 31847).
224 - e.focus();
 244+ $(e).focus();
225245
226246 // IE Support
227247 var preFinished = false;

Follow-up revisions

RevisionCommit summaryAuthorDate
r103138(bug 32241) Fix flickering behavior in IE. Patch by Lupo. See also r102948catrope09:59, 15 November 2011
r103160REL1_18 MFT r102948, r103074, r103138reedy12:55, 15 November 2011
r1031921.18wmf1 MFT r102948, r103138reedy16:45, 15 November 2011

Status & tagging log