Удзельнік:Nux/monobook.js

Зьвесткі зь Вікіпэдыі — вольнай энцыкляпэдыі

Заўвага: каб пабачыць зьмены пасьля публікацыі, Вам можа спатрэбіцца ачысьціць кэш Вашага браўзэра.

  • Firefox / Safari: трымайце Shift і націсьніце Reload, ці націсьніце Ctrl-F5 ці Ctrl-R (⌘-R на Mac)
  • Google Chrome: націсьніце Ctrl-Shift-R (⌘-Shift-R на Mac)
  • Internet Explorer / Edge: трымайце Ctrl і націсьніце Refresh, ці націсьніце Ctrl-F5
  • Opera: націсьніце Ctrl-F5.
/*
==== Automatic summaries ====
* Author: [[:pl:User:Adziura|Adam Dziura]]
* Fixes: [[:pl:User:Nux|Maciej Jaros]]
<pre>
*/
// main function
$(function ()
{
	// stop before starting
	if (window.autoSummariesDone)
		return;

	//
	// check if user is editing and if this is a summary field (not a section header field)
	var el = document.getElementById('wpSummary');
	if (el)
	{
		if (el.getAttribute('tabindex')==1) // hack! hopefully will not be changed
			return	// stop
		;
	}
	else
	{
		return;	// stop
	}
	
	//
	// adding element that will hold buttons
	el = el.nextSibling;
	var parent = document.createElement('span');
	parent.id = 'userSummaryButtonsA'
	el.parentNode.insertBefore(document.createElement('br'), el)
	el.parentNode.insertBefore(parent, el)
	
	//
	// adding summary buttons
	var cl = '';	// class is not needed (as on may style with the element above)
	// drobne różne
	addSummaryBtn(parent, 'артаг.', 'addSumm("артаграфія")', cl,
		'артаграфія (ort.)');
	addSummaryBtn(parent, 'стыл.', 'addSumm("стылевые правки")', cl,
		'стылевые правки (style)');
	addSummaryBtn(parent, 'спасылкi', 'addSumm("выпраўленьне спасылак")', cl,
		'спасылкi (linkfix)');
	addSummaryBtn(parent, 'дапаўн.', 'addSumm("дапаўненьне")', cl,
		'дапаўненьне (expand)');
	addSummaryBtn(parent, 'абнаўл.', 'addSumm("абнаўленьне зьвестак")', cl,
		'абнаўленьне зьвестак (update)');
        addSummaryBtn(parent, 'інтэрвікі', 'addSumm("інтэрвікі")', cl,
		'інтэрвікі (interwiki)');
        addSummaryBtn(parent, 'катэг.', 'addSumm("катэгорыя")', cl,
		'катэгорыя (category)');
        addSummaryBtn(parent, 'шаблён', 'addSumm("шаблён")', cl,
		'шаблён (template)');
});

/*
Params:
* el - parent element to hold buttons
* t - text to appear in the button
* a - action (as string) to be run after clicking a button; may be more then one function
* c - optional class name to be attached to the button
* d - a tooltip to be show when one highlights the button
*/
function addSummaryBtn(el, t, a, c, d) {
	var btn = document.createElement('a');

	btn.appendChild(document.createTextNode(t));
	btn.title = d;
	if (c!='')
		btn.className = c
	;
	btn.onclick = new Function(a);

	el.appendChild(btn);
}

function addSumm(txt) {
	var wpS = document.editform.wpSummary;
	if (wpS.value != '' && wpS.value.charAt(wpS.value.length-2) != '/')
		wpS.value += ', ' + txt
	else
		wpS.value += txt
	;
}


// </pre>