I found a solution to this issue. I took some code from this thread:
More Entry Edit Buttons, a few buttons I use all the time and worked it into the bm_entry.tmpl and edit_entry.tmpl files.
Here's what I did:
I added this code to the script tag at the top of the template (I put it just below the mtShortcuts function.
CODE
function addSmiley(str) {
if (!document.selection) return;
if (!window.last_elem) return;
last_elem.caretPos.text = ' ' + str + ' ';
last_elem.focus();
}
function saveCaret (elem) {
if (!document.selection) return;
if (elem.isTextEdit) elem.caretPos = document.selection.createRange();
last_elem = elem;
}
function checkStr () {
if( !document.selection ) return;
before = document.selection.createRange();
after = document.selection.createRange();
before.moveStart( 'textedit', -1 );
after.moveEnd( 'textedit', 1 );
if( before.text.match(/<(b|i|u|a|p)(\s[^>]*)?>$/i) && !RegExp('^[^<]*<\/'+RegExp.$1+'>','i').exec(after.text) ) {
var text = '</' + RegExp.$1 + '>';
last_elem.caretPos.text = text;
last_elem.caretPos.moveStart( 'character', -text.length );
last_elem.caretPos.moveEnd( 'character', -text.length );
last_elem.caretPos.select();
}
}
Then modified the area that displays the formatting buttons to add my smilies. here's a sample:
CODE
document.write('<td width="20"><a href="javascript:addSmiley(\':\)\')"><img src="http://www.mysite.com/smilies/smile.gif" border="0" alt=":)" width="15" height="15" /></a></td>');
document.write('<td width="20"><a href="javascript:addSmiley(\':\(\')"><img src="http://www.mysite.com/smilies/sad.gif" border="0" alt=":(" width="15" height="15" /></a></a></td>');
document.write('<td width="20"><a href="javascript:addSmiley(\':D\')"><img src="http://www.mysite.com/smilies/biggrin.gif" border="0" alt=":D" width="15" height="15" /></a></td>');
document.write('<td width="20"><a href="javascript:addSmiley(\':P\')"><img src="http://www.mysite.com/smilies/tongue.gif" border="0" alt=":P" width="15" height="15" /></a></td>');
then in the textarea tags for each body, extended text and excerpt, just after where you see wrap="virtual" I added this:
CODE
onselect="saveCaret(this)" onclick="saveCaret(this)" onkeyup="saveCaret(this);checkStr()"
In bm_entry, I moved the smilies to the same line as the Extended Text label since there wasn't enough room next to the other formatting buttons and the code looks slightly different as it isn't in the javascript format:
CODE
<td><a href="javascript:addSmiley(':\)')"><img src="http://www.mysite.com/smilies/smile.gif" border="0" alt=":)" width="15" height="15" /></a></td>
<td><a href="javascript:addSmiley(':\(')"><img src="http://www.mysite.com/smilies/sad.gif" border="0" alt=":(" width="15" height="15" /></a></td>
<td><a href="javascript:addSmiley(':D')"><img src="http://www.mysite.com/smilies/biggrin.gif" border="0" alt=":D" width="15" height="15" /></a></td>
<td><a href="javascript:addSmiley(':P')"><img src="http://www.mysite.com/smilies/tongue.gif" border="0" alt=":P" width="15" height="15" /></a></td>
You could also do as suggested in
this thread and just add a table row below the textarea to add your smilies instead of having to adjust the row that has the section labels. Hope this helps everyone who wants to add a smilie bar to their entry forms.