Hi,
You can add a new button without touching the wymeditor's code.
What I recommand is to build a plugin for your fonctionality, and than you include this plugin, and you call it in the skin you use, or in the postInit function.
This is an exemple of code you could use as a base to make your dialog plugin. I extracted this from a plugin I made, but my plugin was much more messy, so I can't publish it all :
- Code: Select all
;window.jQuery && (function($) {
var html = '<body class="wym_dialog wym_dialog_myplugin"'
+ ' onload="window.opener.WYMeditor.INIT_MY_DIALOG(window, ' + WYMeditor.INDEX + ')"'
+ '>'
// The HTML code here for the dialog
+ '</body>'
WYMeditor.INIT_MY_DIALOG = function(wdw, index) {
var wym = WYMeditor.INSTANCES[index];
var doc = wdw.document;
var selected = wym.selected();
//add css rules from options
var styles = doc.styleSheets[0];
var aCss = eval(wym._options.dialogStyles);
wym.addCssRules(doc, aCss);
// ....... Any code you want. You can take exemple on WYMeditor.INIT_DIALOG
// Handle here events like form submition for exemple.
};
$.extend(WYMeditor.editor.prototype, {
// Function to be called for initialisation in the skin init, or in postInit
MyPluginInit: function() {
var dialog = (function(wym) {
return function() {
wym.dialog( 'Dialog Title', html );
return false;
};
})(this);
// Insert a button in the toolbox after the link button
$(this._box)
.find('.wym_tools ul .wym_tools_link')
.after(
$(
'<li class="wym_tools_myplugin">'+
'<a title="Insert what I want" href="#">'+
'Insert what I want'+
'</a>'+
'</li>'
)
.mousedown(dialog)
);
}
});
})(window.jQuery);
Nico