Now i'm not very good at javascript, so if someone finds this useful and wants to do it in a better way i'll be happy to use your code instead of mine but it seems to work for me atm.
![Smile :)](./images/smilies/icon_smile.gif)
Simply put it makes a cookie whenever someone presses B,I or U, and when sending the message it checks for that cookie and adds the appropriate BBCode to the message, it was the easiest way to do this i could think of.
First of all i put this code in pfcclient.js after the switch_text_color function
- Code: Select all
makeBold: function()
{
this.font_weight = 'bold';
fcookie = getCookie('pfc_font_weight');
if (fcookie == 'bold')
{
this.font_weight = 'normal';
}
this.el_words.style.fontWeight = this.font_weight;
this.el_words.focus();
setCookie('pfc_font_weight', this.font_weight);
},
makeItalic: function()
{
this.font_style = 'italic';
fcookie = getCookie('pfc_font_style');
if (fcookie == 'italic')
{
this.font_style = 'normal';
}
this.el_words.style.fontStyle = this.font_style;
this.el_words.focus();
setCookie('pfc_font_style', this.font_style);
},
makeUnderline: function()
{
this.font_decoration = 'underline';
fcookie = getCookie('pfc_font_decoration');
if (fcookie == 'underline')
{
this.font_decoration = 'none';
}
this.el_words.style.textDecoration = this.font_decoration;
this.el_words.focus();
setCookie('pfc_font_decoration', this.font_decoration);
},
Second i put this code at line 543 (still in pfcclient.js) after the part that colorizes the text
- Code: Select all
// make the text bold if a cookie is set
fcookie = getCookie('pfc_font_weight');
if (fcookie == 'bold')
{
var wval = '[b]' + wval + '[/b]';
}
// make the text italic if a cookie is set
fcookie = getCookie('pfc_font_style');
if (fcookie == 'italic')
{
var wval = '[i]' + wval + '[/i]';
}
// make the text underlined if a cookie is set
fcookie = getCookie('pfc_font_decoration');
if (fcookie == 'underline')
{
var wval = '[u]' + wval + '[/u]';
}
And third of course i changed the onclick actions on the actual buttons, you can find these around line 100 in themes/default/chat.html.tpl.php
- Code: Select all
<div id="pfc_bbcode_container">
<div class="pfc_btn">
<img src="<?php echo $c->getFileUrlFromTheme('images/bt_strong.gif'); ?>"
alt="<?php echo _pfc("Bold"); ?>"
title="<?php echo _pfc("Bold"); ?>"
class="pfc_bt_strong"
onclick="pfc.makeBold()" />
</div>
<div class="pfc_btn">
<img src="<?php echo $c->getFileUrlFromTheme('images/bt_em.gif'); ?>"
alt="<?php echo _pfc("Italics"); ?>"
title="<?php echo _pfc("Italics"); ?>"
class="pfc_bt_strong"
onclick="pfc.makeItalic()" />
</div>
<div class="pfc_btn">
<img src="<?php echo $c->getFileUrlFromTheme('images/bt_ins.gif'); ?>"
alt="<?php echo _pfc("Underline"); ?>"
title="<?php echo _pfc("Underline"); ?>"
class="pfc_bt_strong"
onclick="pfc.makeUnderline()" />
</div>