mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
- 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
This commit is contained in:
parent
1e895071d4
commit
c4ebef7f27
1 changed files with 31 additions and 9 deletions
|
@ -66,22 +66,44 @@ function smiley(text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function bbfontstyle(bbopen, bbclose) {
|
function bbfontstyle(bbopen, bbclose) {
|
||||||
if ((clientVer >= 4) && is_ie && is_win) {
|
|
||||||
theSelection = document.selection.createRange().text;
|
theSelection = false;
|
||||||
if (!theSelection) {
|
|
||||||
insert_text(bbopen + bbclose);
|
|
||||||
document.forms[form_name].elements[text_name].focus();
|
document.forms[form_name].elements[text_name].focus();
|
||||||
return;
|
|
||||||
}
|
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.selection.createRange().text = bbopen + theSelection + bbclose;
|
||||||
document.forms[form_name].elements[text_name].focus();
|
document.forms[form_name].elements[text_name].focus();
|
||||||
return;
|
theSelection = '';
|
||||||
} else {
|
|
||||||
insert_text(bbopen + bbclose);
|
|
||||||
document.forms[form_name].elements[text_name].focus();
|
|
||||||
return;
|
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], 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]);
|
storeCaret(document.forms[form_name].elements[text_name]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function insert_text(text) {
|
function insert_text(text) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue