User:Hafspajen/common.js
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.
var customizeToolbar = function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'sections': {
'extras': {
'type': 'toolbar', // Can also be 'booklet'
'label': 'Extras'
// or 'labelMsg': 'section-emoticons-label' for a localized label
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'extras',
'groups': {
'chars': {
'label': 'Chars' // or use labelMsg for a localized label, see above
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'extras',
'group': 'chars',
'tools': {
'templ': {
label: 'Template',
type: 'button',
icon: 'commons.wikimedia.org/wiki/File:Norwegian_template_sign.png',
action: {
type: 'encapsulate',
options: {
pre: "{{", // text to be inserted
post: "}}" // text to be inserted
}
}
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'extras',
'group': 'chars',
'tools': {
'linkl': {
label: 'Link',
type: 'button',
icon: 'commons.wikimedia.org/wiki/File:Norwegian_link_sign.png',
action: {
type: 'encapsulate',
options: {
pre: "[[", // text to be inserted
post: "]]" // text to be inserted
}
}
}
}
} );
};
/* Check if view is in edit mode and that the required modules are available. 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.user.options.get( 'showtoolbar' ) ) {
$.when(
mw.loader.using( 'ext.wikiEditor' ),
$.ready
).then( customizeToolbar );
}
} );
}
// Add the customizations to LiquidThreads' edit toolbar, if available
mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar );