User:Polygnotus/Scripts/WikiEditorToolbar.js: Difference between revisions

Content deleted Content added
No edit summary
use OOUI
 
(47 intermediate revisions by the same user not shown)
Line 2:
//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: {
buttonIdwelcomeButton: {
label: 'Welcome',
filters: [ 'body.ns-3' ],
type: 'button',
icon: '//https://upload.wikimedia.org/wikipedia/commons/86/826f/NotoSans_-_Raised_Hand_With_Fingers_Splayed_-_1F590Handshake_icon_BLACK_and_WHITE.svg',
action: {
type: 'encapsulate',
options: {
pre: '{{subst:' + 'Welcome-newuser|heading=noUser:Polygnotus/Templates/welcome}} ~~' + '~~',
}
}
},
}
}); refIdeas: {
type: 'element',
});
filters: [ 'body.ns-1' ],
}
element: function ( context ) {
 
var button = new OO.ui.ButtonInputWidget( {
 
label: '',
 
icon: 'lightbulb',
 
title: 'refideas'
if (['edit', 'submit'].indexOf(mw.config.get('wgAction')) !== -1) {
} );
mw.hook('wikiEditor.toolbarReady').add(function($textarea) {
button.connect( null, {
$textarea.wikiEditor('addToToolbar', {
section click: 'advanced',function ( e ) {
var text = '{{refideas\n|1=\n}}';
group: 'insert',
tools: {
var textarea = context.$textarea[0];
buttonId: {
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',
Line 45 ⟶ 142:
}
}
},
}
vand2Button: {
});
});
}
 
 
if (['edit', 'submit'].indexOf(mw.config.get('wgAction')) !== -1) {
mw.hook('wikiEditor.toolbarReady').add(function($textarea) {
$textarea.wikiEditor('addToToolbar', {
section: 'advanced',
group: 'insert',
tools: {
buttonId: {
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',
Line 68 ⟶ 155:
}
}
},
}
vand3Button: {
});
});
}
 
 
if (['edit', 'submit'].indexOf(mw.config.get('wgAction')) !== -1) {
mw.hook('wikiEditor.toolbarReady').add(function($textarea) {
$textarea.wikiEditor('addToToolbar', {
section: 'advanced',
group: 'insert',
tools: {
buttonId: {
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',
Line 91 ⟶ 168:
}
}
},
}
vand4Button: {
});
});
}
 
 
if (['edit', 'submit'].indexOf(mw.config.get('wgAction')) !== -1) {
mw.hook('wikiEditor.toolbarReady').add(function($textarea) {
$textarea.wikiEditor('addToToolbar', {
section: 'advanced',
group: 'insert',
tools: {
buttonId: {
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',
Line 117 ⟶ 184:
}
});
 
});
}
 
// </nowiki>