MediaWiki:Gadget-Extra-Editbuttons.js
Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Internet Explorer/Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
- Opera: Strg+F5
//============================================================
// en: ADD SOME EXTRA BUTTONS TO THE EDITPANEL [[:en:User:MarkS/Extra edit buttons]]
// de: FÜGE NEUE BUTTON IN DIE WERKZEUGLEISTE [[:de:Benutzer:Olliminatore/Extra-Editbuttons]]
// Converted by [[User:Olliminatore]] 25.09.2006
// Angepasst an RL und mw.toolbar von [[User:✓]] April 2011
//============================================================
// de: Die Reihenfolge und Anzahl der Buttons ist über die (alphabetische) Variable customEditButtons wählbar.
// <nowiki>
/*global $, mw*/
/*jshint multistr:true, strict:true, forin:true*/
(function () {
"use strict";
// Return early if not on edit page
if (!mw.toolbar) // exists only in edit-mode
return;
// Das Abwarten des Moduls 'user' gewährleistet, dass in global/common/skin konfigurierte Anpassungen wirken
mw.loader.using(['mediawiki.toolbar', 'user'], function () { $(function () {
var $toolbar = $('#toolbar');
// Check that the toolbar is present on the page
if (!$toolbar.length)
return;
// Define available buttons
var sig = window.usersignature || '--\~\~\~\~',
cURL = "//upload.wikimedia.org/wikipedia/commons/",
i,
l,
buttons = {
'A' : [
cURL + 'e/e9/Button_headline2.png',
'Sekundäre Überschrift',
'\n=== ',
' ===',
'Sekundäre Überschrift'
],
'A3' : [
cURL + '/3/3a/Button_headline3.png',
'Untergeordnete Überschrift',
'\n==== ',
' ====',
'Untergeordnete Überschrift'
],
'B' : [
cURL + '1/13/Button_enter.png',
'Zeilenumbruch',
'<br />',
'',
''
],
'B1' : [
cURL + '6/62/Button_desambig.png',
'Begriffsklärungseite',
'{{Begriffsklärung}}',
'',
''
],
'B2' : [
cURL + '5/5e/Button_disambig_small.png',
'Dieser Artikel erläutert…',
'{{Dieser Artikel|',
'}}',
'erläutert den Buchstaben X, zu anderen Bedeutungen siehe [[X (Begriffsklärung)]].'
],
'B3' : [
cURL + '5/5e/Button_disambig_small.png',
'Begriffsklärungshinweis',
'{{Begriffsklärungshinweis}}',
'',
''
],
'C' : [
cURL + '5/5f/Button_center.png',
'Zentriert',
'<div style="text-align: center;">\n',
'\n<\/div>',
'Zentriert'
],
'CF' : [
cURL + '3/37/Btn_toolbar_commentaire.png',
'Chemische Formel',
':<math>\u005Cmathrm{',
'}</math>',
''
],
'CO' : [
cURL + '6/6c/Button_commons.png',
'Commons',
'{{Commons|Category:',
'}}',
'Seitenname'
],
'D' : [
cURL + 'e/ea/Button_align_left.png',
'Left-Align',
'<div style="text-align: left; direction: ltr; margin-left: 1em;">\n',
'\n<\/div>',
'Left-aligned Text'
],
'DS' : [
cURL + '4/4e/Button_romain.png',
'SORTIERUNG',
'{{SORTIERUNG:',
'}}',
'Sortierbegriff'
],
'DO' : [
cURL + 'e/e9/Button_done.png',
'Erledigt (kurz)',
'{{Erl.}}',
'',
''
],
'ER' : [
cURL + '9/9d/Button_fait.png',
'Erledigt (lang)',
'{{Erledigt|1=' + sig,
'}}',
''
],
'E' : [
cURL + '0/04/Button_array.png',
'Tabelle',
'',
'',
'',
'mw-editbutton-tablegenerator'
],
'F' : [
cURL + '8/8f/Button_poeme.png',
'Farbiger Text',
'<span style="color: color">',
'<\/span>',
'Farbig'
],
'FS' : [
cURL + '1/1b/Button_miss_signature.png',
'Fehlende Signatur',
'\{\{subst\:Unsigned|',
'}}',
'BENUTZER'
],
'G' : [
cURL + '9/9e/Btn_toolbar_gallery.png',
'Bildergalerie',
'\n<gallery>\nDatei:M63.jpg|[[M63]]\nDatei:Mona Lisa.jpg|[[Mona Lisa]]\nDatei:Truite arc-en-ciel.jpg|Eine [[Forelle ]]\n<\/gallery>',
'',
''
],
'H' : [
cURL + '7/74/Button_comment.png',
'Versteckter Kommentar',
'<!--',
'-->',
'Versteckt'
],
'I' : [
cURL + '4/41/Button_hr_halfwidth.png',
'Gedankenstrich',
'–',
'',
''
],
'I1' : [
cURL + '6/6a/Button_sup_letter.png',
'Hochgestellter Text (superscript)',
'<sup>',
'<\/sup>',
'Hochgestellt'
],
'I2' : [
cURL + 'a/aa/Button_sub_letter.png',
'Tiefgestellter Text (subscript)',
'<sub>',
'<\/sub>',
'Tiefgestellt'
],
'J1' : [
cURL + '5/58/Button_small.png',
'Kleingeschriebener Text (small)',
'<small>',
'<\/small>',
'Klein'
],
'J2' : [
cURL + '5/56/Button_big.png',
'Größerer Text (big)',
'<big>',
'<\/big>',
'Groß'
],
'K' : [
cURL + 'b/b4/Button_category03.png',
'Kategorie',
'[[Kategorie:',
']]',
'Name der Kategorie'
],
'KR' : [
cURL + 'b/b1/Button_dagger.png',
'Kreuz',
'†',
'',
''
],
'L' : [
cURL + '8/8e/Button_shifting.png',
'Setze Tab(s)',
':',
'',
':'
],
'M' : [
cURL + 'f/fd/Button_blockquote.png',
'Markiert ein Zitat mit Absatz',
'<blockquote style="border: 1px solid blue; padding: 2em;">\n',
'\n<\/blockquote>',
'Text'
],
'N' : [
cURL + '4/4b/Button_nbsp.png',
'Geschütztes Leerzeichen (nonbreaking space)',
' ',
'',
''
],
'NT' : [
cURL + 'b/bf/Button_thinsp.png',
'Schmales geschütztes Leerzeichen',
' ',
'',
''
],
'O' : [
cURL + '2/23/Button_code.png',
'Code einfügen',
'<code>',
'<\/code>',
'Code'
],
'P' : [
cURL + '3/3c/Button_pre.png',
'Vorformatierter Text',
'<pre>',
'<\/pre>',
'Präformatierter Text'
],
'P1' : [
cURL + '9/93/Button_sub_link.png',
'Link zu einem Seiten-Abschnitt',
'[[Seite#',
']]',
'Abschnitt'
],
'PF' : [
cURL + 'f/ff/Button_arrow_right.png',
'Pfeil nach rechts',
'\u2192',
'',
''
],
'PD' : [
cURL + 'e/ee/Button_vote_biblio.png',
'Personendaten',
'{{Personendaten\n|NAME=\n|ALTERNATIVNAMEN=',
'\n|KURZBESCHREIBUNG=\n|GEBURTSDATUM=\n|GEBURTSORT=\n|STERBEDATUM=\n|STERBEORT=\n}}',
''
],
'PO' : [
cURL + 'c/c7/Button_polytonique.png',
'Unicode-Sonderzeichen der altgriechischen Schrift',
'{{Polytonisch|',
'}}',
'Text'
],
'Q' : [
cURL + 'd/d3/Button_definition_list.png',
'Definitionsliste',
'\n; ',
' : ',
'Text'
],
'Q1' : [
cURL + '0/05/Button_Anf%C3%BChrung.png',
'Anführungszeichen',
'„',
'“',
'Text'
],
'Q2' : [
cURL + '2/26/Button_latinas.png',
'Latinas',
'«',
'»',
'Text'
],
'Q3' : [
cURL + 'b/bc/Button_guillemet.png',
'Guillemets',
'»',
'«',
'Text'
],
'R' : [
cURL + '7/79/Button_reflink.png',
'Markiere eine Referenz',
'<ref>',
'<\/ref>',
'Bezugsangabe'
],
'R1' : [
cURL + 'c/c4/Button_ref.png',
'Referenz mit Name',
'<ref name="">',
'<\/ref>',
'Bezugsangabe'
],
'R2' : [
cURL + 'f/fe/Button_refs.png',
'Wiederholungs-Referenz',
'<ref name="',
'"/>',
'Referenzname'
],
'R3' : [
cURL + '9/9a/Button_references.png',
'Referenz-Footer',
'\n== Einzelnachweise ==\n<references />\n',
'',
''
],
'RD' : [
cURL + '7/70/Button_fusion.png',
'Redundanz',
'{{ers:Redundanz|',
'}}',
'Artikel1|Artikel2|Artikel3…'
],
'S' : [
cURL + 'c/c9/Button_strike.png',
'Durchgestrichener Text',
'<s>',
'<\/s>',
'Durchgestrichen'
],
'SA' : [
cURL + 'b/bb/Seealso.png',
'Siehe auch',
'\n== Siehe auch ==\n',
'',
''
],
'SC' : [
cURL + '0/02/Button_S_yellow.png',
'SourceCode hervorheben',
'<source lang="javascript">',
'<\/source>',
'Quelltext'
],
'SM' : [
cURL + '7/74/Button_oeil.png',
'Smiley',
'<tt style="background:#FE3">',
'</tt>',
':D'
],
'ST' : [
cURL + '7/72/Button_span_2.png',
'span-tag mit CSS-Angabe',
'<span style="">',
'<\/span>',
'Markierter Inhalt'
],
'T' : [
cURL + 'e/eb/Button_plantilla.png',
'Vorlage',
'{{',
'}}',
'Vorlagenname'
],
'TL' : [
cURL + 'e/eb/Button_templatelink.png',
'Vorlagenlink',
'{{[[Vorlage:',
'|]]}}',
'Vorlagenname'
],
'TT' : [
cURL + '3/30/Tt_icon.png',
'Schreibmaschinenstil',
'<tt>',
'<\/tt>',
'Teletyper Text'
],
'U' : [
cURL + 'f/fd/Button_underline.png',
'Unterstreichen',
'<u>',
'<\/u>',
'Unterstrichener Text'
],
'UR' : [
cURL + 'e/ec/Button_aviso.png',
'Urheberrecht ungeklärt',
'{{Urheberrecht ungeklärt}}',
'',
''
],
'URV' : [
cURL + '9/9d/Button_halt.png',
'Urheberrechtsverletzung',
'{{URV}} [',
'] ' + sig,
'Url'
],
'V' : [
cURL + 'c/c8/Button_redirect.png',
'Weiterleitung (Redirect)',
'#WEITERLEITUNG [[',
']]',
'Ziel einfügen',
'mw-editbutton-redirect'
],
'VP' : [
cURL + 'b/ba/Button_conserver.png',
'Vote *pro*',
'# {{pro}} ' + sig,
'',
''
],
'VC' : [
cURL + 'f/fc/Button_supp.png',
'Vote *contra*',
'# {{contra}} ' + sig,
'',
''
],
'VN' : [
cURL + '4/4e/Button_neutre.png',
'Vote *neutral*',
'# {{neutral}} ' + sig,
'',
''
],
'WB' : [
cURL + '6/61/Button_wikibooks.png',
'Wikibooks',
'{{Wikibooks',
'}}',
'|Seitenname'
],
'WS' : [
cURL + 'e/eb/Button_wikisource.png',
'Wikisource',
'{{Wikisource',
'}}',
'|Seitenname'
],
'WT' : [
cURL + 'b/bf/WP-icon.png',
'Wiktionary',
'{{Wiktionary',
'}}',
'|Seitenname'
],
'WV' : [
cURL + 'b/b5/Button_wikiversity.png',
'Wikiversity',
'{{Wikiversity',
'}}',
'|Seitenname'
],
'W' : [
cURL + '8/88/Btn_toolbar_enum.png',
'Nummerierung',
'\n# Element 1\n# Element 2\n# Element 3',
'',
''
],
'X' : [
cURL + '1/11/Btn_toolbar_liste.png',
'Liste',
'\n* Element A\n* Element B\n* Element C',
'',
''
],
'Y1' : [
cURL + 'c/ce/Button_no_include.png',
'No Include',
'<noinclude>',
'<\/noinclude>',
'Text'
],
'Y2' : [
cURL + '7/79/Button_include.png',
'Include only',
'<includeonly>',
'<\/includeonly>',
'Text'
],
'Z' : [
cURL + '3/35/Button_substitute.png',
'Ersetzen',
'{{ers:',
'}}',
'Vorlage'
],
'ZI' : [
cURL + '8/83/Button_biocitas.png',
'Zitat',
'{{Zitat|',
'}}',
'Text|Autor (optional)|Quelle (optional)'
],
'T1' : [
cURL + 'c/c6/Blending_blue_button_background.png',
'Spacer (no function)',
'',
'',
''
],
'0' : [
cURL + 'e/e2/Button_bold.png',
'Fetter Text',
'\'\'\'',
'\'\'\'',
'Fetter Text',
'mw-editbutton-bold'
],
'1' : [
cURL + '1/1d/Button_italic.png',
'Kursiver Text',
'\'\'',
'\'\'',
'Kursiver Text',
'mw-editbutton-italic'
],
'2' : [
cURL + 'c/c0/Button_link.png',
'Interner Link',
'[[',
']]',
'Link-Text',
'mw-editbutton-link'
],
'3' : [
cURL + 'e/ec/Button_extlink.png',
'Externer Link (http:// beachten)',
'[',
']',
'http://www.example.com Link-Text',
'mw-editbutton-extlink'
],
'4' : [
cURL + 'f/fb/Button_headline.png',
'überschrift',
'\n== ',
' ==\n',
'überschrift',
'mw-editbutton-headline'
],
'5' : [
cURL + 'd/de/Button_image.png',
'Dateilink',
'[[Datei:',
']]',
'Beispiel.jpg',
'mw-editbutton-image'
],
'6' : [
cURL + '1/19/Button_media.png',
'Mediendatei-Link',
'[[Media:',
']]',
'Beispiel.ogg',
'mw-editbutton-media'
],
'7' : [
cURL + '2/2e/Button_math.png',
'Mathematische Formel (LaTeX)',
'\x3cmath\x3e',
'\x3c/math\x3e',
'Formel hier einfügen',
'mw-editbutton-math'
],
'8' : [
cURL + '8/82/Nowiki_icon.png',
'Unformatierter Text',
'\x3cnowiki\x3e',
'\x3c/nowiki\x3e',
'Unformatierten Text hier einfügen',
'mw-editbutton-nowiki'
],
'9' : [
cURL + '6/6d/Button_sig.png',
'Deine Signatur mit Zeitstempel',
'--\~\~\~\~',
'',
'',
'mw-editbutton-signature'
],
'10' : [
cURL + '0/0d/Button_hr.png',
'Horizontale Linie (sparsam verwenden)',
'\n----\n',
'',
'',
'mw-editbutton-hr'
]
};
// Add user defined buttons to the available buttons
if (window.myButtons)
$.extend(buttons, window.myButtons);
// Add buttons to the toolbar in the specified order
var order = window.customEditButtons || 'A,A3,B,E,F,G,H,I1,I2,J1,K,M,Q,R,R1,R2,R3,S,T,U,V,W,X';
if (order === 'all') {
order = [];
for (var key in buttons) {
if (isNaN(key)) {
order.push(key);
}
}
} else {
order = order.split(',');
}
for (i = 0, l = order.length; i < l; i++) {
var button = buttons[order[i]];
if (!button)
throw new Error('Unknown button: ' + order[i]);
// Unfortunately the group insert .addButtons is at performance reasons senseless for us
mw.toolbar.addButton.apply(mw.toolbar, button);
}
// Remove some default buttons if requested
if (window.rmEditButtons) {
var remove = window.rmEditButtons;
if ((remove[0] + '').toLowerCase() === 'all')
remove = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
remove.sort().reverse();
var $toolbarButtons = $toolbar.children();
for (i = 0, l = remove.length; i < l; i++)
$toolbarButtons.eq(remove[i]).remove();
}
// Customize signature button
if (sig !== '--\~\~\~\~') {
$('#mw-editbutton-signature').unbind('click').click(function () {
mw.toolbar.insertTags(sig, '', '');
return false;
}).attr('src', cURL + 'd/d1/Button_mysignature.png');
}
// Add special click handlers
$('#mw-editbutton-redirect').unbind('click').click(function () {
var target = window.prompt('Wohin soll die Weiterleitung?', '');
if (target) {
var text = '#WEITERLEITUNG [[' + target + ']]';
$('#wpTextbox1').val(text);
$('#wpSummary').val(text);
$('#wpWatchthis').prop('checked', false);
}
});
$('#mw-editbutton-tablegenerator').click(popupTable);
// Adjust width of spacer images
if (mw.toolbar.$toolbar) {
mw.toolbar.$toolbar.children('img[src="' + buttons.T1[0] + '"]').width(6).unbind('click');
}
//============================================================
// Table generator
//============================================================
/** en: Generate an array using Mediawiki syntax
* @author: originally from fr:user:dake
* @version: 0.2 */
mw.toolbar.generateTable = function (caption, exhead, nbCol, nbRow, exfield, align) {
var code = '\n';
code += '{| class="wikitable" ' + align + '\n' + caption + exhead;
if (exfield) {
code += '!\n';
}
for (i = 1; i < nbCol + 1; i++) {
code += '! FELD ' + i + '\n';
}
var items = 0;
for (var j = 0; j < nbRow; j++) {
if (exfield) {
items++;
code += '|-\n! style="background:#FDD;" | ITEM ' + items + '\n';
} else {
code += '|-\n';
}
for (i = 0; i < nbCol; i++) {
code += '| Element\n';
}
}
code += '|}\n';
mw.toolbar.insertTags('', '', code);
};
/** en: Open a popup with parameters to generate an array.
* The number of rows/columns can be modified.
* @author: originally fr:user:dake
* @version: 0.2 */
function popupTable() {
var popup = window.open('about:blank', 'WPtable', 'height=400,width=400,scrollbars=yes');
var javaCode = '<script type="text\/javascript">function insertCode(){' +
'var caption = (document.paramForm.inputCaption.checked)?"\|\+ TABLE CAPTION \\n":""; ' +
'var exhead = (document.paramForm.inputHead.checked)?\'\|\- style=\"background: #DFD;\"\\n\':""; ' +
'var row = parseInt(document.paramForm.inputRow.value); ' +
'var col = parseInt(document.paramForm.inputCol.value); ' +
'var exfield = document.paramForm.inputItems.checked; ' +
'var align = (document.paramForm.inputAlign.checked)?\'align="center"\':""; ' +
'window.opener.mw.toolbar.generateTable(caption,exhead,col,row,exfield,align); ' +
'window.close()}<\/script>';
popup.document.write('<html><head><title>Make table<\/title>' +
javaCode +
'<\/head><body>' +
'<p>Enter the table parameters below: <\/p>' +
'<form name="paramForm">' +
'Table caption: <input type="checkbox" name="inputCaption"><p\/>' +
'Table alignment: center<input type="checkbox" name="inputAlign"><p\/>' +
'Table headline: colored<input type="checkbox" name="inputHead"><p\/>' +
'Number of rows: <input type="text" name="inputRow" value="3" size="2"><p\/>' +
'Number of columns: <input type="text" name="inputCol" value="3" size="2"><p\/>' +
'Item column: <input type="checkbox" name="inputItems" ><p\/>' +
'<\/form">' +
'<i>The default table allows for fields and values only.<\/i><p\/>' +
'Check "Item column" to allow for the table to have fields, items, and values.<\/i><p\/>' +
'<p><a href="javascript:insertCode()"> Insert table into window<\/a> |' +
' <a href="javascript:self.close()">Cancel<\/a><\/p>' +
'<\/body><\/html>');
popup.document.close();
return false;
}
}); });
})();
// </nowiki>