/* Dank aan Commons:User:Krinkle */
/* OLD WAY:
mwCustomEditButtons = {
"imageId": "mw-customeditbutton-myspecialbutton",
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png",
"speedTip": "Title label",
"tagOpen": "Smile (",
"tagClose": ")",
"sampleText": "sample"}
}
NEW WAY:
kCustomMainInsertButton(
'myspecialbutton', //imageId
'http://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png', //imageFile
'Title label', //speedTip
'Smile (', //tagOpen
')', //tagClose
'sample' //sampleText
);
NB:
Wrap your buttoncode within <code>function kCustomMainInsertButton_config(){ *your code* });</code>.
*/
if ( typeof $ != 'undefined' && typeof $.fn.wikiEditor != 'undefined' && typeof kCustomMainInsertButton == 'undefined' && wgAction == 'edit') {
function kCustomMainInsertButton(imageId,imageFile,speedTip,tagOpen,tagClose,sampleText,callbackFunc){
// Reason for the a-method instead of the much shorter a.b-method
// is to dynamicly set the object name imageId
var wikiOptions = {'section': 'main', 'group': 'insert', 'tools': {}};
wikiOptions = {
label: speedTip,
type: 'button',
icon: imageFile,
action: {
type: 'callback',
execute: function() {
$( '#wpTextbox1' ).textSelection('encapsulateSelection',{
pre: tagOpen,
peri: sampleText,
post: tagClose
});
if(typeof callbackFunc == 'function'){ callbackFunc() }
}
}
}
$('#wpTextbox1').wikiEditor('addToToolbar', wikiOptions)
}
}
$(function(){ $(function(){ kCustomMainInsertButton_config(); }); });