tracing into nicEdit code I found that buttons actually appear on the screen when setPanel() API function is being called.
setPanel() draws standard buttons, then it passes 'panel' event to fireEvent() API function which then invokes loadPanel(), which in turn calls addButton(), which tests button.type by evaluating it:
addButton : function(buttonName,options,noOrder) {
var button = options.buttons[buttonName];
var type = (button['type']) ? eval('(typeof('+button['type']+') == "undefined") ? null : '+button['type']+';') : nicEditorButton;
// <== here type is null, cause I defined button['type'] as local variable in separate file
var hasButton = bkLib.inArray(this.buttonList,buttonName);
if(type && (hasButton || this.ne.options.fullPanel)) {
this.panelButtons.push(new type(this.panelElm,buttonName,options,this.ne));
if(!hasButton) {
this.buttonList.push(buttonName);
}
}
},
in the snippet above the code eval('(typeof('+button['type']+') == "undefined")
returnes true as I defined the button type as a local variable:
var nicEditorExampleButton = nicEditorButton.extend({
mouseClick : function() {
alert('The example save button icon has been clicked!');
}
});
The button appeared as soon as I defined the button type as global:
nicEditorExampleButton = nicEditorButton.extend({
mouseClick : function() {
alert('The example save button icon has been clicked!');
}
});
I think type existance which nicEdit does should perform more clear and reliable way to prevent global namespace pollution, maybe as of (typeof(button['type']) == "undefined")