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

Content deleted Content added
No edit summary
use OOUI
 
(19 intermediate revisions by the same user not shown)
Line 1:
//I should be able to combine these
//colours are weird in dark mode
 
//https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization
 
// <nowiki>
Line 24 ⟶ 26:
refIdeas: {
labeltype: 'RefIdeaselement',
filters: [ 'body.ns-31' ],
typeelement: 'button',function ( context ) {
var button = new OO.ui.ButtonInputWidget( {
icon: '//upload.wikimedia.org/wikipedia/commons/8/8c/Farm-Fresh_lightbulb_add.png',
action label: {'',
type icon: 'encapsulatelightbulb',
options title: {'refideas'
} pre: '{{refideas\n|1=\n}}',);
}button.connect( null, {
click: function }( e ); {
var text = '{{refideas\n|1=\n}}';
width: 26,
var textarea = context.$textarea[0];
var start = textarea.selectionStart;
var end = textarea.selectionEnd;
var currentText = textarea.value;
options: {
textarea.value = currentText.substring(0, start) + text + currentText.substring(end);
textarea.selectionStart = textarea.selectionEnd = start + text.length;
textarea.focus();
type: 'encapsulate',
$(textarea).trigger('input');
type: 'encapsulate',
$('#wpSummary').val('Added {{refideas}} template');
}
} );
return button.$element;
}
},
Line 40 ⟶ 60:
element: function ( context ) {
var button = new OO.ui.ButtonInputWidget( {
label: 'WP PolicyReadThis',
icon: 'articlearticles'
} );
button.connect( null, {
click: function ( e ) {
OO.ui.var policy = prompt( 'Enter Wikipedia policy/guideline abbreviation (e.g., NPOV, V, RS):' ).done( function ( answer ) {;
if ( answerpolicy !== null && answerpolicy.trim() !== '' ) {
var text = '== [[WP:' + answerpolicy.trim() + ']] ==\nPlease read [[WP:' + answerpolicy.trim() + ']], thanks and have a nice day, ~~~~';
context.fn$textarea.encapsulateSelectiontextSelection('encapsulateSelection', {
pre: text
} );
}
} );
}
} );
Line 60 ⟶ 79:
exlinkInBody: {
labeltype: 'ExternalLinkInBodyelement',
filters: [ 'body.ns-3' ],
typeelement: 'button',function ( context ) {
icon: var button = new OO.ui.ButtonInputWidget( {
label: 'ExternalLinkInBody',
src icon: '//upload.wikimedia.org/wikipedia/commons/40/4405/Icon_External_LinkIUCN_EX.svg',
width: 26,
height:} 26);
} button.connect( null, {
action click: function ( e ) {
var text = '{{subst:' + 'User:Polygnotus/Templates/exlink}} ~~' + '~~';
type: 'encapsulate',
context.$textarea.textSelection('encapsulateSelection', {
options: {
pre: '{{subst:' + 'User pre:Polygnotus/Templates/exlink}} ~~' + '~~',text
});
}
} );
return button.$element;
}
},
uwSpam: {
labeltype: 'UW-Spamelement',
filters: [ 'body.ns-3' ],
typeelement: 'button',function ( context ) {
var button = new OO.ui.ButtonInputWidget( {
icon: '//upload.wikimedia.org/wikipedia/commons/c/c8/No-spam.svg',
action label: {'Uw-Spam',
icon: '//upload.wikimedia.org/wikipedia/commons/8c/8cc8/FarmNo-Fresh_lightbulb_addspam.pngsvg',
type: 'encapsulate',
options:} {);
button.connect( null, pre: '{{subst:' + 'uw-spam}} ~~' + '~~',
} click: function ( e ) {
var text = '{{subst:' + 'uw-spam}} ~~' + '~~';
context.$textarea.textSelection('encapsulateSelection', {
pre: text
});
}
} );
return button.$element;
}
},