User:Perhelion/Editbar2.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
// <nowiki>
/* remove buttons */
/* global $ */
(function () {
'use strict';
var $textbox = $('#wpTextbox1'),
	cUrl = 'https://upload.wikimedia.org/wikipedia/commons/';

if (!$.fn.wikiEditor || !$textbox.length) return;

$textbox.wikiEditor('removeFromToolbar', { section: 'characters' })
	.wikiEditor('removeFromToolbar', { section: 'help' })
	/*.wikiEditor('removeFromToolbar', { section: 'main', group: 'insert', tool: 'xlink' } )
	.wikiEditor('removeFromToolbar', { section: 'main', group: 'insert', tool: 'ilink' } )
	.wikiEditor( 'removeFromToolbar', { section: 'main', group: 'insert', tool: 'file' } )*/;
//****************************************************************
//****************************************************************
// quand le document est ready
$(function () {
	var Laius =
			'\n\: See [[Commons\:Reusing content outside Wikimedia]]' +
			'\n\: Wikimedia Commons hosts all the free images for the different language versions of Wikipedia, and some other projects. All images published on Wikimedia Commons are either published with a free license or in the Public Domain... except really few exceptions that are copyrighted by the Wikimedia Foundation ( like logos for Wikipedia, Commons etc )' +
			'\n\: For example, this image \: [[\:File\:\'37 coupe.jpg]] has a description section with basic informations like \: what is depicted, when the photo was taken, who is the author. Under it, a second section "Licensing" provide indications on under which license this photo is published. Here, [http\:\/\/creativecommons.org\/licenses\/by\/3.0/deed.en Creative Commons Attribution 3.0 Unported].' +
			'\n\: If you wish to use it or to modify it with photoshop for your own website, you have to tell who is the author, and provide a link to the license like this \: ' +
			'\n\: <small>by Trekphiler, published with [https\:\/\/creativecommons.org\/licenses\/by\/3.0\/deed.en Creative Commons Paternité 3.0 Unported licence]<\/small>.' +
			'\n\: If you are going to publish it in a book, you have to add, for example at the end of the book \: <small>by Trekphiler, published with <nowiki>Creative Commons Attribution 3.0 Unported license http\:\/\/creativecommons.org\/licenses/by\/3.0\/deed.en<\/nowiki><\/small>' +
			'\n\: No further agreement from author is required, no financial compensation needs to be provided.' +
			'\n\: Just be sure to check the license on the description page of an image, and to be sure to be on Commons \: wikipedias locally host some copyrighted images used for educational purpose, and those materials are not free.';
	
	// Templates
	$textbox.wikiEditor('addToToolbar', {
		section: 'advanced',
		group: 'format',
		tools: {
			strikethrough: {
				label: 'Strike',
				type: 'button',
				icon: cUrl + '3/30/Btn_toolbar_rayer.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '<s>',
						post: '</s>'
					}
				}
			}
		}
	});
	$textbox.wikiEditor('addToToolbar', {
		section: 'main',
	//****************************************************************
	// group list : Tool de type select (liste sélectionable)
	// To add a group to an existing toolbar section:
		groups: {
			list: { type: 'toolbar' },
		},
		group: 'list',
		tools: {
			Templates: {
				label: 'Templates',
				type: 'select',
				list: {
					// {{RetouchedPicture}}
					'Retouched-bouton': {
						label: '{{RetouchedPicture}}',
						action: {
							type: 'encapsulate',
							options: {
								pre: '{{RetouchedPicture|',
								post: '}}',
								ownline: false
							}
						}
					},
					// Float clear
					'Space-bouton': {
						label: 'Clear',
						action: {
							type: 'encapsulate',
							options: {
								pre: '{{-}}',
								ownline: false
							}
						}
					},
					// bloc gris de citation
					'Bloc-bouton': {
						label: '{{Bloc}}',
						action: {
							type: 'encapsulate',
							options: {
								pre: '{{User:Lilyu/Bloc|1=',
								post: '}}',
								ownline: false
							}
						}
					},
					// explication réutilisation
					'ReUse-bouton': {
						label: 'ReUse',
						action: {
							type: 'encapsulate',
							options: {
								pre: Laius
							}
						}
					}
				}
			}
		}
	});
	/********************************/
	// group description : edition de page de description d'image
	// To add a group to an existing toolbar section:
	// Description
	$textbox.wikiEditor('addToToolbar', {
		section: 'main',
		groups: {
			description: { type: 'toolbar' }
		},
		group: 'description',
		tools: {
			'Description-bouton': {
				label: 'Description',
				type: 'button',
				icon: cUrl + 'b/be/Button_Filedesc.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '=={{int:filedesc}}=='
					}
				}
			},
			'Licence-titre-bouton': {
				label: 'Licence',
				type: 'button',
				icon: cUrl + '1/15/Button_License.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '=={{int:license-header}}=='
					}
				}
			},
			'WTF-bouton': {
				label: 'WTFPL',
				type: 'button',
				icon: cUrl + '4/44/Lilyu_Custom_Button_WTF.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{Self|WTFPL}}'
					}
				}
			}
		}
	});
	//****************************************************************
	$textbox.wikiEditor('addToToolbar', {
		section: 'main',
		groups: {
			extra: { type: 'toolbar' }
		},
		group: 'extra',
		tools: {
			// en
			'en2-bouton': {
				label: 'en|',
				type: 'button',
				icon: cUrl + 'thumb/2/22/Lilyu_Custom_Button_en.svg/23px-Lilyu_Custom_Button_en.svg.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{en|',
						post: '}}'
					}
				}
			},
			// de
			'de2-bouton': { 
				label: 'de|',
				type: 'button',
				icon: cUrl + 'thumb/6/61/Lilyu_Custom_Button_de.svg/23px-Lilyu_Custom_Button_de.svg.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{de|',
						post: '}}'
					}
				}
			}
		}
	});

}); // document ready
}());
// </nowiki>