/* * JavaScript for folding/unfolding menus * -------------------------------------------------------------------- * $Revision:: $ * $Date:: $ * $Tag:: 0.2.1-FINAL $ * $Author:: $ * -------------------------------------------------------------------- * Copyright (c) 2003 - 2009 by Roland Haeder * Copyright (c) 2009 - 2011 by Mailer Developer Team * For more information visit: http://mxchange.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301 USA */ // Init variables var menuStates = []; var id = null; /** * Function to fold all menus and unfold current (mainAction) one * * @param mode Unused ATM, is the menu 'mode' and will be 'admin','guest','member' or 'sponsor') * @param currentAction Currently selected (clicked) 'action' * @param action Unused ATM, 'action' of menu block * @param what Unused ATM, 'what' of menu entry */ function changeMenuFoldState (mode, currentAction, action, what) { // Get all li-tags var li = document.getElementsByTagName('li'); // Generate tag id id = 'action_menu_' + currentAction; // Get element var current = document.getElementById(id); // Is it displayed? if (menuStates[id] == true) { // Then hide it hideMenu(current, id); } else { // Else display it showMenu(current, id); } // Stop click return false; } // Hide given menu function hideMenu (current, id) { // Change CSS and state current.style.cssText = 'display: none;'; menuStates[id] = false; } // Show given menu and hide all others function showMenu (current, id) { // Hide all menus first for (id2 in menuStates) { // Hide this hideMenu(document.getElementById(id2), id2); } // END - for // Last make given menu visible current.style.cssText = 'display: visible;'; menuStates[id] = true; } // Init all folding states function initMenuFoldStates () { // Init variables var style = null; var style2 = null; // Get all li-tags var li = document.getElementsByTagName('li'); // Search for all menus for (var i = 0; i < li.length; i++) { // Skip login/logout if ((li[i].id.substr(-5, 5) == 'login') || (li[i].id.substr(-6, 6) == 'logout')) { // Skip this entry continue; } // END - if // We only want to look for 'action_menu_foo' if (li[i].id.substr(0, 12) == 'action_menu_') { // Okay, found one, so copy it style = li[i].style.cssText; // Is last char a semicolon if (style.substr(-1, 1) == ';') { // Then cut it off style = style.substr(0, (style.length - 1)); } // END - if // Is first part 'display' and last 'none'? menuStates[li[i].id] = ((style.substr(0, 7) == 'display') && (style.substr((style.length - 4), 4) != 'none')); //* DEBUG */ document.write('DEBUG: id=' + li[i].id + ',style=' + style + ',' + style.substr(0, 7) + '/' + style.substr((style.length - 4), 4) + '=' + menuStates[li[i].id] + '
'); } // END - if } // END - for }