From cd12dcad1a482ea805f8dcc58b364e9c6cddc667 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 2 Feb 2010 16:20:17 +0100 Subject: JavaScript syntax fixes --- lib/scripts/textselection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/scripts/textselection.js') diff --git a/lib/scripts/textselection.js b/lib/scripts/textselection.js index 76cc6bcbb..5e4602f85 100644 --- a/lib/scripts/textselection.js +++ b/lib/scripts/textselection.js @@ -24,7 +24,7 @@ function selection_class(){ this.getText = function(){ if(!this.obj) return ''; return this.obj.value.substring(this.start,this.end); - } + }; } /** -- cgit v1.2.3 From 28f6aae1adeef509aa7be8895088cc9f47018054 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 29 Apr 2010 13:08:15 +0200 Subject: Support getSelection in input fields in IE --- lib/scripts/textselection.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/scripts/textselection.js') diff --git a/lib/scripts/textselection.js b/lib/scripts/textselection.js index 5e4602f85..0378b544d 100644 --- a/lib/scripts/textselection.js +++ b/lib/scripts/textselection.js @@ -41,7 +41,6 @@ function getSelection(textArea) { sel.obj = textArea; sel.start = textArea.value.length; sel.end = textArea.value.length; - textArea.focus(); if(document.getSelection) { // Mozilla et al. sel.start = textArea.selectionStart; @@ -57,9 +56,13 @@ function getSelection(textArea) { // The current selection sel.rangeCopy = document.selection.createRange().duplicate(); - - var before_range = document.body.createTextRange(); - before_range.moveToElementText(textArea); // Selects all the text + if (textArea.tagName === 'INPUT') { + var before_range = textArea.createTextRange(); + before_range.expand('textedit'); // Selects all the text + } else { + var before_range = document.body.createTextRange(); + before_range.moveToElementText(textArea); // Selects all the text + } before_range.setEndPoint("EndToStart", sel.rangeCopy); // Moves the end where we need it var before_finished = false, selection_finished = false; -- cgit v1.2.3 From 136982455ae0eddc18744176db33fbd7b421e11c Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 27 Jun 2010 18:34:57 +0200 Subject: Fixed automatic insertion of listbullets in Opera FS#1877 The keydown event can't be prevented in Opera (see http://www.quirksmode.org/dom/events/keys.html) so this switches back to keypress in Opera (keypress doesn't give the correct key codes in Firefox). Furthermore Opera replaces '\n' by '\r\n' when inserting text, thus the offset for cursor/selection placement was wrong. --- lib/scripts/textselection.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/scripts/textselection.js') diff --git a/lib/scripts/textselection.js b/lib/scripts/textselection.js index 0378b544d..742338785 100644 --- a/lib/scripts/textselection.js +++ b/lib/scripts/textselection.js @@ -161,7 +161,12 @@ function pasteText(selection,text,opts){ selection.obj.value.substring(selection.end, selection.obj.value.length); // set new selection - selection.end = selection.start + text.length; + if (is_opera) { + // Opera replaces \n by \r\n when inserting text. + selection.end = selection.start + text.replace(/\r?\n/g, '\r\n').length; + } else { + selection.end = selection.start + text.length; + } // modify the new selection if wanted if(opts.startofs) selection.start += opts.startofs; -- cgit v1.2.3