MediaWiki:Gadget-Einleitung-bearbeiten.js
Aus Kitakien
(Unterschied zwischen Versionen)
Version vom 02:14, 8. Dez. 2007
// ursprünglich: [[:en:User:Pile0nades]] // Erweitert von: Maciej Jaros [[:pl:User:Nux]] // siehe http://pl.wikipedia.org/wiki/MediaWiki:Monobook.js var addEditTopLinkNumHeaders = 2; function addEditTopLink() { // // somehow it gets run twice on some pages - stop that if (window.addEditTopLinkDone) return ; 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 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) if (test<=addEditTopLinkNumHeaders) return ; // // get first header element var fst_h1 = document.getElementById("content").getElementsByTagName("h1")[0]; // // Creating elements // // create div var div = document.createElement("DIV"); div.className = 'editsection'; // create link var link = document.createElement("A"); link.href = document.getElementById("ca-edit").getElementsByTagName("a")[0].href + '§ion=0'; link.setAttribute('title', 'Einleitung des Artikels bearbeiten'); link.appendChild(document.createTextNode('Bearbeiten')); // append link and stuff to div div.appendChild(document.createTextNode('[')); div.appendChild(link); div.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 div container into the DOM before the h1 // fst_h1.appendChild(div); } addOnloadHook(addEditTopLink);