MediaWiki:Gadget-Einleitung-bearbeiten.js

Aus Kitakien

(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
(AZ: Die Seite wurde neu angelegt.)
Zeile 2: Zeile 2:
// Erweitert von: Maciej Jaros [[:pl:User:Nux]]
// Erweitert von: Maciej Jaros [[:pl:User:Nux]]
// siehe http://pl.wikipedia.org/wiki/MediaWiki:Monobook.js
// siehe http://pl.wikipedia.org/wiki/MediaWiki:Monobook.js
 +
// Korrigiert von: [[Benutzer:TMg]]
-
var addEditTopLinkNumHeaders = 2;
+
addOnloadHook(function() {
-
function addEditTopLink() {
+
// if this is preview page or there is no edit tab, stop
-
//
+
// somehow it gets run twice on some pages - stop that
// somehow it gets run twice on some pages - stop that
-
if (window.addEditTopLinkDone)
+
if (! wgIsArticle || window.addEditTopLinkDone)
-
return
+
return;
-
;
+
window.addEditTopLinkDone = true;
window.addEditTopLinkDone = true;
-
//
 
-
// if this is preview page or there is no edit tab, stop
 
-
if (!wgIsArticle)
 
-
return
 
-
;
 
-
 
-
//
 
// if there are no edit-section links then stop
// if there are no edit-section links then stop
var spans = document.getElementById("bodyContent").getElementsByTagName("span");
var spans = document.getElementById("bodyContent").getElementsByTagName("span");
Zeile 24: Zeile 16:
for (i = 0; i < spans.length; i++) {
for (i = 0; i < spans.length; i++) {
if (spans[i].className == 'editsection')
if (spans[i].className == 'editsection')
-
break
+
break;
-
;
+
}
}
-
if (i>=spans.length)
+
if (i >= spans.length)
-
return
+
return;
-
;
+
-
//
 
// additional checkup to stop
// additional checkup to stop
var test = document.getElementById("bodyContent").getElementsByTagName("h2").length +
var test = document.getElementById("bodyContent").getElementsByTagName("h2").length +
Zeile 37: Zeile 26:
document.getElementById("bodyContent").getElementsByTagName("h4").length;
document.getElementById("bodyContent").getElementsByTagName("h4").length;
// note that there is always siteSub (h3)
// note that there is always siteSub (h3)
-
if (test<=addEditTopLinkNumHeaders)
+
var addEditTopLinkNumHeaders = window.addEditTopLinkNumHeaders || 2;
-
return
+
if (test <= addEditTopLinkNumHeaders)
-
;
+
return;
-
+
 
-
//
+
// get first header element
// get first header element
var fst_h1 = document.getElementById("content").getElementsByTagName("h1")[0];
var fst_h1 = document.getElementById("content").getElementsByTagName("h1")[0];
-
//
 
// Creating elements
// Creating elements
-
//
+
// create span
-
// create div
+
var span = document.createElement("SPAN");
-
var div = document.createElement("DIV");
+
span.className = 'editsection';
-
div.className = 'editsection';
+
// create link
// create link
var link = document.createElement("A");
var link = document.createElement("A");
link.href = document.getElementById("ca-edit").getElementsByTagName("a")[0].href + '&section=0';
link.href = document.getElementById("ca-edit").getElementsByTagName("a")[0].href + '&section=0';
-
link.setAttribute('title', 'Einleitung des Artikels bearbeiten');
+
link.title = "Abschnitt bearbeiten: Einleitung";
link.appendChild(document.createTextNode('Bearbeiten'));
link.appendChild(document.createTextNode('Bearbeiten'));
-
// append link and stuff to div
+
// append link and stuff to span
-
div.appendChild(document.createTextNode('['));
+
span.appendChild(document.createTextNode('['));
-
div.appendChild(link);
+
span.appendChild(link);
-
div.appendChild(document.createTextNode(']'));
+
span.appendChild(document.createTextNode(']'));
-
 
+
-
//
+
-
// Styling
+
-
//
+
-
fst_h1.style.cssText = 'position:relative';
+
-
div.style.cssText = 'position:absolute; right:0px; font-size:x-small; bottom:-1.7em';
+
-
// IE fix — relative>absolute just dont work there (is positioned relative to body)
+
-
if (clientPC.indexOf('msie')!=-1 && clientPC.indexOf('opera') == -1)
+
-
div.style.cssText='position:absolute; right:1.5em; font-size:x-small; top:3.8em'
+
-
;
+
-
//
+
// Insert span container into the DOM before the h1
-
// Insert div container into the DOM before the h1
+
fst_h1.insertBefore(document.createTextNode(" "), fst_h1.firstChild);
-
//
+
fst_h1.insertBefore(span, fst_h1.firstChild);
-
fst_h1.appendChild(div);
+
});
-
}
+
-
addOnloadHook(addEditTopLink);
+

Version vom 14:22, 12. Mär. 2008

// ursprünglich: [[:en:User:Pile0nades]]
// Erweitert von: Maciej Jaros [[:pl:User:Nux]]
// siehe http://pl.wikipedia.org/wiki/MediaWiki:Monobook.js
// Korrigiert von: [[Benutzer:TMg]]
 
addOnloadHook(function() {
	// if this is preview page or there is no edit tab, stop
	// somehow it gets run twice on some pages - stop that
	if (! wgIsArticle || window.addEditTopLinkDone)
		return;
	window.addEditTopLinkDone = true;
 
	// if there are no edit-section links then stop
	var spans = document.getElementById("bodyContent").getElementsByTagName("span");
	var i;
	for (i = 0; i < spans.length; i++) {
		if (spans[i].className == 'editsection')
			break;
	}
	if (i >= spans.length)
		return;
 
	// additional checkup to stop
	var test = document.getElementById("bodyContent").getElementsByTagName("h2").length +
		document.getElementById("bodyContent").getElementsByTagName("h3").length +
		document.getElementById("bodyContent").getElementsByTagName("h4").length;
	// note that there is always siteSub (h3)
	var addEditTopLinkNumHeaders = window.addEditTopLinkNumHeaders || 2;
	if (test <= addEditTopLinkNumHeaders)
		return;
 
	// get first header element
	var fst_h1 = document.getElementById("content").getElementsByTagName("h1")[0];
 
	// Creating elements
	// create span
	var span = document.createElement("SPAN");
	span.className = 'editsection';
	// create link
	var link = document.createElement("A");
	link.href = document.getElementById("ca-edit").getElementsByTagName("a")[0].href + '&section=0';
	link.title = "Abschnitt bearbeiten: Einleitung";
	link.appendChild(document.createTextNode('Bearbeiten'));
	// append link and stuff to span
	span.appendChild(document.createTextNode('['));
	span.appendChild(link);
	span.appendChild(document.createTextNode(']'));
 
	// Insert span container into the DOM before the h1
	fst_h1.insertBefore(document.createTextNode(" "), fst_h1.firstChild);
	fst_h1.insertBefore(span, fst_h1.firstChild);
});
Persönliche Werkzeuge