aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/adm/style/editor.js14
-rw-r--r--phpBB/styles/subSilver/template/editor.js14
2 files changed, 14 insertions, 14 deletions
diff --git a/phpBB/adm/style/editor.js b/phpBB/adm/style/editor.js
index 50f34d37d8..0e5f9d12f2 100644
--- a/phpBB/adm/style/editor.js
+++ b/phpBB/adm/style/editor.js
@@ -85,10 +85,9 @@ function bbstyle(bbnumber)
function bbfontstyle(bbopen, bbclose)
{
theSelection = false;
- document.forms[form_name].elements[text_name].focus();
-
+
var textarea = document.forms[form_name].elements[text_name];
- var new_pos = getCaretPosition(textarea).start + bbopen.length;
+ textarea.focus();
if ((clientVer >= 4) && is_ie && is_win)
{
@@ -112,12 +111,13 @@ function bbfontstyle(bbopen, bbclose)
return;
}
+ //The new position for the cursor after adding the bbcode
+ var new_pos = getCaretPosition(textarea).start + bbopen.length;
+
// Open tag
insert_text(bbopen + bbclose);
// Center the cursor when we don't have a selection
-
-
// IE & Opera
if (document.selection)
{
@@ -373,13 +373,13 @@ function getCaretPosition(txtarea)
sel.text = dummy;
//find dummy chraracter again
- len = (dul.text.indexOf(c));
+ len = (dul.text.indexOf(dummy));
sel.moveStart('character',-1);
sel.text = "";
if (len == -1)
{
- len = 0;
+ len = txtarea.value.length;
}
caretPos.start = len;
diff --git a/phpBB/styles/subSilver/template/editor.js b/phpBB/styles/subSilver/template/editor.js
index 50f34d37d8..0e5f9d12f2 100644
--- a/phpBB/styles/subSilver/template/editor.js
+++ b/phpBB/styles/subSilver/template/editor.js
@@ -85,10 +85,9 @@ function bbstyle(bbnumber)
function bbfontstyle(bbopen, bbclose)
{
theSelection = false;
- document.forms[form_name].elements[text_name].focus();
-
+
var textarea = document.forms[form_name].elements[text_name];
- var new_pos = getCaretPosition(textarea).start + bbopen.length;
+ textarea.focus();
if ((clientVer >= 4) && is_ie && is_win)
{
@@ -112,12 +111,13 @@ function bbfontstyle(bbopen, bbclose)
return;
}
+ //The new position for the cursor after adding the bbcode
+ var new_pos = getCaretPosition(textarea).start + bbopen.length;
+
// Open tag
insert_text(bbopen + bbclose);
// Center the cursor when we don't have a selection
-
-
// IE & Opera
if (document.selection)
{
@@ -373,13 +373,13 @@ function getCaretPosition(txtarea)
sel.text = dummy;
//find dummy chraracter again
- len = (dul.text.indexOf(c));
+ len = (dul.text.indexOf(dummy));
sel.moveStart('character',-1);
sel.text = "";
if (len == -1)
{
- len = 0;
+ len = txtarea.value.length;
}
caretPos.start = len;