Szerkesztő:Laszlovszky András/vector.js
Megjegyzés: közzététel után frissítened kell a böngésződ gyorsítótárát, hogy lásd a változásokat.
- Firefox / Safari: tartsd lenyomva a Shift gombot és kattints a Frissítés gombra a címsorban, vagy használd a Ctrl–F5 vagy Ctrl–R (Macen ⌘–R) billentyűkombinációt
- Google Chrome: használd a Ctrl–Shift–R (Macen ⌘–Shift–R) billentyűkombinációt
- Internet Explorer / Edge: tartsd nyomva a Ctrl-t, és kattints a Frissítés gombra, vagy nyomj Ctrl–F5-öt
- Opera: Nyomj Ctrl–F5-öt
// moves section edit links to the right side of the section title
// (see also the rules for .editsectionmoved in Vector.css)
// adds section edit link for the lead section next to the main (h1) title
// shows the contents of [[MediaWiki:Editintro-section-0]] above the edit box if used
// (unless the lead section is the same as the whole article)
// var oldEditsectionLinks=true disables the function.
if(document.getElementById && document.createElement) {
function moveSectionEditLinks() {
if(typeof oldEditsectionLinks != 'undefined' && oldEditsectionLinks == true) return;
var headings = false; // no need to show info aboutw how to edit the whole page if there are no sections
var sectioneditlinks = false; // if there are section edit links, we can safely show the lead section edit link
/* move section edit links */
var body = document.getElementById("bodyContent");
// we iterate through headers until we find a section header
for(var i=1; i<=6; i++) {
var h = body.getElementsByTagName('h'+i);
for(var j=0; j<h.length; j++) {
var span = h[j].getElementsByTagName('span');
for(var k=0; k<span.length; k++) {
if(span[k].className == "mw-headline") headings = true;
else if(span[k].className == "editsection") {
headings = true;
sectioneditlinks = true;
if(is_opera) { // Opera doesn't seem to like the class being changed on the fly
span[k].style.fontSize = "x-small";
span[k].style.fontWeight = "normal";
span[k].style.cssFloat = span[k].style.styleFloat = "none";
span[k].style.marginLeft = "0.5em";
span[k].style.verticalAlign = "baseline";
span[k].style.lineHeight = "1em";
}
span[k].className = "editsectionmoved";
span[k].parentNode.appendChild(document.createTextNode(" "));
span[k].parentNode.appendChild(span[k]); // move behind the heading title
}
}
}
}
/* add lead section edit link */
var edit = document.getElementById("ca-edit");
if(headings && !sectioneditlinks) return; // if sections are not editable, don't add
else if(!headings) {
// try to guess whether sections would be editable; don't add if
// 1) article is protected or otherwise uneditable
// 2) user is viewing page history, edit/move/delete interface, etc.
// 3) user is viewing a special page
// 4) user is viewing a diff, unless it's a diff to the current revision
// 5) user is viewing a permalink to a revision, unless it's the current revision
if(!edit || mw.config.get('wgAction') != "view" || document.location.href.match("/wiki/Speci%C3%A1lis:"))
return;
var diffMatch = document.location.href.match(/diff=([^&]*)/);
var diff = diffMatch ? diffMatch[1] : null;
var oldidMatch = document.location.href.match(/oldid=([^&]*)/);
var oldid = oldidMatch ? oldidMatch[1] : null;
if(oldid && diff) {
if(diff != mw.config.get('wgCurRevisionId') && !(diff == "prev" && oldid == mw.config.get('wgCurRevisionId'))) return;
} else if(oldid) {
if(oldid != mw.config.get('wgCurRevisionId')) return;
}
// covers most cases, "diff=next&oldid=<last before current>" is impossible to catch
}
var href = edit.firstChild.href + "§ion=0";
if(headings) href += "&editintro=MediaWiki:Editintro-section-0";
var title = document.getElementsByTagName('h1')[0];
if(!title || title.className != "firstHeading") return; // make sure this is the main title
var edit0 = document.createElement('span');
edit0.className = "editsectionmoved";
if(is_opera) {
edit0.style.fontSize = "x-small";
edit0.style.fontWeight = "normal";
edit0.style.marginLeft = "0.5em";
edit0.style.verticalAlign = "baseline";
edit0.style.lineHeight = "1em";
}
edit0.innerHTML = '[<a title="Bevezető szerkesztése" href="' + href + '">szerkesztés</a>]';
title.appendChild(document.createTextNode(" "));
title.appendChild(edit0);
}
addOnloadHook(moveSectionEditLinks);
}