Description du problèmeNormalement lorsque vous cliquez sur un smiley dans la page de rédaction des messages, celui-ci doit normalement s'insérer là où vous placez votre curseur mais avec certains navigateurs (Firefox, Opera etc...), les smileys s'insèrent à la fin du message au lieu de l'endroit indiqué.
Correction du problème- Première partie
- Ouvrez
- Code: Tout sélectionner
templates/subSilver/posting_body.tpl
- Cherchez
- Code: Tout sélectionner
function emoticon(text) {
var txtarea = document.post.message;
text = ' ' + text + ' ';
if (txtarea.createTextRange && txtarea.caretPos) {
var caretPos = txtarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
txtarea.focus();
} else {
txtarea.value += text;
txtarea.focus();
}
}
- Remplacez par
- Code: Tout sélectionner
// include the insert smilies fixes for Mozilla
function emoticon(text) {
emoticon_insert(document.post.message, text);
}
function emoticon_insert(txtarea, text)
{
text = ' ' + text + ' ';
if (txtarea.createTextRange && txtarea.caretPos)
{
var caretPos = txtarea.caretPos;
var baseHeight;
if ( is_ie ) {
baseHeight = document.selection.createRange().duplicate().boundingHeight;
}
if (baseHeight != txtarea.caretPos.boundingHeight) {
txtarea.focus();
storeCaret(txtarea);
}
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
txtarea.focus();
}
else if ( (txtarea.selectionEnd | txtarea.selectionEnd == 0) && (txtarea.selectionStart | txtarea.selectionStart == 0) )
{
mozInsert(txtarea, text, "");
}
else
{
txtarea.value += text;
txtarea.focus();
}
}
// insert smilies fixes for Mozilla
function mozInsert(txtarea, openTag, closeTag) {
var scrollTop = ( typeof(txtarea.scrollTop) == 'number' ? txtarea.scrollTop : -1 );
if (txtarea.selectionEnd > txtarea.value.length) {
txtarea.selectionEnd = txtarea.value.length;
}
var startPos = txtarea.selectionStart;
var endPos = txtarea.selectionEnd + openTag.length;
txtarea.value = txtarea.value.slice(0, startPos) + openTag + txtarea.value.slice(startPos);
txtarea.value = txtarea.value.slice(0, endPos) + closeTag + txtarea.value.slice(endPos);
txtarea.selectionStart = startPos + openTag.length;
txtarea.selectionEnd = endPos;
txtarea.focus();
if (scrollTop >= 0) {
txtarea.scrollTop = scrollTop;
}
}
- Deuxième partie
- Ouvrez
- Code: Tout sélectionner
templates/subSilver/posting_smilies.tpl
- Cherchez et supprimez
- Code: Tout sélectionner
<script language="javascript" type="text/javascript">
<!--
function emoticon(text) {
text = ' ' + text + ' ';
if (opener.document.forms['post'].message.createTextRange && opener.document.forms['post'].message.caretPos) {
var caretPos = opener.document.forms['post'].message.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
opener.document.forms['post'].message.focus();
} else {
opener.document.forms['post'].message.value += text;
opener.document.forms['post'].message.focus();
}
}
//-->
</script>
- Cherchez
- Code: Tout sélectionner
<td><a href="javascript:emoticon('{smilies_row.smilies_col.SMILEY_CODE}')"><img src="{smilies_row.smilies_col.SMILEY_IMG}" border="0" alt="{smilies_row.smilies_col.SMILEY_DESC}" title="{smilies_row.smilies_col.SMILEY_DESC}" /></a></td>
- Remplacez par
- Code: Tout sélectionner
<td><a href="javascript:opener.emoticon('{smilies_row.smilies_col.SMILEY_CODE}')"><img src="{smilies_row.smilies_col.SMILEY_IMG}" border="0" alt="{smilies_row.smilies_col.SMILEY_DESC}" title="{smilies_row.smilies_col.SMILEY_DESC}" /></a></td>


