Index: branches/REL1_18/phase3/CREDITS |
— | — | @@ -114,6 +114,7 @@ |
115 | 115 | * Louperivois |
116 | 116 | * Lucas Garczewski |
117 | 117 | * Luigi Corsaro |
| 118 | +* Lupo |
118 | 119 | * Manuel Menal |
119 | 120 | * Marcin Cieślak |
120 | 121 | * Marcus Buck |
Index: branches/REL1_18/phase3/resources/jquery/jquery.textSelection.js |
— | — | @@ -2,6 +2,26 @@ |
3 | 3 | * These plugins provide extra functionality for interaction with textareas. |
4 | 4 | */ |
5 | 5 | ( 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 | + |
6 | 26 | $.fn.textSelection = function( command, options ) { |
7 | 27 | |
8 | 28 | /** |
— | — | @@ -17,6 +37,19 @@ |
18 | 38 | } |
19 | 39 | } |
20 | 40 | |
| 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 | + |
21 | 54 | var fn = { |
22 | 55 | /** |
23 | 56 | * Get the contents of the textarea |
— | — | @@ -34,7 +67,7 @@ |
35 | 68 | if ( $(e).is( ':hidden' ) ) { |
36 | 69 | // Do nothing |
37 | 70 | } else if ( document.selection && document.selection.createRange ) { |
38 | | - e.focus(); |
| 71 | + activateElementOnIE( e ); |
39 | 72 | var range = document.selection.createRange(); |
40 | 73 | retval = range.text; |
41 | 74 | } else if ( e.selectionStart || e.selectionStart == '0' ) { |
— | — | @@ -150,7 +183,7 @@ |
151 | 184 | } |
152 | 185 | } else if ( document.selection && document.selection.createRange ) { |
153 | 186 | // IE |
154 | | - $(this).focus(); |
| 187 | + activateElementOnIE( this ); |
155 | 188 | if ( context ) { |
156 | 189 | context.fn.restoreCursorAndScrollTop(); |
157 | 190 | } |
— | — | @@ -212,12 +245,12 @@ |
213 | 246 | getCaretPosition: function( options ) { |
214 | 247 | function getCaret( e ) { |
215 | 248 | var caretPos = 0, endPos = 0; |
216 | | - if ( $.browser.msie ) { |
| 249 | + if ( document.selection && document.selection.createRange ) { |
217 | 250 | // IE doesn't properly report non-selected caret position through |
218 | 251 | // the selection ranges when textarea isn't focused. This can |
219 | 252 | // lead to saving a bogus empty selection, which then screws up |
220 | 253 | // whatever we do later (bug 31847). |
221 | | - e.focus(); |
| 254 | + activateElementOnIE( e ); |
222 | 255 | |
223 | 256 | // IE Support |
224 | 257 | var preFinished = false; |
Index: branches/REL1_18/phase3/resources/mediawiki.action/mediawiki.action.edit.js |
— | — | @@ -85,7 +85,7 @@ |
86 | 86 | // Create button bar |
87 | 87 | mw.toolbar.init(); |
88 | 88 | |
89 | | - $( '#wpSummary, #wpTextbox1' ).focus( function() { |
| 89 | + $( 'textarea, input:text' ).focus( function() { |
90 | 90 | currentFocused = $(this); |
91 | 91 | }); |
92 | 92 | |
Property changes on: branches/REL1_18/phase3 |
___________________________________________________________________ |
Modified: svn:mergeinfo |
93 | 93 | Merged /trunk/phase3:r102948,103074,103138 |