All tags available

Started by AzaToth, October 14, 2005, 11:59:28 AM

Previous topic - Next topic

AzaToth

This code is to be in Post.template.php and will add a pulldown menu with alternatives for bbc that there is no button for (like nobbc etc...)
I would like the code to be included in the default distribution, because if you create a new bbc-tag there is perhaps not possible to add a button for that tag (how should a button for spoiler look like), and also some buttons should be in the menu instead.

couldn't attach the code because it's contains [code] and [nobbc] tags

here is the code: http://www.efd.lth.se/~d02cf/allcode.txt

Axiem

I'm slightly confused. Where exctly in Post.template.php should this go? It seems to me like it should be split into two blocks...?
Crystal Ball Information:
http://anime.truman.edu/forum [nofollow]
SMF 1.1 RC 1
Minor Mods
Custom Theme

AzaToth

Quote from: Axiem on October 14, 2005, 01:07:14 PM
I'm slightly confused. Where exctly in Post.template.php should this go? It seems to me like it should be split into two blocks...?
They don't need to be split, put them after
// Here loop through the array, printing the images/rows/separators!
foreach ($context['bbc_tags'][0] as $image => $tag)
{
// Is there a "before" part for this bbc button?  If not, it can't be a button!!
if (isset($tag['before']))
{
// Is this tag disabled?
if (!empty($context['disabled_tags'][$tag['code']]))
continue;

// If there's no after, we're just replacing the entire selection in the post box.
if (!isset($tag['after']))
echo '<a href="javascript:void(0);" onclick="replaceText(\'', $tag['before'], '\', document.forms.', $context['post_form'], '.', $context['post_box_name'], '); return false;">';
// On the other hand, if there is one we are surrounding the selection ;).
else
echo '<a href="javascript:void(0);" onclick="surroundText(\'', $tag['before'], '\', \'', $tag['after'], '\', document.forms.', $context['post_form'], '.', $context['post_box_name'], '); return false;">';

// Okay... we have the link.  Now for the image and the closing </a>!
echo '<img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="', $settings['images_url'], '/bbc/', $image, '.gif" align="bottom" width="23" height="22" alt="', $tag['description'], '" title="', $tag['description'], '" border="0" style="background-image: url(', $settings['images_url'], '/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>';
}
// I guess it's a divider...
else
echo '<img src="', $settings['images_url'], '/bbc/divider.gif" alt="|" style="margin: 0 3px 0 3px;" />';
}

at line 800 approx
could do a mod if you like :)

AzaToth

Made the code for the visual part little more astetic:
/* Extra drop down menu */

echo ' <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
function hoverBox(text, obj, e) {
obj.onmouseout = hideBox;
obj.onmousemove = moveBox;
node = document.createElement(\'div\');
node.style.left = e.layerX + \'px\';
node.style.top = e.layerY + \'px\';
node.id = \'hoverBox\';
node.innerHTML = text;
obj.appendChild(node);
}
function moveBox(e) {
node = document.getElementById(\'hoverBox\');
node.style.left = e.layerX + \'px\';
node.style.top = e.layerY + \'px\';
}
function hideBox() {
node = document.getElementById(\'hoverBox\');
node.parentNode.removeChild(node);
}
// ]]></script>';
echo "\n".'<div style="display: inline; position: relative;">'.
'<img '.
'src="'.$settings['images_url'].'/blank.gif" align="bottom" width="23" height="22" '.
'onmouseover="bbc_highlight(this, true);" '.
'onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" '.
'onclick="elem=this.parentNode.lastChild; elem.style.display = elem.style.display == \'none\' ? \'\' : \'none\'" '.
'style="background-image: url('. $settings['images_url']. '/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px; cursor: pointer;" />'.
'<div id="extra_tags" style="position: absolute; left: 0px; display: none;">'."\n";

foreach($context['bbc_tags_extra'] as $name => $tag)
{
if(!empty($context['disabled_tags'][$tag['code']]))
continue;
if(!isset($tag['before']))
{
$extra_style =  'border-top: 1px solid gray; margin-top: 2px;';
continue;
}
if(!isset($tag['after']))
{
$onclick = 'replaceText(\''. htmlspecialchars($tag['before']). '\', document.forms.'. htmlspecialchars($context['post_form']). '.'. $context['post_box_name']. ');';
$tag['after'] = '';
}
else
{
$onclick = 'surroundText(\''. htmlspecialchars($tag['before']).  '\', \''. htmlspecialchars($tag['after']). '\', document.forms.'. $context['post_form']. '.'. $context['post_box_name']. ');';
}
echo '<div style="'.$extra_style .' font-size: 0.9em; cursor: pointer;" onmouseover="hoverBox(\''.htmlspecialchars($tag['description']).'\',this,event);" onclick="this.parentNode.style.display= \'none\'; '.$onclick.' return false;"><span>'.
htmlspecialchars($tag['before'].$tag['after']).'</span></div>';
$extra_style = '';
echo "\n";

}
echo '</div></div>';


Advertisement: