2 * JavaScript for folding/unfolding menus
3 * --------------------------------------------------------------------
8 * --------------------------------------------------------------------
9 * Copyright (c) 2003 - 2009 by Roland Haeder
10 * Copyright (c) 2009 - 2012 by Mailer Developer Team
11 * For more information visit: http://mxchange.org
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
30 var menuStates = new Array();
34 * Function to fold all menus and unfold current (mainAction) one
36 * @param mode Unused ATM, is the menu 'mode' and will be 'admin','guest','member' or 'sponsor')
37 * @param currentAction Currently selected (clicked) 'action'
38 * @param action Unused ATM, 'action' of menu block
39 * @param what Unused ATM, 'what' of menu entry
41 function changeMenuFoldState (mode, currentAction, action, what) {
43 var li = document.getElementsByTagName('li');
46 id = 'action_menu_' + currentAction;
49 var current = document.getElementById(id);
52 if (menuStates[id] === true) {
54 hideMenu(current, id);
57 showMenu(current, id);
65 function hideMenu (current, id) {
66 // Change CSS and state
67 current.style.cssText = 'display: none;';
68 menuStates[id] = false;
71 // Show given menu and hide all others
72 function showMenu (current, id) {
73 // Hide all menus first
74 for (id2 in menuStates) {
76 hideMenu(document.getElementById(id2), id2);
79 // Last make given menu visible
80 current.style.cssText = 'display: visible;';
81 menuStates[id] = true;
84 // Init all folding states
85 function initMenuFoldStates () {
91 var li = document.getElementsByTagName('li');
93 // Search for all menus
94 for (var i = 0; i < li.length; i++) {
96 if ((li[i].id.substr(-5, 5) == 'login') || (li[i].id.substr(-6, 6) == 'logout')) {
101 // We only want to look for 'action_menu_foo'
102 if (li[i].id.substr(0, 12) == 'action_menu_') {
103 // Okay, found one, so copy it
104 style = li[i].style.cssText;
106 // Is last char a semicolon
107 if (style.substr(-1, 1) == ';') {
109 style = style.substr(0, (style.length - 1));
112 // Is first part 'display' and last 'none'?
113 menuStates[li[i].id] = ((style.substr(0, 7) == 'display') && (style.substr((style.length - 4), 4) != 'none'));
114 //* DEBUG */ document.write('DEBUG: id=' + li[i].id + ',style=' + style + ',' + style.substr(0, 7) + '/' + style.substr((style.length - 4), 4) + '=' + menuStates[li[i].id] + '<br />');