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