r103192 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103191‎ | r103192 | r103193 >
Date:16:45, 15 November 2011
Author:reedy
Status:ok
Tags:
Comment:
1.18wmf1 MFT r102948, r103138
Modified paths:
  • /branches/wmf/1.18wmf1 (modified) (history)
  • /branches/wmf/1.18wmf1/CREDITS (modified) (history)
  • /branches/wmf/1.18wmf1/resources/jquery/jquery.textSelection.js (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/CREDITS
@@ -111,6 +111,7 @@
112112 * Louperivois
113113 * Lucas Garczewski
114114 * Luigi Corsaro
 115+* Lupo
115116 * Manuel Menal
116117 * Marcin Cieślak
117118 * Marcus Buck
Index: branches/wmf/1.18wmf1/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 /**
@@ -17,6 +37,19 @@
1838 }
1939 }
2040
 41+/**
 42+ * Helper function for IE for activating the textarea. Called only in the
 43+ * IE-specific code paths below; makes use of IE-specific non-standard
 44+ * function setActive() if possible to avoid screen flicker.
 45+ */
 46+function activateElementOnIE( element ) {
 47+ if ( element.setActive ) {
 48+ element.setActive(); // bug 32241: doesn't scroll
 49+ } else {
 50+ $( element ).focus(); // may scroll (but we patched it above)
 51+ }
 52+}
 53+
2154 var fn = {
2255 /**
2356 * Get the contents of the textarea
@@ -34,7 +67,7 @@
3568 if ( $(e).is( ':hidden' ) ) {
3669 // Do nothing
3770 } else if ( document.selection && document.selection.createRange ) {
38 - e.focus();
 71+ activateElementOnIE( e );
3972 var range = document.selection.createRange();
4073 retval = range.text;
4174 } else if ( e.selectionStart || e.selectionStart == '0' ) {
@@ -150,7 +183,7 @@
151184 }
152185 } else if ( document.selection && document.selection.createRange ) {
153186 // IE
154 - $(this).focus();
 187+ activateElementOnIE( this );
155188 if ( context ) {
156189 context.fn.restoreCursorAndScrollTop();
157190 }
@@ -212,12 +245,12 @@
213246 getCaretPosition: function( options ) {
214247 function getCaret( e ) {
215248 var caretPos = 0, endPos = 0;
216 - if ( $.browser.msie ) {
 249+ if ( document.selection && document.selection.createRange ) {
217250 // IE doesn't properly report non-selected caret position through
218251 // the selection ranges when textarea isn't focused. This can
219252 // lead to saving a bogus empty selection, which then screws up
220253 // whatever we do later (bug 31847).
221 - e.focus();
 254+ activateElementOnIE( e );
222255
223256 // IE Support
224257 var preFinished = false;
Property changes on: branches/wmf/1.18wmf1
___________________________________________________________________
Modified: svn:mergeinfo
225258 Merged /trunk/phase3:r102948,103138

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r102948(bug 32241) WikiEditor scrolls the browser and does not insert in IE7, IE8, I...catrope08:37, 14 November 2011
r103138(bug 32241) Fix flickering behavior in IE. Patch by Lupo. See also r102948catrope09:59, 15 November 2011

Status & tagging log