iTom
04-29-2006, 06:25 PM
This is what I call the 'smilie' hack for SMF. It is a Javascript modification and makes it so when you press [More] next to the smilies, it comes up with a better popup. It uses a table layout, and includes description of the smiley and :code: for generating it. I think it's only compatible with the classic template.
Open up Themes / classic / Post.template.php. Find the second:
<script language="JavaScript" type="text/javascript"><!-- bleh --></script>
tag. Replace with:
<script language="JavaScript" type="text/javascript"><!--
var smileys = [';
foreach ($context['smileys']['popup'] as $smiley_row)
{
echo '
[';
foreach ($smiley_row['smileys'] as $smiley)
{
echo '
["', $smiley['code'], '","', $smiley['filename'], '","', $smiley['description'], '"]';
if (empty($smiley['last']))
echo ',';
}
echo ']';
if (empty($smiley_row['last']))
echo ',';
}
echo '];
var smileyPopupWindow;
function moreSmileys()
{
var row, i;
if (smileyPopupWindow)
smileyPopupWindow.close();
smileyPopupWindow = window.open("", "add_smileys", "toolbar=no,location=no,status=no,menubar=no,scroll bars=yes,width=480,height=500,resizable=no");
smileyPopupWindow.document.write(\'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html>\');
smileyPopupWindow.document.write(\'\n\t<head>\n\t\t<title>', $txt['more_smileys_title'], '</title>\n\t\t<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style.css" />\n\t</head>\');
smileyPopupWindow.document.write(\'\n\t<body style="margin: 1ex;">\n\t\t<table width="100%" cellpadding="5" cellspacing="0" border="0" class="tborder">\n\t\t\t<tr class="titlebg"><td align="left">', $txt['more_smileys_pick'], '</td></tr>\n\t\t\t<tr class="windowbg"><td align="left">\');
for (row = 0; row < smileys.length; row++)
{
for (i = 0; i < smileys[row].length; i++)
{
smileys[row][i][2] = smileys[row][i][2].replace(/"/g, \'"\');
smileyPopupWindow.document.write(\'<table width="100%"><tr><td width="25%" align="center"><a href="javascript:void(0);" onclick="window.opener.replaceText(" \' + smileys[row][i][0] + \'", window.opener.document.', $context['post_form'], '.', $context['post_box_name'], '); window.focus(); return false;"><img src="', $settings['smileys_url'], '/\' + smileys[row][i][1] + \'" alt="\' + smileys[row][i][2] + \'" title="\' + smileys[row][i][2] + \'" style="padding: 4px;" border="0" /></a></td><td width="25%" align="center"><code>\' + smileys[row][i][2] + \'</code></td><td width="25%">\' + smileys[row][i][0] +\'</td></tr></table>\');
}
smileyPopupWindow.document.write("<br />");
}
smileyPopupWindow.document.write(\'</td></tr>\n\t\t\t<tr><td align="center" class="windowbg"><a href="javascript:window.close();\\">', $txt['more_smileys_close_window'], '</a></td></tr>\n\t\t</table>\n\t</body>\n</html>\');
smileyPopupWindow.document.close();
}
// --></script>
Hope this helps!
Open up Themes / classic / Post.template.php. Find the second:
<script language="JavaScript" type="text/javascript"><!-- bleh --></script>
tag. Replace with:
<script language="JavaScript" type="text/javascript"><!--
var smileys = [';
foreach ($context['smileys']['popup'] as $smiley_row)
{
echo '
[';
foreach ($smiley_row['smileys'] as $smiley)
{
echo '
["', $smiley['code'], '","', $smiley['filename'], '","', $smiley['description'], '"]';
if (empty($smiley['last']))
echo ',';
}
echo ']';
if (empty($smiley_row['last']))
echo ',';
}
echo '];
var smileyPopupWindow;
function moreSmileys()
{
var row, i;
if (smileyPopupWindow)
smileyPopupWindow.close();
smileyPopupWindow = window.open("", "add_smileys", "toolbar=no,location=no,status=no,menubar=no,scroll bars=yes,width=480,height=500,resizable=no");
smileyPopupWindow.document.write(\'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html>\');
smileyPopupWindow.document.write(\'\n\t<head>\n\t\t<title>', $txt['more_smileys_title'], '</title>\n\t\t<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style.css" />\n\t</head>\');
smileyPopupWindow.document.write(\'\n\t<body style="margin: 1ex;">\n\t\t<table width="100%" cellpadding="5" cellspacing="0" border="0" class="tborder">\n\t\t\t<tr class="titlebg"><td align="left">', $txt['more_smileys_pick'], '</td></tr>\n\t\t\t<tr class="windowbg"><td align="left">\');
for (row = 0; row < smileys.length; row++)
{
for (i = 0; i < smileys[row].length; i++)
{
smileys[row][i][2] = smileys[row][i][2].replace(/"/g, \'"\');
smileyPopupWindow.document.write(\'<table width="100%"><tr><td width="25%" align="center"><a href="javascript:void(0);" onclick="window.opener.replaceText(" \' + smileys[row][i][0] + \'", window.opener.document.', $context['post_form'], '.', $context['post_box_name'], '); window.focus(); return false;"><img src="', $settings['smileys_url'], '/\' + smileys[row][i][1] + \'" alt="\' + smileys[row][i][2] + \'" title="\' + smileys[row][i][2] + \'" style="padding: 4px;" border="0" /></a></td><td width="25%" align="center"><code>\' + smileys[row][i][2] + \'</code></td><td width="25%">\' + smileys[row][i][0] +\'</td></tr></table>\');
}
smileyPopupWindow.document.write("<br />");
}
smileyPopupWindow.document.write(\'</td></tr>\n\t\t\t<tr><td align="center" class="windowbg"><a href="javascript:window.close();\\">', $txt['more_smileys_close_window'], '</a></td></tr>\n\t\t</table>\n\t</body>\n</html>\');
smileyPopupWindow.document.close();
}
// --></script>
Hope this helps!