git-svn-id: file:///svn/phpbb/trunk@6652 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Dominik Dröscher 2006-11-24 19:38:48 +00:00
parent 2d31d53289
commit 8f97dc8d78
2 changed files with 14 additions and 14 deletions

View file

@ -85,10 +85,9 @@ function bbstyle(bbnumber)
function bbfontstyle(bbopen, bbclose) function bbfontstyle(bbopen, bbclose)
{ {
theSelection = false; theSelection = false;
document.forms[form_name].elements[text_name].focus();
var textarea = document.forms[form_name].elements[text_name]; 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) if ((clientVer >= 4) && is_ie && is_win)
{ {
@ -112,12 +111,13 @@ function bbfontstyle(bbopen, bbclose)
return; return;
} }
//The new position for the cursor after adding the bbcode
var new_pos = getCaretPosition(textarea).start + bbopen.length;
// Open tag // Open tag
insert_text(bbopen + bbclose); insert_text(bbopen + bbclose);
// Center the cursor when we don't have a selection // Center the cursor when we don't have a selection
// IE & Opera // IE & Opera
if (document.selection) if (document.selection)
{ {
@ -373,13 +373,13 @@ function getCaretPosition(txtarea)
sel.text = dummy; sel.text = dummy;
//find dummy chraracter again //find dummy chraracter again
len = (dul.text.indexOf(c)); len = (dul.text.indexOf(dummy));
sel.moveStart('character',-1); sel.moveStart('character',-1);
sel.text = ""; sel.text = "";
if (len == -1) if (len == -1)
{ {
len = 0; len = txtarea.value.length;
} }
caretPos.start = len; caretPos.start = len;

View file

@ -85,10 +85,9 @@ function bbstyle(bbnumber)
function bbfontstyle(bbopen, bbclose) function bbfontstyle(bbopen, bbclose)
{ {
theSelection = false; theSelection = false;
document.forms[form_name].elements[text_name].focus();
var textarea = document.forms[form_name].elements[text_name]; 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) if ((clientVer >= 4) && is_ie && is_win)
{ {
@ -112,12 +111,13 @@ function bbfontstyle(bbopen, bbclose)
return; return;
} }
//The new position for the cursor after adding the bbcode
var new_pos = getCaretPosition(textarea).start + bbopen.length;
// Open tag // Open tag
insert_text(bbopen + bbclose); insert_text(bbopen + bbclose);
// Center the cursor when we don't have a selection // Center the cursor when we don't have a selection
// IE & Opera // IE & Opera
if (document.selection) if (document.selection)
{ {
@ -373,13 +373,13 @@ function getCaretPosition(txtarea)
sel.text = dummy; sel.text = dummy;
//find dummy chraracter again //find dummy chraracter again
len = (dul.text.indexOf(c)); len = (dul.text.indexOf(dummy));
sel.moveStart('character',-1); sel.moveStart('character',-1);
sel.text = ""; sel.text = "";
if (len == -1) if (len == -1)
{ {
len = 0; len = txtarea.value.length;
} }
caretPos.start = len; caretPos.start = len;