I've added a convenient array you can use to add custom buttons. See: http://en.wikipedia.org/wiki/MediaWiki_talk:Monobook.js#Redirect_edit_button http://en.wikipedia.org/w/index.php?title=MediaWiki:Monobook.js&diff=488...
Yes, i found mwCustomEditButtons when looking for it. But it's only useful if you are using inserttags in your buttons.
http://svn.wikimedia.org/viewvc/mediawiki?view=rev&revision=13689
"This makes it compatible with viewing in XML mode in strict browsers like Firefox" I think it worked perfectly in Firefox. The only little change i see is that if you drag&dropped a button before it used the javascript of the href and now (as it doesn't exist) uses the img src.
It seems that the problem appears when we use the innerHTML method, the div is reloaded but the onclick function is not preserved. A simple javascript:void(document.getElementById("toolbar").innerHTML+=""); breaks it. mwSetupToolbar() In fact, javascript:alert(document.getElementById('toolbar').innerHTML); when returning the generated HTML, don't show onclick property.
I developed this piece of code to fix it. It sets again the onclick property for each button. It only can be called after mwSetupToolbar() has done its work. The toolbar.getElementsByTagName("img")[j++], will always exist as it must have been created by mwSetupToolbar(). Note that if you added some button *between* the buttons the software adds, the actions may be overlapped, failing.
mwSetItemOnClick performs the same work done at mwInsertEditButton 9th line. Then the calling of javascript:mwRestoreToolbarFunctions() makes the buttons work again. Note that if added from a monobook it should be the last included because if there's any load event fired _after_ mwRestoreToolbarFunctions restored it, that new function may break it again, so you wouldn't see any change (not working again). You can see an example of this at [[es:Usuario:Platonides/RestoreToolbarFunctions.js]]. You can -as always- freely hotlink and modify it, but please, give some feedback (even if it's a message of "I have starting using this and it works ok :-)" ).
function mwSetItemOnClick(image, item) { image.onclick = function() { insertTags(item.tagOpen, item.tagClose, item.sampleText); return false; } }
function mwRestoreToolbarFunctions() { /* We perform the same checks as mwSetupToolbar. mwSetupToolbar MUST have created the buttons. This function MUSN'T be called before it. Thus, we check all conditions that may have stopped mwSetupToolbar of creating the buttons. */
var toolbar = document.getElementById('toolbar'); if (!toolbar) return false;
var textbox = document.getElementById('wpTextbox1'); if (!textbox) return false;
// Don't generate buttons for browsers which don't fully // support it. if (!document.selection && textbox.selectionStart == null) return false;
var j=0; for (var i in mwEditButtons) { mwSetItemOnClick(toolbar.getElementsByTagName("img")[j++], mwEditButtons[i]); } for (var i in mwCustomEditButtons) { mwSetItemOnClick(toolbar.getElementsByTagName("img")[j++], mwCustomEditButtons[i]); } }