Hi.
I'm trying to create a button which will apply some CSS class (defined externally), atm I've create this plugin:
Added Code.gif icon to plugin folder and registered it:
Button shows correctly and fires Execute on click.
But I don't understand how do I:
Thanks for answers.
I'm trying to create a button which will apply some CSS class (defined externally), atm I've create this plugin:
var FCKCode=function(name){
this.Name=name;
};
FCKCode.prototype.Execute=function(){
FCKUndo.SaveUndoStep();
var style=new FCKStyle({Element: 'span',Styles: {'background-color': 'red'}});
alert(FCK.Styles.CheckStyleInSelection(style));
if(FCK.Styles.CheckStyleInSelection(style))
FCK.Styles.RemoveStyle(style);
else FCK.Styles.ApplyStyle(style);
FCKUndo.SaveUndoStep();
FCK.Focus();
FCK.Events.FireEvent('OnSelectionChange');
};
FCKCode.prototype.GetState=function(){
if(FCK.EditMode!=FCK_EDITMODE_WYSIWYG||!FCK.EditorDocument)
return FCK_TRISTATE_DISABLED;
if(FCKSelection.GetType()=='Control'){
var el=FCKSelection.GetSelectedElement();
if(!el||!FCKStyles.CheckHasObjectStyle(el.nodeName.toLowerCase()))
return FCK_TRISTATE_DISABLED;
}
return FCK_TRISTATE_OFF;
};
FCKCommands.RegisterCommand('Code',new FCKCode('Code'));
var oCodeItem=new FCKToolbarButton('Code','Code',null,null,false,true);
oCodeItem.IconPath=FCKConfig.PluginsPath+'code/Code.gif';
FCKToolbarItems.RegisterItem('Code',oCodeItem);
Added Code.gif icon to plugin folder and registered it:
FCKConfig.Plugins.Add('code');
Button shows correctly and fires Execute on click.
But I don't understand how do I:
- Make it work with external style (in CSS file).
- Figure out is this style already applied.
- Correctly remove the style.
Thanks for answers.

Re: Problem with selection styling.