<script type="text/javascript">
(function($){
$.extend($.fn.texteditor.defaults.commands, {
'forecolor': {
type: 'menubutton',
iconCls: 'icon-forecolor',
menu: $('<div class="menu-content" style="box-sizing:border-box;width:156px;height:120px"></div>'),
duration: 99999999,
width: 26,
onClick: function(){
var target = this
var menu = $(target).menubutton('options').menu;
if (menu.is(':empty')){
menu.append(
'<style>' +
'.te-color{box-sizing:border-box;display:block;width:18px;height:18px;float:left;cursor:pointer;border:1px solid #fff}' +
'.te-color:hover{border:1px solid #000}' +
'</style>'
);
var colors = [
"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="te-color"></a>').appendTo(menu);
a.css('backgroundColor', 'rgb('+colors[i]+')');
}
menu.bind('click', function(e){
if ($(e.target).hasClass('te-color')){
var color = $(e.target).css('backgroundColor');
menu.menu('hide');
$(target).texteditor('getEditor').texteditor('execCommand','foreColor '+color);
}
});
}
}
}
});
$.fn.texteditor.defaults.toolbar.push('forecolor')
})(jQuery);
</script>