1.###edit includes/xoopscodes.php
Find:
<textarea id='".$textarea_id."' name='".$textarea_id."' cols='$cols' rows='$rows'
after it add:
onSelect='xoopsSavePosition("$textarea_id");' onClick='xoopsSavePosition("$textarea_id");' onKeyUp='xoopsSavePosition("$textarea_id");'
the code will be like this:
<textarea id='".$textarea_id."' name='".$textarea_id."' cols='$cols' rows='$rows' onSelect='xoopsSavePosition("$textarea_id");' onClick='xoopsSavePosition("$textarea_id");' onKeyUp='xoopsSavePosition("$textarea_id");'
>
2.Edit includes/xoopsjs.php
Modify the function like this:
function xoopsCodeUrl(id){
if (document.getSelection) {var selection=document.getSelection();}
else if (document.selection) {var selection=document.selection.createRange().text;}
else return;
if (selection){
var text = prompt("echo _ENTERURL;?>", selection);}
else {
var text = prompt("echo _ENTERURL;?>", "");}
var domobj = xoopsGetElementById(id);
if ( text != null && text != "" ) {
if (selection !=null){
var text2 = prompt("echo _ENTERWEBTITLE;?>", selection);var selection="";}
else{
var text2 = prompt("echo _ENTERWEBTITLE;?>", "");}
if ( text2 != null ) {
if ( text2 == "" ) {
var result = "[url=" + text + "]" + text + "[/url]";
} else {
var pos = text2.indexOf(unescape('%00'));
if(0 < pos){
text2 = text2.substr(0,pos);
}
var result = "[url=" + text + "]" + text2 + "[/url]";
}
xoopsInsertText(domobj, result);
}
}
domobj.focus();
}
function xoopsCodeImg(id){
if (document.getSelection) {var selection=document.getSelection();}
else if (document.selection) {var selection=document.selection.createRange().text;}
else return;
if (selection !=null){
var text = prompt("echo _ENTERIMGURL;?>", selection); var selection="";}
else {
var text = prompt("echo _ENTERIMGURL;?>", "");}
var domobj = xoopsGetElementById(id);
if ( text != null && text != "" ) {
var text2 = prompt("echo _ENTERIMGPOS;?>necho _IMGPOSRORL;?>", "");
while ( ( text2 != "" ) && ( text2 != "r" ) && ( text2 != "R" ) && ( text2 != "l" ) && ( text2 != "L" ) && ( text2 != null ) ) {
text2 = prompt("echo _ERRORIMGPOS;?>necho _IMGPOSRORL;?>","");
}
if ( text2 == "l" || text2 == "L" ) {
text2 = " align=left";
} else if ( text2 == "r" || text2 == "R" ) {
text2 = " align=right";
} else {
text2 = "";
}
var result = "[img" + text2 + "]" + text + "[/img]";
xoopsInsertText(domobj, result);
}
domobj.focus();
}
function xoopsCodeEmail(id){
if (document.getSelection) {var selection=document.getSelection();}
else if (document.selection) {var selection=document.selection.createRange().text;}
else return;
if (selection !=null){
var text = prompt("echo _ENTEREMAIL;?>", selection); var selection="";}
else{
var text = prompt("echo _ENTEREMAIL;?>", "");}
var domobj = xoopsGetElementById(id);
if ( text != null && text != "" ) {
var result = "[email]" + text + "[/email]";
xoopsInsertText(domobj, result);
}
domobj.focus();
}
function xoopsCodeQuote(id){
if (document.getSelection) {var selection=document.getSelection();}
else if (document.selection) {var selection=document.selection.createRange().text;}
else return;
//document.forms[0].selectedtext.value = selection.replace(new RegExp('([\f\n\r\t\v ])+', 'g')," ");
if (selection !=null){
var text = prompt("echo _ENTERQUOTE;?>", selection);var selection="";}
else{
var text = prompt("echo _ENTERQUOTE;?>", "");}
var domobj = xoopsGetElementById(id);
if ( text != null && text != "" ) {
var pos = text.indexOf(unescape('%00'));
if(0 < pos){
text = text.substr(0,pos);
}
var result = "[quote]" + text + "[/quote]";
xoopsInsertText(domobj, result);
}
domobj.focus();
}
function xoopsCodeCode(id){
if (document.getSelection) {var selection=document.getSelection();}
else if (document.selection) {var selection=document.selection.createRange().text;}
else return;
// document.forms[0].selectedtext.value = selection.replace(new RegExp('([\f\n\r\t\v ])+', 'g')," ");
if (selection !=null){
var text = prompt("echo _ENTERCODE;?>", selection);var selection="";}
else{
var text = prompt("echo _ENTERCODE;?>", "");}
var domobj = xoopsGetElementById(id);
if ( text != null && text != "" ) {
var result = "[code]" + text + "[ /code]";
xoopsInsertText(domobj, result);
}
domobj.focus();
}
function xoopsCodeText(id, hiddentext){
var textareaDom = xoopsGetElementById(id);
var textDom = xoopsGetElementById(id + "Addtext");
var fontDom = xoopsGetElementById(id + "Font");
var colorDom = xoopsGetElementById(id + "Color");
var sizeDom = xoopsGetElementById(id + "Size");
var xoopsHiddenTextDomStyle = xoopsGetElementById(hiddentext).style;
var fontDomValue = fontDom.options[fontDom.options.selectedIndex].value;
var colorDomValue = colorDom.options[colorDom.options.selectedIndex].value;
var sizeDomValue = sizeDom.options[sizeDom.options.selectedIndex].value;
if (document.getSelection) {var selection=document.getSelection();}
else if (document.selection) {var selection=document.selection.createRange().text;}
else return;
// document.forms[0].selectedtext.value = selection.replace(new RegExp('([\f\n\r\t\v ])+', 'g')," ");
if (selection) {
var textDomValue = selection;
var selection="";
}
else {
var textDomValue = textDom.value;
}
if ( textDomValue == "" ) {
alert("echo _ENTERTEXTBOX;?>");
textDom.focus();
} else {
if ( fontDomValue != "FONT") {
textDomValue = "[font=" + fontDomValue + "]" + textDomValue + "[/font]";
fontDom.options[0].selected = true;
}
if ( colorDomValue != "COLOR") {
textDomValue = "[color=" + colorDomValue + "]" + textDomValue + "[/color]";
colorDom.options[0].selected = true;
}
if ( sizeDomValue != "SIZE") {
textDomValue = "[size=" + sizeDomValue + "]" + textDomValue + "[/size]";
sizeDom.options[0].selected = true;
}
if (xoopsHiddenTextDomStyle.fontWeight == "bold") {
textDomValue = "[b]" + textDomValue + "[/b]";
xoopsHiddenTextDomStyle.fontWeight = "normal";
}
if (xoopsHiddenTextDomStyle.fontStyle == "italic") {
textDomValue = "[i]" + textDomValue + "[/i]";
xoopsHiddenTextDomStyle.fontStyle = "normal";
}
if (xoopsHiddenTextDomStyle.textDecoration == "underline") {
textDomValue = "[u]" + textDomValue + "[/u]";
xoopsHiddenTextDomStyle.textDecoration = "none";
}
if (xoopsHiddenTextDomStyle.textDecoration == "line-through") {
textDomValue = "[d]" + textDomValue + "[/d]";
xoopsHiddenTextDomStyle.textDecoration = "none";
}
xoopsInsertText(textareaDom, textDomValue);
textDom.value = "";
xoopsHiddenTextDomStyle.color = "#000000";
xoopsHiddenTextDomStyle.fontFamily = "";
xoopsHiddenTextDomStyle.fontSize = "12px";
xoopsHiddenTextDomStyle.visibility = "hidden";
textareaDom.focus();
}
}