Index: trunk/phase3/CREDITS |
— | — | @@ -118,6 +118,7 @@ |
119 | 119 | * Louperivois |
120 | 120 | * Lucas Garczewski |
121 | 121 | * Luigi Corsaro |
| 122 | +* Lupo |
122 | 123 | * Manuel Menal |
123 | 124 | * Marcin Cieślak |
124 | 125 | * Marcus Buck |
Index: trunk/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 | /** |
— | — | @@ -34,7 +54,7 @@ |
35 | 55 | if ( $(e).is( ':hidden' ) ) { |
36 | 56 | // Do nothing |
37 | 57 | } else if ( document.selection && document.selection.createRange ) { |
38 | | - e.focus(); |
| 58 | + $(e).focus(); |
39 | 59 | var range = document.selection.createRange(); |
40 | 60 | retval = range.text; |
41 | 61 | } else if ( e.selectionStart || e.selectionStart == '0' ) { |
— | — | @@ -215,12 +235,12 @@ |
216 | 236 | getCaretPosition: function( options ) { |
217 | 237 | function getCaret( e ) { |
218 | 238 | var caretPos = 0, endPos = 0; |
219 | | - if ( $.browser.msie ) { |
| 239 | + if ( document.selection && document.selection.createRange ) { |
220 | 240 | // IE doesn't properly report non-selected caret position through |
221 | 241 | // the selection ranges when textarea isn't focused. This can |
222 | 242 | // lead to saving a bogus empty selection, which then screws up |
223 | 243 | // whatever we do later (bug 31847). |
224 | | - e.focus(); |
| 244 | + $(e).focus(); |
225 | 245 | |
226 | 246 | // IE Support |
227 | 247 | var preFinished = false; |