FYI --
I created a 'label' control for the toolbar, that allows the Html to be changed dynamically with a SetLabel(html) function. I'm currently using it as a plugin, but thought it might be useful to integrate into the core FCK product in some form. It's pretty much some modded code based off the toolbar button stuff. This is useful especially when you're running in full screen mode and have some simple document information you want displayed in the toolbar (last editor in my instance).
Usage:
FCKToolbarItems.RegisterItem('toolbaritem', new FCKToolbarLabel('toolbaritem', 'mytoolbarlabel', 'tooltip'));
Enjoy!
var FCKToolbarLabelUI = function(name, label, tooltip)
{
this.Name = name;
this.Label = label || name;
this.Tooltip = tooltip || this.Label;
this.Style = FCK_TOOLBARITEM_ONLYTEXT;
this.LabelCell = null;
if (FCK.IECleanup)
FCK.IECleanup.AddItem(this, FCKToolbarButtonUI_Cleanup);
}
FCKToolbarLabelUI.prototype._CreatePaddingElement = function(document)
{
var oImg = document.createElement('IMG');
oImg.className = 'TB_Button_Padding';
oImg.src = FCK_SPACER_PATH;
return oImg;
}
FCKToolbarLabelUI.prototype.Create = function(parentElement)
{
var oDoc = FCKTools.GetElementDocument(parentElement);
// Create the Main Element.
var oMainElement = this.MainElement = oDoc.createElement('DIV');
oMainElement.title = this.Tooltip;
// The following will prevent the button from catching the focus.
if (FCKBrowserInfo.IsGecko)
oMainElement.onmousedown = FCKTools.CancelEvent;
// <td><div class="TB_Button_On" title="Smiley"><table cellpadding="0" cellspacing="0"><tr><td><img class="TB_Button_Padding"></td><td nowrap>Toolbar Button</td><td><img class="TB_Button_Padding"></td></tr></table></div></td>
var oTable = oMainElement.appendChild(oDoc.createElement('TABLE'));
oTable.cellPadding = 0;
oTable.cellSpacing = 0;
var oRow = oTable.insertRow(-1);
// The Image cell (icon or padding).
var oCell = oRow.insertCell(-1);
oCell.appendChild(this._CreatePaddingElement(oDoc));
// The Text cell.
this.LabelCell = oRow.insertCell(-1);
this.LabelCell.className = 'TB_Button_Text';
this.LabelCell.noWrap = true;
this.LabelCell.appendChild(oDoc.createTextNode(this.Label));
// The last padding cell.
oCell = oRow.insertCell(-1);
oCell.appendChild(this._CreatePaddingElement(oDoc));
parentElement.appendChild(oMainElement);
}
FCKToolbarLabelUI.prototype.SetLabel = function(html)
{
this.LabelCell.innerHTML = html;
}
function FCKToolbarButtonUI_Cleanup()
{
// This one should not cause memory leak, but just for safety, let's clean it up.
this.LabelCell = null;
this.MainElement = null;
}
var FCKToolbarLabel = function(commandName, label, tooltip)
{
var labelCommand = new Object();
labelCommand.Name = commandName;
// This is the standard function used to execute the command (called when clicking in the context menu item).
labelCommand.Execute = function()
{ }
// This is the standard function used to retrieve the command state (it could be disabled for some reason).
labelCommand.GetState = function()
{
// Let's make it always enabled.
return FCK_TRISTATE_OFF;
}
FCKCommands.RegisterCommand(commandName, labelCommand);
this.CommandName = commandName;
this.Label = label;
this.Tooltip = this.Label;
this.Style = FCK_TOOLBARITEM_ONLYTEXT;
this.DefaultLabel = this.Label; // FCKConfig.DefaultFontLabel || '' ;
this.SourceView = true;
this.ContextSensitive = false;
this.IconPath = null;
}
FCKToolbarLabel.prototype.SetLabel = function(html)
{
this._UILabel.SetLabel(html);
}
FCKToolbarLabel.prototype.Create = function(targetElement)
{
this._UILabel = new FCKToolbarLabelUI(this.CommandName, this.Label, this.Tooltip);
this._UILabel._ToolbarButton = this;
this._UILabel.Create(targetElement);
}
I created a 'label' control for the toolbar, that allows the Html to be changed dynamically with a SetLabel(html) function. I'm currently using it as a plugin, but thought it might be useful to integrate into the core FCK product in some form. It's pretty much some modded code based off the toolbar button stuff. This is useful especially when you're running in full screen mode and have some simple document information you want displayed in the toolbar (last editor in my instance).
Usage:
FCKToolbarItems.RegisterItem('toolbaritem', new FCKToolbarLabel('toolbaritem', 'mytoolbarlabel', 'tooltip'));
Enjoy!
var FCKToolbarLabelUI = function(name, label, tooltip)
{
this.Name = name;
this.Label = label || name;
this.Tooltip = tooltip || this.Label;
this.Style = FCK_TOOLBARITEM_ONLYTEXT;
this.LabelCell = null;
if (FCK.IECleanup)
FCK.IECleanup.AddItem(this, FCKToolbarButtonUI_Cleanup);
}
FCKToolbarLabelUI.prototype._CreatePaddingElement = function(document)
{
var oImg = document.createElement('IMG');
oImg.className = 'TB_Button_Padding';
oImg.src = FCK_SPACER_PATH;
return oImg;
}
FCKToolbarLabelUI.prototype.Create = function(parentElement)
{
var oDoc = FCKTools.GetElementDocument(parentElement);
// Create the Main Element.
var oMainElement = this.MainElement = oDoc.createElement('DIV');
oMainElement.title = this.Tooltip;
// The following will prevent the button from catching the focus.
if (FCKBrowserInfo.IsGecko)
oMainElement.onmousedown = FCKTools.CancelEvent;
// <td><div class="TB_Button_On" title="Smiley"><table cellpadding="0" cellspacing="0"><tr><td><img class="TB_Button_Padding"></td><td nowrap>Toolbar Button</td><td><img class="TB_Button_Padding"></td></tr></table></div></td>
var oTable = oMainElement.appendChild(oDoc.createElement('TABLE'));
oTable.cellPadding = 0;
oTable.cellSpacing = 0;
var oRow = oTable.insertRow(-1);
// The Image cell (icon or padding).
var oCell = oRow.insertCell(-1);
oCell.appendChild(this._CreatePaddingElement(oDoc));
// The Text cell.
this.LabelCell = oRow.insertCell(-1);
this.LabelCell.className = 'TB_Button_Text';
this.LabelCell.noWrap = true;
this.LabelCell.appendChild(oDoc.createTextNode(this.Label));
// The last padding cell.
oCell = oRow.insertCell(-1);
oCell.appendChild(this._CreatePaddingElement(oDoc));
parentElement.appendChild(oMainElement);
}
FCKToolbarLabelUI.prototype.SetLabel = function(html)
{
this.LabelCell.innerHTML = html;
}
function FCKToolbarButtonUI_Cleanup()
{
// This one should not cause memory leak, but just for safety, let's clean it up.
this.LabelCell = null;
this.MainElement = null;
}
var FCKToolbarLabel = function(commandName, label, tooltip)
{
var labelCommand = new Object();
labelCommand.Name = commandName;
// This is the standard function used to execute the command (called when clicking in the context menu item).
labelCommand.Execute = function()
{ }
// This is the standard function used to retrieve the command state (it could be disabled for some reason).
labelCommand.GetState = function()
{
// Let's make it always enabled.
return FCK_TRISTATE_OFF;
}
FCKCommands.RegisterCommand(commandName, labelCommand);
this.CommandName = commandName;
this.Label = label;
this.Tooltip = this.Label;
this.Style = FCK_TOOLBARITEM_ONLYTEXT;
this.DefaultLabel = this.Label; // FCKConfig.DefaultFontLabel || '' ;
this.SourceView = true;
this.ContextSensitive = false;
this.IconPath = null;
}
FCKToolbarLabel.prototype.SetLabel = function(html)
{
this._UILabel.SetLabel(html);
}
FCKToolbarLabel.prototype.Create = function(targetElement)
{
this._UILabel = new FCKToolbarLabelUI(this.CommandName, this.Label, this.Tooltip);
this._UILabel._ToolbarButton = this;
this._UILabel.Create(targetElement);
}