Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F8594
jquery.textSelection.js.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 22 2014, 12:04 AM
2014-11-22 00:04:04 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
jquery.textSelection.js.patch
View Options
Index: jquery.textSelection.js
===================================================================
--- jquery.textSelection.js (revision 102816)
+++ jquery.textSelection.js (working copy)
@@ -2,6 +2,26 @@
* These plugins provide extra functionality for interaction with textareas.
*/
( function( $ ) {
+
+if (document.selection && document.selection.createRange) {
+ // On IE, patch the focus() method to restore the windows' scroll position
+ // (bug 32241)
+ $.fn.extend({
+ focus : (function ( _focus ) {
+ return function () {
+ if ( arguments.length == 0 ) {
+ var $w = $( window );
+ var state = {top: $w.scrollTop(), left: $w.scrollLeft()};
+ var result = _focus.apply( this, arguments );
+ window.scrollTo( state.top, state.left );
+ return result;
+ }
+ return _focus.apply( this, arguments );
+ };
+ })( $.fn.focus )
+ });
+}
+
$.fn.textSelection = function( command, options ) {
/**
@@ -34,7 +54,7 @@
if ( $(e).is( ':hidden' ) ) {
// Do nothing
} else if ( document.selection && document.selection.createRange ) {
- e.focus();
+ $(e).focus();
var range = document.selection.createRange();
retval = range.text;
} else if ( e.selectionStart || e.selectionStart == '0' ) {
@@ -215,12 +235,12 @@
getCaretPosition: function( options ) {
function getCaret( e ) {
var caretPos = 0, endPos = 0;
- if ( $.browser.msie ) {
+ if ( document.selection && document.selection.createRange ) {
// IE doesn't properly report non-selected caret position through
// 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();
+ $(e).focus();
// IE Support
var preFinished = false;
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
8112
Default Alt Text
jquery.textSelection.js.patch (1 KB)
Attached To
Mode
T34241: WikiEditor scrolls the browser and does not insert on IE7, IE8, IE9 if textarea doesn't fit on screen
Attached
Detach File
Event Timeline
Log In to Comment