User:Jean-Frédéric/toolbar.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
Documentation for this user script can be added at User:Jean-Frédéric/toolbar. |
// To add a toolbar section:
function addSectionToToolbar(sectionId, sectionName)
{
$(document).ready( function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'sections': {
sectionId: {
'type': 'toolbar', // Can also be 'booklet'
'label': sectionName
}
}
} );
}
}
// To add a group to an existing toolbar section:
function addGroupToToolbarSection(groupId, groupName, sectionId)
{
$(document).ready( function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': sectionId,
'groups': {
groupId: {
'label': groupName
}
}
} );
}
}
// To add a button to an existing toolbar group:
function addButtonToToolbarGroup(buttonId, buttonLabel, buttonIcon, buttonPre, buttonPost, buttonOwnline, groupId, sectionId)
{
$(document).ready( function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': sectionId,
'group': groupId,
'tools': {
buttonId: {
label: buttonLabel,
type: 'button',
icon: buttonIcon,
action: {
type: 'encapsulate',
options: {
pre: buttonPre
post: buttonPost
ownline: buttonOwnline
buttonIcon
}
}
}
}
} );
}
}
function CustomToolbar(){
addButtonToToolbarGroup(
'strikethrough',
'Strike',
'http://upload.wikimedia.org/wikipedia/commons/3/30/Btn_toolbar_rayer.png',
"<s>",
"</s>",
true,
'format',
'advanced'
);
if ( typeof $ != 'undefined' && typeof $.fn.wikiEditor != 'undefined' ) {
$(document).ready( function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'advanced',
'group': 'format',
'tools': {
'comment': {
label: 'Comment',
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/3/37/Btn_toolbar_commentaire.png',
action: {
type: 'encapsulate',
options: {
pre: "<!-- ",
post: " -->"
}
}
}
}
} );
} );
}
}
addOnloadHook(CustomToolbar);