1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00
git-svn-id: file:///svn/phpbb/trunk@6665 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Dominik Dröscher
2006-11-27 10:26:38 +00:00
parent d5593b154e
commit 0bc076a0c3
2 changed files with 40 additions and 41 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;
@@ -372,7 +375,7 @@ function getCaretPosition(txtarea)
// get current selection
var range = document.selection.createRange();
// create a selection of the whole textarea
// a new selection of the whole textarea
var range_all = document.body.createTextRange();
range_all.moveToElementText(txtarea);