diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2004-01-25 14:19:47 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2004-01-25 14:19:47 +0000 |
commit | 89a50afd70c876298fd38734fcbb9b6c873dc91d (patch) | |
tree | 3229a747b06efe60e085daa0eb891e84c6cf3132 /phpBB/styles | |
parent | 3dd313ed896c6df0336c5a07438efb0f136c084b (diff) | |
download | forums-89a50afd70c876298fd38734fcbb9b6c873dc91d.tar forums-89a50afd70c876298fd38734fcbb9b6c873dc91d.tar.gz forums-89a50afd70c876298fd38734fcbb9b6c873dc91d.tar.bz2 forums-89a50afd70c876298fd38734fcbb9b6c873dc91d.tar.xz forums-89a50afd70c876298fd38734fcbb9b6c873dc91d.zip |
re-add mozWrap
git-svn-id: file:///svn/phpbb/trunk@4765 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/styles')
-rw-r--r-- | phpBB/styles/subSilver/template/editor.js | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/phpBB/styles/subSilver/template/editor.js b/phpBB/styles/subSilver/template/editor.js index dfe9e4c9d5..088a8cf6d7 100644 --- a/phpBB/styles/subSilver/template/editor.js +++ b/phpBB/styles/subSilver/template/editor.js @@ -114,11 +114,19 @@ function bbstyle(bbnumber) { } if ((clientVer >= 4) && is_ie && is_win) + { theSelection = document.selection.createRange().text; // Get text selection - - if (theSelection) { - // Add tags around selection - document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1]; + if (theSelection) { + // Add tags around selection + document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1]; + document.forms[form_name].elements[text_name].focus(); + theSelection = ''; + return; + } + } + else if (document.forms[form_name].elements[text_name].selectionEnd && (document.forms[form_name].elements[text_name].selectionEnd - document.forms[form_name].elements[text_name].selectionStart > 0)) + { + mozWrap(document.forms[form_name].elements[text_name], bbtags[bbnumber], bbtags[bbnumber+1]); document.forms[form_name].elements[text_name].focus(); theSelection = ''; return; @@ -218,6 +226,22 @@ function bbstyle(bbnumber) { storeCaret(document.forms[form_name].elements[text_name]); } +// From http://www.massless.org/mozedit/ +function mozWrap(txtarea, open, close) +{ + var selLength = txtarea.textLength; + var selStart = txtarea.selectionStart; + var selEnd = txtarea.selectionEnd; + if (selEnd == 1 || selEnd == 2) + selEnd = selLength; + + var s1 = (txtarea.value).substring(0,selStart); + var s2 = (txtarea.value).substring(selStart, selEnd) + var s3 = (txtarea.value).substring(selEnd, selLength); + txtarea.value = s1 + open + s2 + close + s3; + return; +} + // Insert at Claret position. Code from // http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130 function storeCaret(textEl) { |