MediaWiki:Gadget-edittools.js

Uwaga: aby zobaczyć zmiany po opublikowaniu, może zajść potrzeba wyczyszczenia pamięci podręcznej przeglądarki.

  • Firefox / Safari: Przytrzymaj Shift podczas klikania Odśwież bieżącą stronę, lub naciśnij klawisze Ctrl+F5, lub Ctrl+R (⌘-R na komputerze Mac)
  • Google Chrome: Naciśnij Ctrl-Shift-R (⌘-Shift-R na komputerze Mac)
  • Internet Explorer / Edge: Przytrzymaj Ctrl, jednocześnie klikając Odśwież, lub naciśnij klawisze Ctrl+F5
  • Opera: Naciśnij klawisze Ctrl+F5.
mw.messages.set({
	'edittoolsgadget-button-title': 'Wstaw symbol/znak/wikikod (wersja $1)',
	'edittoolsgadget-button-alt': 'Edittools'
});

// <nowiki>
window.editToolsGadget = {
	version: 4,
	panel: null,

	init: function() {
		if (mw.config.get('wgAction') != 'edit' && mw.config.get('wgAction') != 'submit')
			return;

		var that = this;
		toolbarGadget.addButton({
			newIcon	: "//commons.wikimedia.org/w/thumb.php?f=Nuvola_apps_kugar.svg&w=21",
			oldIcon	: "//upload.wikimedia.org/wikipedia/commons/0/01/Button_no_source.png",
			title	: mw.msg( 'edittoolsgadget-button-title', this.version ),
			alt	: mw.msg( 'edittoolsgadget-button-alt' ),
			id	: 'editToolsGadget',
			onclick	: function() { that.togglePanel() }
		});

		if (parseInt( jQuery.cookie('editToolsVisible') )) {
			$(function() {
				that.togglePanel();
			});
		}
	},
	togglePanel: function() {
		if (this.panel) {
			if (this.panel.style.display == 'none') {
				this.panel.style.display = 'block';
				jQuery.cookie('editToolsVisible', 1, { expires: 30 });
			}
			else {
				this.panel.style.display = 'none';
				jQuery.cookie('editToolsVisible', 0, { expires: 30 });
			}
			return;
		}
		jQuery.cookie('editToolsVisible', 1, { expires: 30 });

		var that = this;

		this.panel = document.createElement('div');
		this.panel.style.cssText = 'width: 100%; height: 150px; line-height: 1.5em;';

		var index = document.createElement('div');
		index.style.cssText = 'width: 20%; height: 150px; float: left; overflow: auto';

		var content = document.createElement('div');
		content.style.cssText = 'width: 80%; height: 150px; float: right; font-family: monospace,"Courier New"; font-size: 1.25em; overflow: auto';

		for (var i = 0; i < this.groups.length; i++) {
			var group = this.groups[i];

			group.content = document.createElement('div');
			group.content.style.cssText = 'display:none; padding: 5px;';
			for (var j = 0; j < group.items.length; j++) {
				var item = group.items[j];
				var itemLink = document.createElement('span');
				itemLink.style.cssText = 'padding: 5px; cursor:pointer';
				var matches = item.match(/^(.*?)\+(.*)$/);
				if (matches) {
					var prefix = new String(matches[1]);
					var sufix = new String(matches[2]);

					itemLink.appendChild(document.createTextNode(prefix+sufix));
					itemLink.onclick = this.newInsertItemCallback(prefix, sufix, '');
				}
				else {
					itemLink.appendChild(document.createTextNode(item));
					itemLink.onclick = this.newInsertItemCallback(item, '', '');
				}
				itemLink.onmousedown = function() { return false; }
				group.content.appendChild(itemLink);
				group.content.appendChild(document.createTextNode(' '));
			}
			content.appendChild(group.content);

			group.link = document.createElement('div');
			group.link.appendChild(document.createTextNode(group.caption));
			group.link.style.cssText = 'padding: 2px; cursor: pointer';
			index.appendChild(group.link);
			group.link.rel = i;
			group.link.onclick = function() { that.selectGroup(this.rel); return false; };
			group.link.onmousedown = function() { return false; }
		}
		this.panel.appendChild(index);
		this.panel.appendChild(content);

		var textarea = document.getElementById('wpTextbox1');
		if ( !textarea ) {
			return;
		}

		textarea.parentNode.insertBefore(this.panel, textarea);
		var selectedEditToolsGroup = parseInt( jQuery.cookie('selectedEditToolsGroup') );
		this.selectGroup(selectedEditToolsGroup);
	},
	selectGroup: function(number) {
		jQuery.cookie('selectedEditToolsGroup', number, { expires: 30 });

		for (var i = 0; i < this.groups.length; i++) {
			var group = this.groups[i];
			if (number == i) {
				group.content.style.display = 'block';
				group.link.style.fontWeight = 'bold';
			}
			else {
				group.content.style.display = 'none';
				group.link.style.fontWeight = 'normal';
			}
		}
	},
	newInsertItemCallback: function(prefix, sufix, infix) {
		return function() { insertTags(prefix, sufix, infix); };
	}
};

editToolsGadget.groups = [
	{
		caption: 'Polskie znaki',
		items: [ 'Ą', 'ą', 'Ć', 'ć', 'Ę', 'ę', 'Ł', 'ł', 'Ń', 'ń', 'Ó', 'ó', 'Ś', 'ś', 'Ź', 'ź', 'Ż', 'ż', 'á', 'é', 'ſ', '—', '„+“', '„+”', '«+»', '»+«' ]
	},
	{
		caption: 'Inne litery',
		items: [ 'Á', 'á', 'À', 'à', 'Â', 'â', 'Ä', 'ä', 'Å', 'å', 'Ā', 'ā', 'Ă', 'ă', 'Ã', 'ã', 'Æ', 'æ', 'Ç', 'ç', 'Č', 'č', 'Ċ', 'ċ', 'Ď', 'ď', 'Ḍ', 'ḍ', 'É', 'é', 'È', 'è', 'Ê', 'ê', 'Ë', 'ë', 'Ē', 'ē', 'Ě', 'ě', 'Ġ', 'ġ', 'Ḥ', 'ḥ', 'Ħ', 'ħ', 'Í', 'í', 'Î', 'î', 'Ī', 'ī', 'Ĭ', 'ĭ', 'Ï', 'ï', 'IJ', 'ij', 'Ľ', 'ľ', 'ḻ', 'ḷ', 'Ñ', 'ñ', 'Ň', 'ň', 'Ṇ', 'ṇ', 'ṅ', 'ṉ', 'Ó', 'ó', 'Ö', 'ö', 'Ő', 'ő', 'Ô', 'ô', 'Ō', 'ō', 'Ǒ', 'ǒ', 'Ò', 'ò', 'Œ', 'œ', 'Ø', 'ø', 'q́', 'Ř', 'ř', 'Ṛ', 'ṛ', 'ṟ', 'Š', 'š', 'Ş', 'ş', 'Ṣ', 'ṣ', 'Ť', 'ť', 'Ţ', 'ţ', 'Ṭ', 'ṭ', 'Ű', 'ű', 'Ú', 'ú', 'Ü', 'ü', 'Ů', 'ů', 'Ū', 'ū', 'Û', 'û', 'Ŭ', 'ŭ', 'Ý', 'ý', 'ẏ', 'Ẓ', 'ẓ', 'Ž', 'ž', 'ß', 'Ð', 'ð', 'Þ', 'þ' ]
	},
	{
		caption: 'Cyrylica',
		items: [ 'А', 'а', 'Б', 'б', 'В', 'в', 'Г', 'г', 'Д', 'д', 'Е', 'е', 'Ё', 'ё', 'Ж', 'ж', 'З', 'з', 'И', 'и', 'Й', 'й', 'К', 'к', 'Л', 'л', 'М', 'м', 'Н', 'н', 'О', 'о', 'П', 'п', 'Р', 'р', 'С', 'с', 'Т', 'т', 'У', 'у', 'Ф', 'ф', 'Х', 'х', 'Ц', 'ц', 'Ч', 'ч', 'Ш', 'ш', 'Щ', 'щ', 'Ъ', 'ъ', 'Ы', 'ы', 'Ь', 'ь', 'Э', 'э', 'Ю', 'ю', 'Я', 'я', 'ѓ', 'є', 'і', 'ї', 'ј', 'љ', 'њ', 'Ґ', 'ґ', 'Ѣ', 'ѣ', 'Ѳ', 'ѳ', 'Ѵ', 'ѵ', 'Ѯ', 'ѯ', 'Ѕ', 'ѕ', 'Ѱ', 'ѱ', 'Ѡ', 'ѡ', 'Ѫ', 'ѫ', 'Ѧ', 'ѧ', 'Ѭ', 'ѭ', 'Ѩ', 'ѩ' ]
	},
	{
		caption: 'Afabet grecki',
		items: [ 'Α', 'α', 'Β', 'β', 'Γ', 'γ', 'Δ', 'δ', 'Ε', 'ε', 'Ζ', 'ζ', 'Η', 'η', 'Θ', 'θ', 'Ι', 'ι', 'Κ', 'κ', 'Λ', 'λ', 'Μ', 'μ', 'Ν', 'ν', 'Ξ', 'ξ', 'Ο', 'ο', 'Π', 'π', 'Ρ', 'ρ', 'Σ', 'ς', 'σ', 'Τ', 'τ', 'Υ', 'υ', 'Φ', 'φ', 'Χ', 'χ', 'Ψ', 'ψ', 'Ω', 'ω', '·', '΄' ]
	},
	{
		caption: 'Symbole',
		items: [ '–', '—', '„+”', '„+“', '‹+›', '«+»', '»+«', ',+‘', '¡', '¿', '$', '¢', '£', '€', '©', '®', '№', '§', '‰', '°', '‘', 'ʹ', '“', 'ʺ', '¹', '²', '³', '½', '¼', '¾', '⅓', '⅔', '±', '•', '†', '[+]', '[[+]]', '{{+}}', '~', '|' ]
	},
	{
		caption: 'Arabski i hebrajski',
		items: [ 'ا', 'آ', 'ب', 'ت', 'ث', 'ج', 'ح', 'خ', 'د', 'ذ', 'ر', 'ز', 'س', 'ش', 'ص', 'ض', 'ط', 'ظ', 'ع', 'غ', 'ف', 'ق', 'ك', 'ل', 'م', 'ن', 'ه', 'و', 'ي', 'ة', 'ى', 'א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט', 'י', 'כ', 'ך', 'ל', 'מ', 'ם', 'נ', 'ן', 'ס', 'ע', 'פ', 'ף', 'צ', 'ץ', 'ק', 'ר', 'ש', 'ת', '־', '״', '׳', '---', 'א', 'א', 'ב', 'ו', 'י', 'ײ', 'כ', 'פ', 'פ', 'ש', 'ת' ]
	},
	{
		caption: 'Gruziński i ormiański',
		items: [ 'ა', 'ბ', 'გ', 'დ', 'ე', 'ვ', 'ზ', 'თ', 'ი', 'კ', 'ლ', 'მ', 'ნ', 'ო', 'პ', 'ჟ', 'რ', 'ს', 'ტ', 'უ', 'ფ', 'ქ', 'ღ', 'ყ', 'შ', 'ჩ', 'ც', 'ძ', 'წ', 'ჭ', 'ხ', 'ჯ', 'ჰ', 'Ա', 'ա', 'Բ', 'բ', 'Գ', 'գ', 'Դ', 'դ', 'Ե', 'ե', 'ԵՒ', 'և', 'Զ', 'զ', 'Է', 'է', 'Ը', 'ը', 'Թ', 'թ', 'Ժ', 'ժ', 'Ի', 'ի', 'Լ', 'լ', 'Խ', 'խ', 'Ծ', 'ծ', 'Կ', 'կ', 'Հ', 'հ', 'Ձ', 'ձ', 'Ղ', 'ղ', 'Ճ', 'ճ', 'Մ', 'մ', 'Յ', 'յ', 'Ն', 'ն', 'Շ', 'շ', 'Ո', 'ո', 'ՈՒ', 'ու', 'Չ', 'չ', 'Պ', 'պ', 'Ջ', 'ջ', 'Ռ', 'ռ', 'Ս', 'ս', 'Վ', 'վ', 'Տ', 'տ', 'Ր', 'ր', 'Ց', 'ց', 'Ւ', 'ւ', 'Փ', 'փ', 'Ք', 'ք', 'Օ', 'օ', 'Ֆ', 'ֆ' ]
	},
	{
		caption: 'Wiki-składnia',
		items: [ '[[Kategoria:+]]', '#REDIRECT[[+]]', '<ref>+</ref>', '<references/>', '<s>+</s>', '<includeonly>+</includeonly>', '<noinclude>+</noinclude>', '{{DEFAULTSORT:+}}' ]
	},
	{
		caption: 'Proofread',
		items: [ '&#32;', '<br>', '{{tab}}', '{{tab|+}}', '{{pp|+|}}', '{{pk|+|}}', '{{JustowanieStart}}', '{{JustowanieKoniec}}', '{{Przypiswiki|+}}', '{{Rozstrzelony|+}}', '{{Kapitaliki|+}}', '{{Skan zawiera grafikę}}', '{{Skan zawiera reklamę}}', '<section begin="X" />+<section end="X" />', '<pages index="?" from="?" fromsection="X" to="?" tosection="X" />', '{{***}}', '{{***2}}', '{{---}}', '{{===}}', '{{...}}', '{{wiersz tabelki proofread|indeks=|tytuł=|autor=|autor2=|strony=|uwagi=|start=|stan=}}' ]
	},
	{
		caption: 'Licencje',
		items: [ '{{Cc-by-3.0-tekst+}}', '{{GFDL-tekst+}}', '{{GFDL-1.3-Cc-by-sa-3.0-tekst+}}', '{{PD-ineligible-tekst+}}', '{{TekstPD+|}}', '{{TłumaczPD+|}}', '{{PD-old-tekst+}}' ]
	}
];

editToolsGadget.init();

// </nowiki>