aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2011-12-15 22:17:39 +0100
committerJoas Schilling <nickvergessen@gmx.de>2011-12-15 22:17:39 +0100
commit2bf4e8d3d0ad86038fe5ff84d3b48517b8033fc8 (patch)
treeee0a7a095a93e3f3d4d92d64d4e8b3dc65d4ecc9
parent730d2d5d19741508f243d61f47c28af2564be6b1 (diff)
downloadforums-2bf4e8d3d0ad86038fe5ff84d3b48517b8033fc8.tar
forums-2bf4e8d3d0ad86038fe5ff84d3b48517b8033fc8.tar.gz
forums-2bf4e8d3d0ad86038fe5ff84d3b48517b8033fc8.tar.bz2
forums-2bf4e8d3d0ad86038fe5ff84d3b48517b8033fc8.tar.xz
forums-2bf4e8d3d0ad86038fe5ff84d3b48517b8033fc8.zip
[ticket/8996] Revert initial fix to keep old behaviour on empty selection Part2
Revert "[ticket/8996] Correctly apply BBCodes in IE6-9 when applying with accesskey" This reverts commit 219bdbaf7044bd203755ed138d109cf39ccdb837. PHPBB3-8996
-rw-r--r--phpBB/styles/prosilver/template/editor.js26
1 files changed, 11 insertions, 15 deletions
diff --git a/phpBB/styles/prosilver/template/editor.js b/phpBB/styles/prosilver/template/editor.js
index 957c39b568..cfdb54f54b 100644
--- a/phpBB/styles/prosilver/template/editor.js
+++ b/phpBB/styles/prosilver/template/editor.js
@@ -86,10 +86,14 @@ function bbfontstyle(bbopen, bbclose)
if ((clientVer >= 4) && is_ie && is_win)
{
// Get text selection
- textarea = document.forms[form_name].elements[text_name];
- if (textarea.createTextRange && textarea.caretPos)
+ theSelection = document.selection.createRange().text;
+
+ if (theSelection)
{
- textarea.caretPos.text = bbopen + textarea.caretPos.text + bbclose;
+ // Add tags around selection
+ document.selection.createRange().text = bbopen + theSelection + bbclose;
+ document.forms[form_name].elements[text_name].focus();
+ theSelection = '';
return;
}
}
@@ -103,7 +107,7 @@ function bbfontstyle(bbopen, bbclose)
//The new position for the cursor after adding the bbcode
var caret_pos = getCaretPosition(textarea).start;
- var new_pos = caret_pos + bbopen.length;
+ var new_pos = caret_pos + bbopen.length;
// Open tag
insert_text(bbopen + bbclose);
@@ -343,15 +347,7 @@ function mozWrap(txtarea, open, close)
*/
function storeCaret(textEl)
{
- var keyCode = false;
- if (is_ie)
- {
- keyCode = (event.keyCode) ? event.keyCode : event.charCode;
- }
-
- // Did the user press Shift (16), Ctrl (17) or Alt (18)?
- // If so, we do not update the caretPos, so BBCodes can still be applied correctly.
- if ((!is_ie || (keyCode != 16 && keyCode != 17 && keyCode != 18)) && (textEl.createTextRange))
+ if (textEl.createTextRange)
{
textEl.caretPos = document.selection.createRange().duplicate();
}
@@ -429,7 +425,7 @@ function getCaretPosition(txtarea)
var caretPos = new caretPosition();
// simple Gecko/Opera way
- if(!is_ie && (txtarea.selectionStart || txtarea.selectionStart == 0))
+ if(txtarea.selectionStart || txtarea.selectionStart == 0)
{
caretPos.start = txtarea.selectionStart;
caretPos.end = txtarea.selectionEnd;
@@ -456,7 +452,7 @@ function getCaretPosition(txtarea)
// we ignore the end value for IE, this is already dirty enough and we don't need it
caretPos.start = txtarea.sel_start;
- caretPos.end = txtarea.sel_start;
+ caretPos.end = txtarea.sel_start;
}
return caretPos;