aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/styles
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2006-03-26 16:12:54 +0000
committerNils Adermann <naderman@naderman.de>2006-03-26 16:12:54 +0000
commitc4ebef7f27e1f58639faf4458240c652fcac6392 (patch)
tree7991efc82ea1e1a1d783ce5c26d8eb8fe813cb8e /phpBB/styles
parent1e895071d409313f2a2f8083da2fe05a123e18fe (diff)
downloadforums-c4ebef7f27e1f58639faf4458240c652fcac6392.tar
forums-c4ebef7f27e1f58639faf4458240c652fcac6392.tar.gz
forums-c4ebef7f27e1f58639faf4458240c652fcac6392.tar.bz2
forums-c4ebef7f27e1f58639faf4458240c652fcac6392.tar.xz
forums-c4ebef7f27e1f58639faf4458240c652fcac6392.zip
- some JS magic to make color bbcode work properly with selected text [Bug #1118]
git-svn-id: file:///svn/phpbb/trunk@5730 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/styles')
-rw-r--r--phpBB/styles/subSilver/template/editor.js40
1 files changed, 31 insertions, 9 deletions
diff --git a/phpBB/styles/subSilver/template/editor.js b/phpBB/styles/subSilver/template/editor.js
index c9809bb7ed..bbc89abcfb 100644
--- a/phpBB/styles/subSilver/template/editor.js
+++ b/phpBB/styles/subSilver/template/editor.js
@@ -66,22 +66,44 @@ function smiley(text) {
}
function bbfontstyle(bbopen, bbclose) {
- if ((clientVer >= 4) && is_ie && is_win) {
- theSelection = document.selection.createRange().text;
- if (!theSelection) {
- insert_text(bbopen + bbclose);
+
+ theSelection = false;
+ document.forms[form_name].elements[text_name].focus();
+
+ 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 = bbopen + theSelection + bbclose;
document.forms[form_name].elements[text_name].focus();
+ theSelection = '';
return;
}
- document.selection.createRange().text = bbopen + theSelection + bbclose;
- document.forms[form_name].elements[text_name].focus();
- return;
- } else {
- insert_text(bbopen + bbclose);
+ }
+ 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], bbopen, bbclose);
document.forms[form_name].elements[text_name].focus();
+ theSelection = '';
return;
}
+
+ if (imageTag) { // Close image tag before adding
+ insert_text(bbtags[15]);
+
+ lastValue = arraypop(bbcode) - 1; // Remove the close image tag from the list
+ document.forms[form_name].addbbcode14.value = "Img"; // Return button back to normal state
+ imageTag = false;
+ }
+
+ // Open tag
+ insert_text(bbopen + bbclose);
+
+ document.forms[form_name].elements[text_name].focus();
+
storeCaret(document.forms[form_name].elements[text_name]);
+ return;
}
function insert_text(text) {