Utilisateur:Linedwell/toolbarWikiEditor.js

Une page de Wikipédia, l'encyclopédie libre.
Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.

Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;

Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5.
//<nowiki>
var customizeToolbar = function () {
	var commonPath = '//upload.wikimedia.org/wikipedia/commons/';
	
	//Création du "groupe" dans lequel les nouveaux boutons iront
	$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
		'section': 'main',
		'groups': {
			'custom': {
				'label': ''
			}
		}
	} );
	
	//Fonctions globales supplémentaires
	$('#wpTextbox1').wikiEditor('addToToolbar', {
		section: 'main',
		group: 'format',
		tools: {
			"strikethrough": {
				label: 'Barré',
				type: 'button',
				icon: commonPath + '6/6d/Vector_strikeout.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: "<s>",
						post: "</s>"
					}
				}
			}
		}
	});
	
	//Fonctions uniquement actives sur l'espace de nom Discussion utilisateur (ns-3)
	if(mw.config.get('wgNamespaceNumber') === 3){
		$('#wpTextbox1').wikiEditor('addToToolbar', {
			section: 'main',
			group: 'custom',
			tools: {
				"test0": {
					label: 'Test 0',
					type: 'button',
					icon: commonPath + 'thumb/9/99/Nuvola_apps_important_green.svg/25px-Nuvola_apps_important_green.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '== Vos modifications sur [[',
							post: ']] ont été annulées ==\n{{subst:Test 0}} ~~~~'
						}
					}
				},
				
				"test1": {
					label: 'Test 1',
					type: 'button',
					icon: commonPath + 'thumb/d/dc/Nuvola_apps_important_yellow.svg/25px-Nuvola_apps_important_yellow.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '== Vos modifications sur [[',
							post: ']] ont été annulées ==\n{{subst:Test 1}} ~~~~'
						}
					}
				},
				
				"test2": {
					label: 'Test 2',
					type: 'button',
					icon: commonPath + 'thumb/9/99/Nuvola_apps_important_orange.svg/25px-Nuvola_apps_important_orange.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '== Vos modifications sur [[',
							post: ']] ont été annulées ==\n{{subst:Test 2}} ~~~~'
						}
					}
				},
				
				"test3": {
					label: 'Test 3',
					type: 'button',
					icon: commonPath + 'thumb/f/f7/Nuvola_apps_important.svg/25px-Nuvola_apps_important.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '== Vos modifications sur [[',
							post: ']] ont été annulées ==\n{{subst:Test 3}} ~~~~'
						}
					}
				},
				
				"spam": {
					label: 'Spam',
					type: 'button',
					icon: commonPath + 'thumb/2/2d/Nuvola_web_broom.svg/25px-Nuvola_web_broom.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '== Vos modifications sur [[',
							post: ']] ont été annulées ==\n{{subst:Bienvenue spammeur}} ~~~~'
						}
					}
				},
				
				"copyviolight": {
					label: 'Copyvio light',
					type: 'button',
					icon: commonPath + '7/71/Toolbar_copyvio.png',
					action: {
						type: 'encapsulate',
						options: {
							peri: '{{subst:Copieurlight||}} – ~~~~',
						}
					}
				},
				
				"copyvio": {
					label: 'Copyvio',
					type: 'button',
					icon: commonPath + '9/94/Toolbar_copyright.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '== Violation de copyright ==\n',
							post: '{{subst:Copieur||}} ~~~~',
						}
					}
				},
				
				"delete": {
					label: 'Suppression',
					type: 'button',
					icon: commonPath + 'thumb/2/2c/Broom_icon.svg/25px-Broom_icon.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							peri: '{{subst:Création supprimée||critères=[[WP:CAA|critères d\'admissibilité des articles]]}} ~~~~',
						}
					}
				},
				
				"blocked": {
					label: 'Bloqué',
					type: 'button',
					icon: commonPath + 'thumb/5/57/Stop_hand_nuvola_yellow.svg/25px-Stop_hand_nuvola_yellow.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							peri: '== Notification de blocage ==\n{{Bloqué}} ~~~~',
						}
					}
				},
				
				"banned": {
					label: 'Banni',
					type: 'button',
					icon: commonPath + 'thumb/f/f1/Stop_hand_nuvola.svg/25px-Stop_hand_nuvola.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							peri: '== Notification de blocage ==\n{{Vandale banni}} ~~~~',
						}
					}
				}
			}
		});
	}
	
	// Si on est dans l'espace de nom Utilisateur:
	if(mw.config.get('wgNamespaceNumber') === 2 && mw.config.get('wgPageName').split("/",1) == "Utilisateur:Linedwell"){
		$('#wpTextbox1').wikiEditor('addToToolbar', {
			section: 'main',
			group: 'custom',
			tools: {
				"status-done": {
					label: 'Fini',
					type: 'button',
					icon: commonPath + 'thumb/f/fb/Yes_check.svg/25px-Yes_check.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							peri: '{{Utilisateur:Linedwell/statut|fini}}',
						}
					}
				},
				
				"status-processing": {
					label: 'En cours',
					type: 'button',
					icon: commonPath + 'thumb/f/f6/VLC.svg/25px-VLC.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							peri: '{{Utilisateur:Linedwell/statut|en cours}}',
						}
					}
				},
				
				"status-wait": {
					label: 'En attente',
					type: 'button',
					icon: commonPath + 'thumb/3/31/Symbol_wait_vote.svg/25px-Symbol_wait_vote.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							peri: '{{Utilisateur:Linedwell/statut|standby}}',
						}
					}
				},
				
				"status-stopped": {
					label: 'Stoppé',
					type: 'button',
					icon: commonPath + 'thumb/8/8b/Stop_hand.svg/25px-Stop_hand.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							peri: '{{Utilisateur:Linedwell/statut|stoppé}}',
						}
					}
				}
			}
		});
		
	}
};

/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
	mw.loader.using( 'user.options' ).then( function () {
		// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
		if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
			$.when(
				mw.loader.using( 'ext.wikiEditor' ), $.ready
			).then( customizeToolbar );
		}
	} );
}
//</nowiki>