mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
re-add mozWrap
git-svn-id: file:///svn/phpbb/trunk@4765 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
3dd313ed89
commit
89a50afd70
1 changed files with 28 additions and 4 deletions
|
@ -114,11 +114,19 @@ function bbstyle(bbnumber) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((clientVer >= 4) && is_ie && is_win)
|
if ((clientVer >= 4) && is_ie && is_win)
|
||||||
|
{
|
||||||
theSelection = document.selection.createRange().text; // Get text selection
|
theSelection = document.selection.createRange().text; // Get text selection
|
||||||
|
if (theSelection) {
|
||||||
if (theSelection) {
|
// Add tags around selection
|
||||||
// Add tags around selection
|
document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
|
||||||
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();
|
document.forms[form_name].elements[text_name].focus();
|
||||||
theSelection = '';
|
theSelection = '';
|
||||||
return;
|
return;
|
||||||
|
@ -218,6 +226,22 @@ function bbstyle(bbnumber) {
|
||||||
storeCaret(document.forms[form_name].elements[text_name]);
|
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
|
// Insert at Claret position. Code from
|
||||||
// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
|
// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
|
||||||
function storeCaret(textEl) {
|
function storeCaret(textEl) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue