1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
| /*
var currentMenu = null;
var currentSub = null;
if (!document.getElementById) {
document.getElementById = function() { return null; }
}
function initializeMenu(menuId, actuatorId) {
var menu = document.getElementById(menuId);
var actuator = document.getElementById(actuatorId);
if (menu == null || actuator == null) return;
if (menu.className == "submenu") {
initializeSubMenu(menuId, actuatorId);
return;
}
actuator.onmouseover = function() {
if (currentMenu) {
currentMenu.style.visibility = "hidden";
this.showMenu();
if (currentSub != null) {
currentSub.style.visibility = "hidden";
}
}
}
actuator.onclick = function() {
if (currentMenu == null) {
this.showMenu();
}
else {
currentMenu.style.visibility = "hidden";
currentMenu = null;
}
return false;
}
actuator.showMenu = function() {
menu.style.left = this.offsetLeft + "px";
menu.style.top = this.offsetTop + this.offsetHeight + "px";
currentMenu = menu;
menu.style.visibility = "visible";
}
}
function initializeSubMenu(menuId, actuatorId) {
var menu = document.getElementById(menuId);
var actuator = document.getElementById(actuatorId);
if (menu == null || actuator == null) return;
actuator.className += " subactuator";
actuator.onmouseover = function() {
if (currentSub) {
currentSub.style.visibility = "hidden";
this.showMenu();
}
}
actuator.onclick = function() {
if (currentSub == null) {
this.showMenu();
} else {
currentSub.style.visibility = "hidden";
currentSub = null;
}
return false;
}
actuator.showMenu = function() {
menu.style.left = 140 + "px";
menu.style.top = this.offsetTop - 1 + "px";
menu.style.visibility = "visible";
currentSub = menu;
}
}
function expandMenus() {
// empty method - this is here b/c the ListDisplayer
// calls this method for expanding menus and the list
// type is determined by JavaScript, rather than Java
}
// This function loops through all the <ul>'s in the document and
// initializes the menus for them if they have menu classes
function initializeMenus() {
var uls = document.getElementsByTagName("ul");
for (i = 0; i < uls.length; i++) {
if (uls[i].className == "menuList") {
decorateMenu(uls[i]);
}
}
}
function decorateMenu(menu) {
var links = menu.getElementsByTagName("a");
var lists = document.getElementsByTagName("ul");
var actuators = new Array();
var nonActuators = new Array();
// build an array of actuators
for (i=0; i < links.length; i++) {
if (links[i].className == "actuator") {
actuators[actuators.length] = links[i];
} else {
nonActuators[nonActuators.length] = links[i];
}
}
var menus = new Array();
// build an array of menus
for (i=0; i < lists.length; i++) {
if (lists[i].className == "menu" || lists[i].className == "submenu") {
menus[menus.length] = lists[i];
}
}
// initialize actuators and menus (number should be the same)
for (i=0; i < actuators.length; i++) {
initializeMenu(menus[i].id, actuators[i].id);
}
// Begin custom code to remember last item clicked (with cookies)
// add an onclick event to set a cookie on the non-actuators
for (i=0; i < nonActuators.length; i++) {
nonActuators[i].onclick=function() {
setCookie(itemCookie,this.href);
}
}
}
/* You can call initializeMenus() manually from your JSP if this doesn't work.
* Just put the following code after the last menu tag.
* <script type="text/javascript">
* initializeMenus();
* </script>
*/
window.onload = initializeMenus; |
Partager