The 'forecolor' and 'backcolor' should be menubutton components, you need to set the 'type' property as 'menubutton'.
{
type:'menubutton',
name:'forecolor',
iconCls:'icon-forecolor'
}
When clicking on these two buttons, the drop-down color panel should display to allow the user to select the colors. Please look at the code below:
$(function(){
function buildColorPanel(mb){
var opts = $(mb).menubutton('options');
if (!opts.menu){
opts.menu = $('<div class="menu-content texteditor-color"></div>');
}
opts.menu.menu({
onShow: function(){
if ($(this).is(':empty')){
var colors = [
"0,0,0","68,68,68","102,102,102","153,153,153","204,204,204","238,238,238","243,243,243","255,255,255",
"244,204,204","252,229,205","255,242,204","217,234,211","208,224,227","207,226,243","217,210,233","234,209,220",
"234,153,153","249,203,156","255,229,153","182,215,168","162,196,201","159,197,232","180,167,214","213,166,189",
"224,102,102","246,178,107","255,217,102","147,196,125","118,165,175","111,168,220","142,124,195","194,123,160",
"204,0,0","230,145,56","241,194,50","106,168,79","69,129,142","61,133,198","103,78,167","166,77,121",
"153,0,0","180,95,6","191,144,0","56,118,29","19,79,92","11,83,148","53,28,117","116,27,71",
"102,0,0","120,63,4","127,96,0","39,78,19","12,52,61","7,55,99","32,18,77","76,17,48"
];
for(var i=0; i<colors.length; i++){
var a = $('<a class="texteditor-colorcell"></a>').appendTo(this);
a.css('backgroundColor', 'rgb('+colors[i]+')');
}
}
}
});
opts.menu.bind('click', function(e){
if ($(e.target).hasClass('texteditor-colorcell')){
var color = $(e.target).css('backgroundColor');
var cmd = opts.name + ' ' + color;
$('#editor').texteditor('getEditor').texteditor('execCommand',cmd);
opts.menu.menu('hide');
}
});
$(mb).menubutton({menu:opts.menu}); // attach the menu
}
$('#rr').ribbon({
data:data,
onClick: function(name,target){
if (name == 'forecolor' || name == 'backcolor'){
buildColorPanel($(target));
$(target).trigger('mouseenter');
}
}
});
});