MediaWiki:Gadget-extrabewerkingsknoppen.js

Uit Wikipedia, de vrije encyclopedie
Naar navigatie springen Naar zoeken springen

Hulp bij het instellen van uw voorkeuren Let op! Nadat u de veranderingen heeft opgeslagen, moet u de cache van uw browser nog legen om ze daadwerkelijk te zien.

Internet Explorer Ctrl+F5
Mozilla (incl. Firefox) Klik met Shift op de verversknop (of Ctrl+Shift+R)
Chrome Ctrl+Shift+R
Safari Klik met Shift en/of Alt op de verversknop
Opera Ctrl+F5 (in oudere versies: F5)
/**
 * Extra bewerkingsknoppen
 * Afkomstig van http://de.wikipedia.org/w/index.php?title=MediaWiki:Gadget-Extra-Editbuttons.js&oldid=100643998
 */

(function(){

	// Return early if not on edit page
	var action = mw.config.get( 'wgAction' );
	if( action !== 'edit' && action !== 'submit' ) {
		return;
	}

	// By registering our dependency after document.ready, we make sure
	// that the toolbar is fully loaded before we manipulate it
	mw.loader.using( [ 'mediawiki.toolbar', 'user' ], function() { $( function() {

		// Check that the toolbar is present on the page
		if( !$( '#toolbar' ).length ) {
			return;
		}

		// Define available buttons
		var sig = window.usersignature || '--\~\~\~\~';
		var commonsUrl = "//upload.wikimedia.org/wikipedia/commons/";
		var styleUrl = mw.config.get( 'stylepath' ) + '/common/images/';

var buttons={
'A':[commonsUrl +'e/e9/Button_headline2.png','Tussenkopje (tweede niveau)','\n===','===','Kop van de tweede niveau'],
'B':[commonsUrl +'1/13/Button_enter.png','Regel afbreken','<br />','',''],
'C':[commonsUrl +'5/5f/Button_center.png','Centreren','<div style="text-align: center;">\n','\n<\/div>','Tekst die gecentreerd wordt'],
'D':[commonsUrl +'e/ea/Button_align_left.png','Links uitlijnen','<div style="text-align: left; direction: ltr; margin-left: 1em;">\n','\n<\/div>','Tekst die links wordt uitgelijnd'],
'D1':[commonsUrl +'a/a5/Button_align_right.png','Rechts uitlijnen','<div style="text-align: right; direction: ltr; margin-left: 1em;">\n','\n<\/div>','Tekst die rechts wordt uitgelijnd'],
'F':[commonsUrl +'1/1e/Button_font_color.png','Gekleurde tekst invoegen','<span style="color: ','">Gekleurde tekst<\/span>','ColourName'],
'FS':[commonsUrl +'1/1b/Button_miss_signature.png','Niet ondertekend','{{afzender|','}}','Gebruikersnaam of IP'],
'G':[commonsUrl +'9/9e/Btn_toolbar_gallery.png','Afbeeldingengalerij',"\n<gallery\>\nImage:","|[[Omschrijving]]\nImage:Mona Lisa.jpg|[[Omschrijving]]\nImage:Truite arc-en-ciel.jpg|[[Omschrijving]]\n<\/gallery>",'M63.jpg'],
'H':[commonsUrl +'7/74/Button_comment.png','Verborgen commentaar',"<!--","-->",'Verborgen commentaar. Gebruik de overlegpagina voor opmerkingen en discussie.'],
'I1':[commonsUrl +'6/6a/Button_sup_letter.png','Superscript','<sup>','<\/sup>','Tekst'],
'I2':[commonsUrl +'a/aa/Button_sub_letter.png','Subscript','<sub>','<\/sub>','Tekst'],
'J1':[commonsUrl +'5/58/Button_small.png','Kleiner','<small>','<\/small>','Tekst die kleiner wordt weergegeven'],
'J2':[commonsUrl +'5/56/Button_big.png','Groter','<big>','<\/big>','Tekst die groter wordt weergegeven'],
'K':[commonsUrl +'b/b4/Button_category03.png','Categorie',"[\[Categorie:","]]",'Naam'],
'L':[commonsUrl +'8/8e/Button_shifting.png','Inspringen',':','','Tekst dat wordt ingesprongen. Gebruik nogmaals een : om verder in te springen.'],
'M':[commonsUrl +'f/fd/Button_blockquote.png','Voeg een tekstblok of een quote in','<blockquote style="border: 1px solid blue; padding: 2em;">\n','\n<\/blockquote>','Tekstblok of een quote.'],
'N':[commonsUrl +'4/4b/Button_nbsp.png','Niet-afbrekende spatie','&nbsp;','',''],
'O':[commonsUrl +'2/23/Button_code.png','Voeg broncode in','<code>','<\/code>','Broncode'],
'P':[commonsUrl +'3/3c/Button_pre.png','Voorgeformateerde tekst','<pre>','<\/pre>','Voorgeformateerde tekst'],
'Q':[commonsUrl +'d/d3/Button_definition_list.png','Lijst met definities invoegen','\n; ','\n: Item 1\n: Item 2','Definitie'],
'R':[commonsUrl +'7/79/Button_reflink.png','Voeg een referentie, bron of voetnoot toe','<ref>','<\/ref>','[http:\/\/www.voorbeeld.com Bijvoorbeeld een referentie e.d. naar een website] of een referentie naar een boek'],
'R1':[commonsUrl +'9/99/Button_reflink_advanced_2.png','Referentie met naam: naam','<ref name="','','Naam van referentie'],
'R2':[commonsUrl +'9/99/Button_reflink_advanced_2.png','Referentie met naam: de referentie zelf','">','<\/ref>','[http:\/\/www.voorbeeld.com Bijvoorbeeld een referentie e.d. naar een website] of een referentie naar een boek'],
'R3':[commonsUrl +'1/1a/Button_reflink_advanced_3.png','Referentie met naam: eindmarkering herhaling','','"/>',''],
'R4':[commonsUrl +'9/9a/Button_references.png','Overzicht referenties e.d.: met nieuw bronnensjabloon',"{{Appendix|bron|2=\n{{References}}\n}}\n",'',''],
'R5':[commonsUrl +'9/9a/Button_references.png','Overzicht referenties e.d.: in al bestaand bronnensjabloon',"\n----\n{{References}}\n",'',''],
'R6':[commonsUrl +'9/9a/Button_references.png','Overzicht referenties e.d.: los met tussenkopje',"==Referenties==\n{{References}}\n",'',''],
'S':[commonsUrl +'c/c9/Button_strike.png','Doorstrepen','<s>','<\/s>','Doorgestreepte tekst'],
//<nowiki>
'T':[commonsUrl +'e/eb/Button_plantilla.png','Sjabloon invoegen','{{','}}','Sjabloonnaam'],
//</nowiki>
'TS':[commonsUrl +'a/a4/TableStart.png','Begin van tabel','{| ','',''],
'TC':[commonsUrl +'7/71/TableCell.png','Kolom','| ','',''],
'TE':[commonsUrl +'0/06/TableEnd.png','Einde van tabel','','|}',''],
'TR':[commonsUrl +'4/4c/TableRow.png','Rij','|- ','',''],
'T1':[commonsUrl +'3/30/Tt_icon.png','Tekst in teletype','<tt>','<\/tt>','Tekst met het teletype-lettertype'],
'U':[commonsUrl +'f/fd/Button_underline.png','Onderstrepen',"<u>","<\/u>",'Tekst die onderstreept wordt'],
'V':[commonsUrl +'c/c8/Button_redirect.png','Redirect',"#REDIRECT [[","]]",'Artikelnaam'],
'W':[commonsUrl +'8/88/Btn_toolbar_enum.png','Genummerde lijst',"\n# ","\n# Element 2\n# Element 3",'Element 1'],
'X':[commonsUrl +'1/11/Btn_toolbar_liste.png','Lijst',"\n* ","\n* Element B\n* Element C",'Element A'],
'Y1':[commonsUrl +'c/ce/Button_no_include.png','Sjabloon: noinclude',"<noinclude>","<\/noinclude>",'Tekst'],
'Y2':[commonsUrl +'7/79/Button_include.png','Sjabloon: includeonly',"<includeonly>","<\/includeonly>",'Tekst'],
'Z':[commonsUrl +'3/35/Button_substitute.png','Sjabloon substitueren',"{{subst:","}}",'Sjabloonnaam'],
'AI':[commonsUrl +'1/1c/Button_advanced_image.png','Geavanceerde afbeelding',"[\[Bestand:","|thumb|right|px|Caption]]",'FileName.jpg'],
'TALK':[commonsUrl +'4/49/Button_talk.png','Sjabloon aan overlegpagina IP/gebruiker toevoegen',"","",""]
};

		// 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,B,S,U,C,D,D1,F,FS,AI,G,H,I1,J1,K,L,M,N,W,X,Q,R,R4,R5,T,V';
		if( order === 'all' ) {
			order = [];
			for( var key in buttons ) {
				if( isNaN( key ) ) {
					order.push( key );
				}
			}
		} else {
			order = order.split( ',' );
		}

		for( var i = 0, l = order.length; i < l; i++ ) {
			var button = buttons[order[i]];
			if( !button ) {
				throw new Error( 'Unknown button: ' + order[i] );
			}
			mw.toolbar.addButton.apply( mw.toolbar, button );
		}

		// Remove some default buttons if requested
		if( window.rmEditButtons && mw.toolbar.$toolbar ) {
			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 = mw.toolbar.$toolbar.children();
			for( var i = 0, l = remove.length; i < l; i++ ) {
				$toolbarButtons.eq( remove[i] ).remove();
			}
		}

		// Customize signature button
		if( sig !== '--\~\~\~\~' ) {
			$( '#mw-editbutton-signature' ).off( 'click' ).click( function() {
				mw.toolbar.insertTags( sig, '', '' );
				return false;
			} ).attr( 'src', commonsUrl + 'd/d1/Button_mysignature.png' );
		}

		// Add special click handlers
		$( '#mw-editbutton-redirect' ).off( 'click' ).click( function() {
			var target = window.prompt( 'Wohin soll der Redirect?', '' );
			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 ).off( '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( var 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: #FFDDDD;" | ITEM ' + items + '\n';
				} else {
					code += '|-\n';
				}
				for( var 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: #DDFFDD;\"\\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> &nbsp;&nbsp;&nbsp; |'
					+' &nbsp;&nbsp;&nbsp;<a href="javascript:self.close()">Cancel<\/a><\/p>'
					+'<\/body><\/html>'
			);
			popup.document.close();
			return false;
		}
	} ) } );
})();