Code:
/**
* LiveMenu, version 1.1
*
* Copyright (c) 2009-2010 Sergey Golubev
*
* LiveMenu is freely distributable under the terms of the MIT License.
* For details, see http://livemenu.sourceforge.net
*/
var liveMenu = {};
liveMenu.defaultConfig = {
/* Css class name of 'ul' elements, which are considered to be main menus */
mainMenuClassName: 'lm-menu',
/* Css class name of 'ul' elements, which are considered to be submenus */
submenuClassName: 'lm-submenu',
/* Css class name of a submenu container */
containerClassName: 'lm-container',
/* Css class names of horizontal and vertical submenus */
horizontalClassName: 'lm-horizontal', verticalClassName: 'lm-vertical',
/* Css class names, which determine position of a submenu */
right: 'lm-right', left: 'lm-left', up: 'lm-up', down: 'lm-down',
/* A delay in showing the submenus (in milliseconds)*/
showDelay: 80,
/* A delay in hiding a submenu (in milliseconds) */
hideDelay: 500,
/**
* An event type at which a submenu should be shown.
* Can be 'mouseenter' or 'click'
*/
showOn: 'mouseenter',
/**
* An effect that is used when showing or hiding a submenu.
* Can be 'plain', 'slide', 'fade' or smooth
*/
effect: 'plain',
/**
* Defines the way the submenus are being hidden: simultaneously or
* consecutively. Can be simultaneous or consecutive.
*/
mode: 'simultaneous', /**
* The following configuration options make sense only if the 'effect'
* option is not set to 'plain'
*/
/* The duration of showing or closing the submenus (in milliseconds) */
duration: 400,
/**
* The maximum number of simultaneously hiding sibling submenus. Makes
* sense only if the 'consecutive' mode is used, but regardless the mode,
* '0' value make the submenus hide without effects.
*/
maxHidingSubmenus: 3,
/* A transition algorithm. Can be 'linear' or 'sinoidal'. */
transition: 'sinoidal'
}
liveMenu.isReady = false; //True if the DOM is loaded
liveMenu.subsCount = 0; //Used for submenu IDs generation
liveMenu.isKonqueror = navigator.userAgent.indexOf('Konqueror') != -1;
/* Initializes the menus after the DOM is loaded */
liveMenu.initOnLoad = function (menuId, config) {
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", function() {
liveMenu.isReady = true;
new liveMenu.Menu(menuId, config);
}, false);
} else if (document.attachEvent) {
document.attachEvent("onreadystatechange", function() {
if (document.readyState === "complete") {
liveMenu.isReady = true;
new liveMenu.Menu(menuId, config);
}
});
}
liveMenu.event.add(window, "load", function () {
if (!liveMenu.isReady) new liveMenu.Menu(menuId, config);
});
}
/* The main menu constructor */
liveMenu.Menu = function (menuId, config) {
var X = liveMenu.Utils;
this.config = X.merge(liveMenu.defaultConfig, config);
if (this.config.showOn == 'click')
this.config.showDelay = 0;
if (this.config.effect == 'plain' || this.config.maxHidingSubmenus == 0)
this.config.mode = 'consecutive';
this.id = menuId;
this.domNode = document.getElementById(menuId);
this.orientation = this.getOrientation();
this.submenus = {};
this.visibleSubs = [];
this.stopHidingOn = null;
var initSubNodes = this.getInitSubNodes();
this.setSubIDs(initSubNodes);
var convertedSubNodes = this.convertMenuTree(initSubNodes);
this.initializeSubs(convertedSubNodes);
}
liveMenu.Menu.prototype = {
/* Gets initial submenu DOM nodes */
getInitSubNodes: function () {
var X = liveMenu.Utils, cfg = this.config,
ulNodes = this.domNode.getElementsByTagName('ul'),
initSubNodes = [];
for (var i=0, l=ulNodes.length; i<l; i++)
if (X.hasClass(ulNodes[i], cfg.submenuClassName))
initSubNodes.push(ulNodes[i]);
return initSubNodes;
},
/* Generates and sets submenu IDs */
setSubIDs: function (initSubNodes) {
for (var i=0, l=initSubNodes.length; i<l; i++) {
var initSub = initSubNodes[i];
initSub.id = 'submenu'+(++liveMenu.subsCount);
initSub.parentNode.id =
'submenu'+liveMenu.subsCount+'_opener';
}
},...
Or are you saying I am not calling it properly?
Bookmarks