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

Content deleted Content added
No edit summary
use OOUI
 
(30 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 22 ⟶ 24:
}
},
refIdeas: {
type: 'encapsulateelement',
filters: [ 'body.ns-1' ],
element: function ( context ) {
var button = new OO.ui.ButtonInputWidget( {
type label: 'encapsulate',
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: {
labeltype: 'ExternalLinkInBodyelement',
filters: [ 'body.ns-3' ],
typeelement: 'button',function ( context ) {
var button = new OO.ui.ButtonInputWidget( {
icon: '//upload.wikimedia.org/wikipedia/commons/6/6c/Outline-body-aura.svg',
action label: {'ExternalLinkInBody',
icon: '//upload.wikimedia.org/wikipedia/commons/c0/c805/No-spamIUCN_EX.svg',
type: 'encapsulate',
options:} {);
button.connect( null, {
pre: '{{subst:' + 'User:Polygnotus/Templates/exlink}} ~~' + '~~',
} click: function ( e ) {
pre: var text = '{{subst:' + 'User:Polygnotus/Templates/exlink}} ~~' + '~~',;
context.$textarea.textSelection('encapsulateSelection', {
pre: text
});
}
} );
return button.$element;
}
},
uwSpam: {
labeltype: 'ExternalLinkInBodyelement',
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/6c/6cc8/Outline-bodyNo-auraspam.svg',
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;
}
},
teahouseButton: {
label: 'Teahouse',
Line 58 ⟶ 130:
}
},
vand1Button: {
label: 'Vandalism warning level 1',
Line 70 ⟶ 143:
}
},
vand2Button: {
label: 'Vandalism warning level 2',
Line 82 ⟶ 156:
}
},
vand3Button: {
label: 'Vandalism warning level 3',
Line 94 ⟶ 169:
}
},
vand4Button: {
label: 'Vandalism warning level 4',