aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/styles/subSilver/template/editor.js
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/styles/subSilver/template/editor.js')
-rw-r--r--phpBB/styles/subSilver/template/editor.js32
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) {