Add BBcolors with javascript
Description
You will be able to add BBCode for colors with a javascript code
Set up
First, go to your javascript panel inside the Administration Panel and create a new code (paste this):
- Code:
$(document).ready(function(){
function addColor(label,color) {
$('#text_editor_select_controls #color').append('<button style="color:'+color+'" onclick="bbfontstyle(\'[color='+color+']\',\'[/color]\');selectWysiwyg(this,\'color\');return false">'+label+'</button><br>');
$('#wcolor').append('<br><button id="text_editor_cmd_constructBBcode_select_color_'+color+'" style="color: '+color+';" class="added-color">'+label+'</button>');
$('.added-color').click(function(e){
vB_Editor['text_editor'].format(e,$(this).attr('id').replace('text_editor_cmd_',''),false,true);
}).attr('class','');
}
addColor('Admin','#00a5cd');
addColor('Color-title','#COLCODE');
});
Customize the tutorial
To change the text that you will display, simply change Color-title with your own message. If you want to change the color change #COLOCODE.
And if you want to add new BBcode colors you can add this part (and edit it) to the code above separated with a line (Go down):
- Code:
addColor('Color-title','#COLCODE');
Technical problems
![]() | The tutorial was tested on this forum and with the browser Google Chrome; If you notice that the tutorial doesn't work for a browser or for a version of forum (PhpBB2, PhpBB3, PunBB, Invision) contact an administrator and we will fill this field with your reporting. Thanks, the staff |
![]() | For every problem or question please, contact us in the section Support for the tutorials, The staff will answer you as soon as it is possible... |
Friendly,
The team of the Forum of Codes.