Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
m (Without line feeds, it will have to be like this.) |
(tested in greasemonkey, hopefully works here) |
||
Line 44: | Line 44: | ||
} | } | ||
} | } | ||
} | |||
function columnAreaImage(){ | |||
var divS; | |||
if (document.getElementById ) { | |||
divS = document.getElementById("column-content"); | |||
} else if (document.all ) { | |||
divS = document.all["column-content"]; | |||
} else { | |||
return; | |||
} | |||
if ( divS && divS.style ){ | |||
var divSHval; | |||
if (divS.style.pixelHeight) { | |||
divSHval= divS.style.pixelHeight; | |||
} else { | |||
divSHval= divS.offsetHeight; | |||
} | |||
if(Number(divSHval) >1132){ | |||
//1132=768(number bigger than background image and side buttons)+imgheight(366) | |||
divS.style.backgroundImage = "url(/images/6/69/The_Infosphere_lower_Background.png)"; | |||
divS.style.backgroundPosition ="bottom left"; | |||
divS.style.backgroundRepeat ="no-repeat"; | |||
} | |||
} | |||
} | } | ||
addOnloadHook(createAllReasonButtons); | addOnloadHook(createAllReasonButtons); | ||
addOnloadHook(columnAreaImage); | |||
/*</pre>*/ | /*</pre>*/ |
Revision as of 13:02, 1 March 2008
/* Any JavaScript here will be loaded for all users on every page load. */ /*<pre>*/ var reasonCaptionShow = "Show reason"; var reasonCaptionHide = "Hide reason"; var hasClass = (function () { var reCache = {}; return function (element, className) { return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className); }; })(); function collapseReason(id) { var content = document.getElementById("reasonContent-" + id); var rSwitch = document.getElementById("reasonSwitch-" + id); if(rSwitch.firstChild.data==reasonCaptionShow) { content.style.display = "block"; rSwitch.firstChild.data = reasonCaptionHide; } else { content.style.display = "none"; rSwitch.firstChild.data = reasonCaptionShow; } } function createAllReasonButtons() { var reasonIndex = 0; var divs = document.getElementsByTagName("div"); for(var i = 0; i < divs.length; i++) { if(hasClass(divs[i], "reasonContainer")) { var rSwitch = divs[i].childNodes[0].lastChild; var content = divs[i].childNodes[1]; content.setAttribute("id", "reasonContent-" + reasonIndex); var link = document.createElement("a"); var linkCaption = document.createTextNode(reasonCaptionShow); link.setAttribute("id", "reasonSwitch-" + reasonIndex); link.setAttribute("href", "javascript:collapseReason(" + reasonIndex + ");"); link.appendChild(linkCaption); rSwitch.appendChild(link); reasonIndex++; } } } function columnAreaImage(){ var divS; if (document.getElementById ) { divS = document.getElementById("column-content"); } else if (document.all ) { divS = document.all["column-content"]; } else { return; } if ( divS && divS.style ){ var divSHval; if (divS.style.pixelHeight) { divSHval= divS.style.pixelHeight; } else { divSHval= divS.offsetHeight; } if(Number(divSHval) >1132){ //1132=768(number bigger than background image and side buttons)+imgheight(366) divS.style.backgroundImage = "url(/images/6/69/The_Infosphere_lower_Background.png)"; divS.style.backgroundPosition ="bottom left"; divS.style.backgroundRepeat ="no-repeat"; } } } addOnloadHook(createAllReasonButtons); addOnloadHook(columnAreaImage); /*</pre>*/