//I should be able to combine these
//colours are weird in dark mode
//https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization
// <nowiki>
if (['edit', 'submit'].indexOf(mw.config.get('wgAction')) !== -1) {
mw.hook('wikiEditor.toolbarReady').add(function($textarea) {
$textarea.wikiEditor('addToToolbar', {
section: 'advanced',
group: 'insert',
tools: {
welcomeButton: {
label: 'Welcome',
filters: [ 'body.ns-3' ],
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/6/6f/Handshake_icon_BLACK_and_WHITE.svg',
action: {
type: 'encapsulate',
options: {
pre: '{{subst:' + 'User:Polygnotus/Templates/welcome}} ~~' + '~~',
}
}
},
refIdeas: {
type: 'element',
filters: [ 'body.ns-1' ],
element: function ( context ) {
var button = new OO.ui.ButtonInputWidget( {
label: '',
icon: 'lightbulb',
title: 'refideas'
} );
button.connect( null, {
click: function ( e ) {
var text = '{{refideas\n|1=\n}}';
var textarea = context.$textarea[0];
var start = textarea.selectionStart;
var end = textarea.selectionEnd;
var currentText = textarea.value;
textarea.value = currentText.substring(0, start) + text + currentText.substring(end);
textarea.selectionStart = textarea.selectionEnd = start + text.length;
textarea.focus();
$(textarea).trigger('input');
$('#wpSummary').val('Added {{refideas}} template');
}
} );
return button.$element;
}
},
wpPolicy: {
type: 'element',
element: function ( context ) {
var button = new OO.ui.ButtonInputWidget( {
label: 'ReadThis',
icon: 'articles'
} );
button.connect( null, {
click: function ( e ) {
var policy = prompt('Enter Wikipedia policy/guideline abbreviation (e.g., NPOV, V, RS):');
if (policy !== null && policy.trim() !== '') {
var text = '== [[WP:' + policy.trim() + ']] ==\nPlease read [[WP:' + policy.trim() + ']], thanks and have a nice day, ~~~~';
context.$textarea.textSelection('encapsulateSelection', {
pre: text
});
}
}
} );
return button.$element;
}
},
exlinkInBody: {
type: 'element',
filters: [ 'body.ns-3' ],
element: function ( context ) {
var button = new OO.ui.ButtonInputWidget( {
label: 'ExternalLinkInBody',
icon: '//upload.wikimedia.org/wikipedia/commons/0/05/IUCN_EX.svg'
} );
button.connect( null, {
click: function ( e ) {
var text = '{{subst:' + 'User:Polygnotus/Templates/exlink}} ~~' + '~~';
context.$textarea.textSelection('encapsulateSelection', {
pre: text
});
}
} );
return button.$element;
}
},
uwSpam: {
type: 'element',
filters: [ 'body.ns-3' ],
element: function ( context ) {
var button = new OO.ui.ButtonInputWidget( {
label: 'Uw-Spam',
icon: '//upload.wikimedia.org/wikipedia/commons/c/c8/No-spam.svg'
} );
button.connect( null, {
click: function ( e ) {
var text = '{{subst:' + 'uw-spam}} ~~' + '~~';
context.$textarea.textSelection('encapsulateSelection', {
pre: text
});
}
} );
return button.$element;
}
},
teahouseButton: {
label: 'Teahouse',
filters: [ 'body.ns-3' ],
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/0/0d/Questionmark_SVG_4.svg',
action: {
type: 'encapsulate',
options: {
pre: 'If you have any questions, the [[WP:TEAHOUSE]] is a great place to get answers.',
}
}
},
vand1Button: {
label: 'Vandalism warning level 1',
filters: [ 'body.ns-3' ],
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/8/8a/Eo_circle_grey_number-1.svg',
action: {
type: 'encapsulate',
options: {
pre: '{{subst:' + 'uw-vand1}} ~~' + '~~',
}
}
},
vand2Button: {
label: 'Vandalism warning level 2',
filters: [ 'body.ns-3' ],
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/c/c7/Eo_circle_yellow_number-2.svg',
action: {
type: 'encapsulate',
options: {
pre: '{{subst:' + 'uw-vand2}} ~~' + '~~',
}
}
},
vand3Button: {
label: 'Vandalism warning level 3',
filters: [ 'body.ns-3' ],
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/c/c5/Eo_circle_deep-orange_number-3.svg',
action: {
type: 'encapsulate',
options: {
pre: '{{subst:' + 'uw-vand3}} ~~' + '~~',
}
}
},
vand4Button: {
label: 'Vandalism warning level 4',
filters: [ 'body.ns-3' ],
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/c/cd/Eo_circle_red_number-4.svg',
action: {
type: 'encapsulate',
options: {
pre: '{{subst:' + 'uw-vand4}} ~~' + '~~',
}
}
}
}
});
});
}
// </nowiki>