1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-11 03:04:09 +02:00

#5606 and some beautification

git-svn-id: file:///svn/phpbb/trunk@6664 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Dominik Dröscher
2006-11-26 21:26:15 +00:00
parent 12fb5f6aa2
commit d5593b154e
2 changed files with 35 additions and 31 deletions

View File

@@ -118,20 +118,20 @@ function bbfontstyle(bbopen, bbclose)
insert_text(bbopen + bbclose);
// Center the cursor when we don't have a selection
// IE & Opera
if (document.selection)
// Gecko and proper browsers
if (!isNaN(textarea.selectionStart))
{
textarea.selectionStart = new_pos;
textarea.selectionEnd = new_pos;
}
// IE
else if (document.selection)
{
var range = textarea.createTextRange();
range.move("character", new_pos);
range.select();
storeCaret(document.forms[form_name].elements[text_name]);
}
//Gecko
else if (!isNaN(textarea.selectionStart))
{
textarea.selectionStart = new_pos;
textarea.selectionEnd = new_pos;
}
document.forms[form_name].elements[text_name].focus();
return;
@@ -155,13 +155,8 @@ function insert_text(text, spaces, popup)
{
text = ' ' + text + ' ';
}
if (textarea.createTextRange && textarea.caretPos)
{
var caret_pos = textarea.caretPos;
caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) == ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
}
else if (!isNaN(textarea.selectionStart))
if (!isNaN(textarea.selectionStart))
{
var sel_start = textarea.selectionStart;
var sel_end = textarea.selectionEnd;
@@ -169,7 +164,15 @@ function insert_text(text, spaces, popup)
mozWrap(textarea, text, '')
textarea.selectionStart = sel_start + text.length;
textarea.selectionEnd = sel_end + text.length;
}
else if (textarea.createTextRange && textarea.caretPos)
{
var caret_pos = textarea.caretPos;
caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) == ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
}
else
{
textarea.value = textarea.value + text;