Skip to content

Instantly share code, notes, and snippets.

@danmichaelo
Created March 31, 2012 21:55
Show Gist options
  • Select an option

  • Save danmichaelo/2268929 to your computer and use it in GitHub Desktop.

Select an option

Save danmichaelo/2268929 to your computer and use it in GitHub Desktop.
MediaWiki : Toolbar add custom button
function customizeToolbar() {
$('#wpTextbox1').wikiEditor('addToToolbar', {
'section': 'main',
'group': 'format',
'tools': {
'guillemets': {
label: 'Anførselstegn',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/b/b5/Wikify_button.svg',
action: {
type: 'encapsulate',
options: {
pre: "«",
post: "»"
}
}
}
}
});
}
/* Check if we are in edit mode and the required modules are available and then customize the toolbar */
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1 ) {
mw.loader.using( 'user.options', function () {
if ( mw.user.options.get('usebetatoolbar') ) {
mw.loader.using( 'ext.wikiEditor.toolbar', function () {
$(customizeToolbar);
} );
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment