Utente:Balubino/monobook.js
Questa pagina definisce alcuni parametri di aspetto e comportamento generale di tutte le pagine. Per personalizzarli vedi Aiuto:Stile utente.
Nota: dopo aver salvato è necessario pulire la cache del proprio browser per vedere i cambiamenti (per le pagine globali è comunque necessario attendere qualche minuto). Per Mozilla / Firefox / Safari: fare clic su Ricarica tenendo premuto il tasto delle maiuscole, oppure premere Ctrl-F5 o Ctrl-R (Command-R su Mac); per Chrome: premere Ctrl-Shift-R (Command-Shift-R su un Mac); per Konqueror: premere il pulsante Ricarica o il tasto F5; per Opera può essere necessario svuotare completamente la cache dal menù Strumenti → Preferenze; per Internet Explorer: mantenere premuto il tasto Ctrl mentre si preme il pulsante Aggiorna o premere Ctrl-F5.
// Add an eventListener to browsers that can do it somehow.
// Originally by the amazing Scott Andrew.
function addEvent(obj, evType, fn){
if (obj.addEventListener){
obj.addEventListener(evType, fn, true);
return true;
} else if (obj.attachEvent){
var r = obj.attachEvent("on"+evType, fn);
return r;
} else {
return false;
}
}
function initFoldingBar() {
var h2 = document.getElementsByTagName('h2');
for (i=0; i < h2.length; i++) {
var cH2 = h2.item(i);
//cH2.style.backgroundColor = 'yellow';
//var nH2 = h2.item(i+1);
catturaSez(cH2);
if (!cH2.getAttribute("cl")) {
var toggler = document.createElement('a');
var togglerTxt = document.createTextNode('+');
toggler.href = "javascript: void 0";
addEvent(toggler, "click", mostraNascondi);
toggler.appendChild(togglerTxt);
cH2.insertBefore(toggler,cH2.childNodes[0]);
}
cH2.setAttribute("cl","1");
//toggler.href = "javascript: return void;";
//toggler.ClickHandler = "mostraNascondi";
//XBrowserAddHandler(toggler, "click", "ClickHandler");
/*
if (newDiv) {
//document.body.insertBefore(newDiv,nH2);
document.body.appendChild(newDiv);
}
*/
}
}
function mostraNascondi(e) {
if (!e) {
var tgt = window.event.srcElement.parentNode.parentNode;
} else {
var tgt = e.target.parentNode;
}
catturaSez(tgt,1);
}
function sezioneVicina(ele) {
if (ele.nextSibling.nodeType == 3) {
// allora siamo su gecko: contare 4 tag in avanti
if (ele.nextSibling.nextSibling.nextSibling.nextSibling.tagName == 'H2') {
return true;
}
} else {
// siamo su ie contare 2 tag
if (ele.nextSibling.nextSibling.tagName == 'H2') {
return true;
}
}
}
function catturaSez(ele,flag) {
flag = (!flag) ? '1' : flag;
//var newDiv = document.createElement('div');
var cItem = ele.nextSibling;
// aggiunto nextSibling perchèdeve fermarsi un nodo prima del prossimo H2: c'è anche l'ancorh
// event better: mi becco i bottoni di edit come limite inferiore
// se non e' spazio
while(cItem && cItem.tagName != 'H2') {
if (cItem.nodeType != 3) {
if (cItem.className == "editsection" && sezioneVicina(cItem)) {return false;}
if (cItem.style) {
if (flag == 1) {
//cItem.setAttribute("oldisplay", cItem.style.display);
//var sDisplay = (cItem.style.display == 'none') ? cItem.getAttribute("oldisplay") : 'none';
var sDisplay = (cItem.style.display == 'none') ? 'block' : 'none';
//cItem.style.backgroundColor='gray';
cItem.style.display=sDisplay;
} else if (flag == 2) {
//cItem.style.backgroundColor='gray';
}
//} else {
//alert(cItem.tagName);
}
//newDiv.appendChild(cItem);
//document.removeChild(cItem);
}
cItem = cItem.nextSibling;
}
//return newDiv;
}
initFoldingBar();