website/parts/menuResize.js

64 lines
1.5 KiB
JavaScript

var columnIDs;
function init () {
setHeight ('menu', columnIDs);
}
function doResize () {
setHeight ('menu', columnIDs);
}
function setHeight (myTarget, columns) {
if (document.getElementById) {
var targetID = document.getElementById (myTarget);
var maxHeight = targetID.offsetHeight;
var divCount = columns.length;
var i = 0;
// we only want to resize if the level 2 CSS has been loaded
if (window.getComputedStyle) { // got NS/Mozilla/Firefox
var targetStyle = window.getComputedStyle (targetID, "");
if (targetStyle.getPropertyValue ('background-color') == 'transparent') {
return;
}
} else if (targetID.currentStyle) { // got IE
if (targetID.currentStyle.backgroundColor == 'transparent') {
return;
}
}
// the divs array contains references to each column's div element.
var divs = new Array (divCount);
for (i = 0; i < divCount; i++) {
divs[i] = document.getElementById (columns[i]);
}
// determine the maximum height out of all columns specified
for (i = 0; i < divs.length; i++) {
if (maxHeight < divs[i].offsetHeight) {
maxHeight = divs[i].offsetHeight + 2;
}
}
// set the target column to that maximum height
targetID.style.height = maxHeight + 'px';
}
}
/* for Mozilla */
if (document.addEventListener) {
document.addEventListener ("DOMContentLoaded", init, null);
}
/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
document.write ("<script defer src=ie_onload.js><"+"/script>");
/*@end @*/
/* for other browsers */
window.onload = init;
window.onresize = doResize;