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

Content deleted Content added
No edit summary
No edit summary
Line 25:
},
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).triggerfocus('input');
$(textarea).trigger('input');
$('#wpSummary').val('Added {{refideas}} template');
}
} );
return button.$element;
}
},
refIdeas wpPolicy: {
type: 'element',
element: function ( context ) {
filters: [ 'body.ns-1' ],
var button = new OO.ui.ButtonInputWidget( {
element: function ( context ) {
label: 'WP Policy',
var button = new OO.ui.ButtonInputWidget( {
label icon: 'articles',
icon: 'lightbulb', } );
button.connect( null, {
title: 'refideas'
click: function ( e ) {
} );
var policy = prompt('Enter Wikipedia policy/guideline abbreviation (e.g., NPOV, V, RS):');
button.connect( null, {
if (policy !== null && policy.trim() !== '') {
click: function ( e ) {
var text = '== [[WP:' + policy.trim() + ']] ==\nPlease read [[WP:' + policy.trim() + ']], thanks and have a nice day, ~~~~';
var text = '{{refideas\n|1=\n}}';
context.$textarea.textSelection('encapsulateSelection', {
var textarea = context.$textarea[0]; pre: text
var start = textarea.selectionStart });
var end = textarea.selectionEnd; }
var currentText = textarea.value; }
} );
return button.$element;
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;
}
},
 
section: 'secondary',
group: 'default',
tools: {
wpPolicy: {
type: 'element',
element: function ( context ) {
var button = new OO.ui.ButtonInputWidget( {
label: 'WP Policy',
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: {