/*
* JSCookMenu.js for mod_JSCookMenu
* Wizzud : The script below is almost original. The only changes I have made are:
* - put the whole script in one big 'if' statement, checking the declaration of a variable so that I can include
* the script multiple times. I have to do it this way because I need the script as high up the HTML as possible,
* which would ideally be in the
section but I can't get it there safely. I would like to have used
* $mainframe->addCustomHeadTag(), but that relies on templates using output buffering to get the main body of the
* page BEFORE getting the header using mosShowHead(), which they don't! So each instance of a menu loads this script
* but only the first loaded will run the code inside my 'if' statement.
* - modified the class of the main menu, so as to be able to distinguish between a horizontal and vertical menu in the
* CSS. The class of the main menu table was set to Menu for both vertical and horizontal; it now gets set
* to either MenuH or MenuV, depending upon the orientation. The CSS stylesheets have also been
* amended accordingly.
*/
/*
JSCookMenu v1.4.4. (c) Copyright 2002-2005 by Heng Yuan
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
ITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
// Wizzud: start of alternative method for enabling multiple menus ...
if(typeof _cmIDCount == 'undefined'){
// Globals
var _cmIDCount = 0;
var _cmIDName = 'cmSubMenuID'; // for creating submenu id
var _cmTimeOut = null; // how long the menu would stay
var _cmCurrentItem = null; // the current menu item being selected;
var _cmNoAction = new Object (); // indicate that the item cannot be hovered.
var _cmNoClick = new Object (); // similar to _cmNoAction but does not respond to mouseup/mousedown events
var _cmSplit = new Object (); // indicate that the item is a menu split
var _cmItemList = new Array (); // a simple list of items
// default node properties
var _cmNodeProperties =
{
// main menu display attributes
//
// Note. When the menu bar is horizontal,
// mainFolderLeft and mainFolderRight are
// put in . When the menu
// bar is vertical, they would be put in
// a separate TD cell.
// HTML code to the left of the folder item
mainFolderLeft: '',
// HTML code to the right of the folder item
mainFolderRight: '',
// HTML code to the left of the regular item
mainItemLeft: '',
// HTML code to the right of the regular item
mainItemRight: '',
// sub menu display attributes
// HTML code to the left of the folder item
folderLeft: '',
// HTML code to the right of the folder item
folderRight: '',
// HTML code to the left of the regular item
itemLeft: '',
// HTML code to the right of the regular item
itemRight: '',
// cell spacing for main menu
mainSpacing: 0,
// cell spacing for sub menus
subSpacing: 0,
// auto disappear time for submenus in milli-seconds
delay: 500,
// act on click to open sub menu
// not yet implemented
// 0 : use default behavior
// 1 : hover open in all cases
// 2 : click on main, hover on sub
// 3 : click open in all cases
clickOpen: 1
};
//////////////////////////////////////////////////////////////////////
//
// Drawing Functions and Utility Functions
//
//////////////////////////////////////////////////////////////////////
//
// produce a new unique id
//
function cmNewID ()
{
return _cmIDName + (++_cmIDCount);
}
//
// return the property string for the menu item
//
function cmActionItem (item, prefix, isMain, idSub, orient, nodeProperties)
{
var clickOpen = _cmNodeProperties.clickOpen;
if (nodeProperties.clickOpen)
clickOpen = nodeProperties.clickOpen;
// var index = _cmItemList.push (item) - 1;
_cmItemList[_cmItemList.length] = item;
var index = _cmItemList.length - 1;
idSub = (!idSub) ? 'null' : ('\'' + idSub + '\'');
orient = '\'' + orient + '\'';
prefix = '\'' + prefix + '\'';
var onClick = (clickOpen == 3) || (clickOpen == 2 && isMain);
var returnStr;
if (onClick)
returnStr = ' onmouseover="cmItemMouseOver (this,' + prefix + ',' + isMain + ',' + idSub + ',' + index + ')" onmousedown="cmItemMouseDownOpenSub (this,' + index + ',' + prefix + ',' + orient + ',' + idSub + ')"';
else
returnStr = ' onmouseover="cmItemMouseOverOpenSub (this,' + prefix + ',' + isMain + ',' + idSub + ',' + orient + ',' + index + ')" onmousedown="cmItemMouseDown (this,' + index + ')"';
return returnStr + ' onmouseout="cmItemMouseOut (this,' + nodeProperties.delay + ')" onmouseup="cmItemMouseUp (this,' + index + ')"';
}
//
// this one is used by _cmNoClick to only take care of onmouseover and onmouseout
// events which are associated with menu but not actions associated with menu clicking/closing
//
function cmNoClickItem (item, prefix, isMain, idSub, orient, nodeProperties)
{
// var index = _cmItemList.push (item) - 1;
_cmItemList[_cmItemList.length] = item;
var index = _cmItemList.length - 1;
idSub = (!idSub) ? 'null' : ('\'' + idSub + '\'');
orient = '\'' + orient + '\'';
prefix = '\'' + prefix + '\'';
return ' onmouseover="cmItemMouseOver (this,' + prefix + ',' + isMain + ',' + idSub + ',' + index + ')" onmouseout="cmItemMouseOut (this,' + nodeProperties.delay + ')"';
}
function cmNoActionItem (item, prefix)
{
return item[1];
}
function cmSplitItem (prefix, isMain, vertical)
{
var classStr = 'cm' + prefix;
if (isMain)
{
classStr += 'Main';
if (vertical)
classStr += 'HSplit';
else
classStr += 'VSplit';
}
else
classStr += 'HSplit';
return eval (classStr);
}
//
// draw the sub menu recursively
//
function cmDrawSubMenu (subMenu, prefix, id, orient, nodeProperties)
{
var str = '' + strSub;
return str;
}
//
// The function that builds the menu inside the specified element id.
//
// @param id id of the element
// orient orientation of the menu in [hv][ab][lr] format
// menu the menu object to be drawn
// nodeProperties properties for each menu node
//
function cmDraw (id, menu, orient, nodeProperties, prefix)
{
var obj = cmGetObject (id);
if (!nodeProperties)
nodeProperties = _cmNodeProperties;
if (!prefix)
prefix = '';
// Wizzud ...
if (!orient)
orient = 'hbr';
var orientStr = String (orient);
var orientSub;
var vertical;
var orientVorH = orientStr.charAt(0).toUpperCase();
/* Wizzud - replaced ...
var str = '