To improve usability of BBCode I made some modifications over the "insert_text" function.
What does it do ?
- Same features as default function
- If no text is selected, a prompt box asks the user to write a text. When the prompt box is validated the text witht the bbcode is automaticaly added to the send message box
Location of the script :
file : Chat_root/themes/Your_theme/templates/pfcclient.js.tpl.php
line : 1277
News function :
- Code: Select all
/**
* BBcode ToolBar
*/
insert_text: function(open, close)
{
var msgfield = $('<?php echo $prefix; ?>words');
// IE support
if (document.selection && document.selection.createRange)
{
msgfield.focus();
sel = document.selection.createRange();
if(sel.text.lenght==0) var texte = prompt('Tapez le texte à mettre en forme :','');
else var texte = sel.text;
sel.text = open + texte + close;
msgfield.focus();
}
// Moz support
else if (msgfield.selectionStart || msgfield.selectionStart == '0')
{
var startPos = msgfield.selectionStart;
var endPos = msgfield.selectionEnd;
if(startPos==endPos) var texte = prompt('Tapez le texte à mettre en forme :','');
else var texte = msgfield.value.substring(startPos, endPos);
msgfield.value = msgfield.value.substring(0, startPos) + open + texte + close + msgfield.value.substring(endPos, msgfield.value.length);
msgfield.selectionStart = msgfield.selectionEnd = endPos + open.length + close.length;
msgfield.focus();
}
// Fallback support for other browsers
else
{
var texte = prompt('Tapez le texte à mettre en forme :','');
msgfield.value += open + texte + close;
msgfield.focus();
}
return;
},
Have fun
![Wink ;)](./images/smilies/icon_wink.gif)