diff options
author | Andreas Gohr <andi@splitbrain.org> | 2009-06-03 19:00:42 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2009-06-03 19:00:42 +0200 |
commit | 5979067e17b8c74e4b3ae51e0073aa0b5eae0f49 (patch) | |
tree | fc37d6292285961dfbf852f6b74ac3b577fe14c2 /lib/scripts/textselection.js | |
parent | a4b53097ed9163317ba6a1f3a22c27ae081bea2a (diff) | |
download | dokuwiki-5979067e17b8c74e4b3ae51e0073aa0b5eae0f49.tar.gz dokuwiki-5979067e17b8c74e4b3ae51e0073aa0b5eae0f49.zip |
reset scroll position when setting selection FS#1707
Ignore-this: cb035f32eccc0fcb2c9163b8620abb91
darcs-hash:20090603170042-7ad00-07ee60074714d6d23d34e59269776ccb504d1f0a.gz
Diffstat (limited to 'lib/scripts/textselection.js')
-rw-r--r-- | lib/scripts/textselection.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/scripts/textselection.js b/lib/scripts/textselection.js index 537e8d348..f005fa3da 100644 --- a/lib/scripts/textselection.js +++ b/lib/scripts/textselection.js @@ -14,6 +14,7 @@ function selection_class(){ this.end = 0; this.obj = null; this.rangeCopy = null; + this.scroll = 0; this.getLength = function(){ return this.end - this.start; @@ -41,8 +42,9 @@ function getSelection(textArea) { textArea.focus(); if(document.getSelection) { // Mozilla et al. - sel.start = textArea.selectionStart; - sel.end = textArea.selectionEnd; + sel.start = textArea.selectionStart; + sel.end = textArea.selectionEnd; + sel.scroll = textArea.scrollTop; } else if(document.selection) { // MSIE // The current selection var range = document.selection.createRange(); @@ -72,6 +74,7 @@ function setSelection(selection){ if(document.getSelection){ // FF // what a pleasure in FF ;) selection.obj.setSelectionRange(selection.start,selection.end); + if(selection.scroll) selection.obj.scrollTop = selection.scroll; } else if(document.selection) { // IE // count number of newlines in str to work around stupid IE selection bug var countNL = function(str) { |