MediaWiki:Gadget-summarised-editing.js: Difference between revisions
From WikiMSK
(Created page with "wpSummaryButtons = new Array(); function insertSummary(text) { wpSummary = document.getElementById('wpSummary'); if (wpSummary.value.indexOf(text) != -1) return; if...") |
No edit summary |
||
Line 52: | Line 52: | ||
} | } | ||
addSummaryButton(" | addSummaryButton("Category", "Category", "Edit categories"); | ||
$(function() {createSummaryButtons();}); | $(function() {createSummaryButtons();}); | ||
/* </pre> */ | /* </pre> */ |
Revision as of 00:10, 23 August 2020
wpSummaryButtons = new Array();
function insertSummary(text) {
wpSummary = document.getElementById('wpSummary');
if (wpSummary.value.indexOf(text) != -1) return;
if(wpSummaryButtons.length == 0) return;
if (wpSummary.value.match(/[^,; \/•]$/)) wpSummary.value += ';';
if (wpSummary.value.match(/[^ ]$/)) wpSummary.value += ' ';
wpSummary.value += text;
}
function addSummaryButton(name, text, title) {
buttonSummary = document.createElement('a');
buttonSummary.appendChild(document.createTextNode(name));
buttonSummary.href = "#";
buttonSummary.title = title;
buttonSummary.onclick = function(){insertSummary(text); return false;};
wpSummaryButtons[wpSummaryButtons.length] = buttonSummary;
}
function createSummaryButtons(){
// pokud pole Shrnutí editace neexistuje, nemá smysl pokračovat
if(!document.getElementById('wpSummary')) return;
var wpSummary = document.getElementById('wpSummary');
if (!wpSummary || (wpSummary.form.wpSection && wpSummary.form.wpSection.value == 'new')) return;
wpSummaryBtn = document.createElement('div');
wpSummaryBtn.className = 'mw-editSummary';
wpSummaryBtnP = document.createElement('p');
wpSummaryBtn.appendChild(wpSummaryBtnP);
wpSummaryLegend = document.createElement('b');
wpSummaryLegend.appendChild(document.createTextNode(" Náměty pro shrnutí editace: "));
wpSummaryBtnP.appendChild(wpSummaryLegend);
for(var i in wpSummaryButtons) {
wpSummaryBtnP.appendChild(wpSummaryButtons[i]);
wpSummaryBtnMezera = document.createElement('span');
if(i != (wpSummaryButtons.length - 1)) wpSummaryBtnMezera.appendChild(document.createTextNode(' • '));
wpSummaryBtnP.appendChild(wpSummaryBtnMezera);
}
wpInsert = $(".mw-editTools")[0];
wpInsert.parentNode.insertBefore(wpSummaryBtn, wpInsert.nextSibling);
}
addSummaryButton("Category", "Category", "Edit categories");
$(function() {createSummaryButtons();});
/* </pre> */