MediaWiki:Common.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
// Check if we're editing a page. https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization#Basic_setup https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization/Library
if (['edit', 'submit'].indexOf(mw.config.get('wgAction')) !== -1) {
// Add a hook handler.
mw.hook('wikiEditor.toolbarReady').add(function($textarea) {
// Configure a new toolbar entry on the given $textarea jQuery object.
// Strike through text
$textarea.wikiEditor('addToToolbar', {
section: 'main',
group: 'format',
tools: {
"strikethrough": {
label: 'Strike',
type: 'button',
oouiIcon: 'strikethrough',
action: {
type: 'encapsulate',
options: {
pre: "<s>",
post: "</s>"
}
}
}
}
});
// no include
$textarea.wikiEditor('addToToolbar', {
section: 'advanced',
group: 'insert',
tools: {
"noinclude": {
label: 'NoInclude',
type: 'button',
icon: 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/79/OOjs_UI_icon_eyeClosed.svg/20px-OOjs_UI_icon_eyeClosed.svg.png',
//filters: ['body.ns-10'],
action: {
type: 'encapsulate',
options: {
pre: "<noinclude>",
post: "</noinclude>"
}
}
},
"includeonly": {
label: 'IncludeOnly',
type: 'button',
icon: 'https://upload.wikimedia.org/wikipedia/commons/thumb/c/cf/OOjs_UI_icon_eye.svg/20px-OOjs_UI_icon_eye.svg.png',
//filters: ['body.ns-10'],
action: {
type: 'encapsulate',
options: {
pre: "<includeonly>",
post: "</includeonly>"
}
}
},
"insertcategory": {
label: 'Category',
type: 'button',
icon: 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a0/OOjs_UI_icon_wikiText.svg/20px-OOjs_UI_icon_wikiText.svg.png',
//filters: ['body.ns-10'],
action: {
type: 'encapsulate',
options: {
pre: "[[Category:",
post: "]]"
}
}
}
}
});
});
}