diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2004-02-08 17:41:28 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2004-02-08 17:41:28 +0000 |
commit | 75e83593b0590229dbf3c2f4f8364e0b56a98793 (patch) | |
tree | 488f3a65ee674c7cbd0318e45d9b9e8546e892fe /phpBB/styles/subSilver/template/editor.js | |
parent | 1f8ee8517ce67680660ce5f539eb372f4e64129f (diff) | |
download | forums-75e83593b0590229dbf3c2f4f8364e0b56a98793.tar forums-75e83593b0590229dbf3c2f4f8364e0b56a98793.tar.gz forums-75e83593b0590229dbf3c2f4f8364e0b56a98793.tar.bz2 forums-75e83593b0590229dbf3c2f4f8364e0b56a98793.tar.xz forums-75e83593b0590229dbf3c2f4f8364e0b56a98793.zip |
correct text placement in mozilla and other browsers not supporting the createTextRange function...
git-svn-id: file:///svn/phpbb/trunk@4817 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/styles/subSilver/template/editor.js')
-rw-r--r-- | phpBB/styles/subSilver/template/editor.js | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/phpBB/styles/subSilver/template/editor.js b/phpBB/styles/subSilver/template/editor.js index 088a8cf6d7..f00750a2d6 100644 --- a/phpBB/styles/subSilver/template/editor.js +++ b/phpBB/styles/subSilver/template/editor.js @@ -11,12 +11,12 @@ var clientPC = navigator.userAgent.toLowerCase(); // Get client info var clientVer = parseInt(navigator.appVersion); // Get browser version var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1)); -var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1) +var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1) && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1) && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1)); -var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1)); -var is_mac = (clientPC.indexOf("mac")!=-1); +var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1)); +var is_mac = (clientPC.indexOf("mac")!=-1); // Shows the help messages in the helpline window function helpline(help) { @@ -51,11 +51,17 @@ function emoticon(text) { text = ' ' + text + ' '; if (document.forms[form_name].elements[text_name].createTextRange && document.forms[form_name].elements[text_name].caretPos) { var caretPos = document.forms[form_name].elements[text_name].caretPos; - caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text; + + caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text; document.forms[form_name].elements[text_name].focus(); } else { - document.forms[form_name].elements[text_name].value += text; + var selStart = document.forms[form_name].elements[text_name].selectionStart; + var selEnd = document.forms[form_name].elements[text_name].selectionEnd; + + mozWrap(document.forms[form_name].elements[text_name], text, '') document.forms[form_name].elements[text_name].focus(); + document.forms[form_name].elements[text_name].selectionStart = selStart + text.length; + document.forms[form_name].elements[text_name].selectionEnd = selEnd + text.length; } } @@ -81,12 +87,21 @@ function bbfontstyle(bbopen, bbclose) { function insert_text(text) { if (document.forms[form_name].elements[text_name].createTextRange && document.forms[form_name].elements[text_name].caretPos) { var caretPos = document.forms[form_name].elements[text_name].caretPos; - caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? text : text; + caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text; } else { - document.forms[form_name].elements[text_name].value += text; + var selStart = document.forms[form_name].elements[text_name].selectionStart; + var selEnd = document.forms[form_name].elements[text_name].selectionEnd; + + mozWrap(document.forms[form_name].elements[text_name], text, '') + document.forms[form_name].elements[text_name].selectionStart = selStart + text.length; + document.forms[form_name].elements[text_name].selectionEnd = selEnd + text.length; } } +function attach_inline() { + insert_text('[attachment=' + document.forms[form_name].elements['attachments'].value + ']' + document.forms[form_name].elements['attachments'].options[document.forms[form_name].elements['attachments'].selectedIndex].text + '[/attachment]'); +} + function bbstyle(bbnumber) { donotinsert = false; @@ -245,7 +260,7 @@ function mozWrap(txtarea, open, close) // Insert at Claret position. Code from // http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130 function storeCaret(textEl) { - if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate(); + if (textEl.createTextRange) { textEl.caretPos = document.selection.createRange().duplicate(); } } function colorPalette() |