/*----------------------------------------------------------------------------\ | XMenu 1.12 | |-----------------------------------------------------------------------------| | Created by Erik Arvidsson | | (http://webfx.eae.net/contact.html#erik) | | For WebFX (http://webfx.eae.net/) | |-----------------------------------------------------------------------------| | An object based tree widget, emulating the one found in microsoft windows, | | with persistence using cookies. Works in IE 5+, Mozilla and konqueror 3. | |-----------------------------------------------------------------------------| | Copyright (c) 1999 - 2002 Emil A Eklund | |-----------------------------------------------------------------------------| | This software is provided "as is", without warranty of any kind, express or | | implied, including but not limited to the warranties of merchantability, | | fitness 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. | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | | This software is available under the three different licenses mentioned | | below. To use this software you must chose, and qualify, for one of those. | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | | The WebFX Non-Commercial License http://webfx.eae.net/license.html | | Permits anyone the right to use the software in a non-commercial context | | free of charge. | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | | The WebFX Commercial license http://webfx.eae.net/commercial.html | | Permits the license holder the right to use the software in a commercial | | context. Such license must be specifically obtained, however it's valid for | | any number of implementations of the licensed software. | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | | GPL - The GNU General Public License http://www.gnu.org/licenses/gpl.txt | | Permits anyone the right to use and modify the software without limitations | | as long as proper credits are given and the original and modified source | | code are included. Requires that the final product, software derivate from | | the original source or any software utilizing a GPL component, such as | | this, is also licensed under the GPL license. | |-----------------------------------------------------------------------------| | 2001-01-12 | Original Version Posted. | | 2001-11-20 | Added hover mode support and removed Opera focus hacks | | 2001-12-20 | (1.1) Added auto positioning and some properties to support | | | this. | | 2002-08-13 | (1.11) toString used ' for attributes. Changed to " to allow | | | in properties/arguments. | | 2003-04-27 | (1.12) Added support for target property on menu item/button | |-----------------------------------------------------------------------------| | Created 2001-01-12 | All changes are in the log above. | Updated 2003-04-27 | \----------------------------------------------------------------------------*/ // check browsers var ua = navigator.userAgent; var opera = /opera [56789]|opera\/[56789]/i.test(ua); var ie = !opera && /MSIE/.test(ua); var ie50 = ie && /MSIE 5\.[01234]/.test(ua); var ie6 = ie && /MSIE [6789]/.test(ua); var ieBox = ie && (document.compatMode == null || document.compatMode != "CSS1Compat"); var moz = !opera && /gecko/i.test(ua); var nn6 = !opera && /netscape.*6\./i.test(ua); // define the default values webfxMenuDefaultWidth = 100; webfxMenuDefaultBorderLeft = 1; webfxMenuDefaultBorderRight = 1; webfxMenuDefaultBorderTop = 1; webfxMenuDefaultBorderBottom = 1; webfxMenuDefaultPaddingLeft = 1; webfxMenuDefaultPaddingRight = 1; webfxMenuDefaultPaddingTop = 1; webfxMenuDefaultPaddingBottom = 1; webfxMenuDefaultShadowLeft = 0; webfxMenuDefaultShadowRight = ie && !ie50 && /win32/i.test(navigator.platform) ? 4 :0; webfxMenuDefaultShadowTop = 0; webfxMenuDefaultShadowBottom = ie && !ie50 && /win32/i.test(navigator.platform) ? 4 : 0; webfxMenuItemDefaultHeight = 18; webfxMenuItemDefaultText = "Untitled"; webfxMenuItemDefaultHref = "javascript:void(0)"; webfxMenuSeparatorDefaultHeight = 6; webfxMenuDefaultEmptyText = "Empty"; webfxMenuDefaultUseAutoPosition = nn6 ? false : true; // other global constants webfxMenuImagePath = ""; webfxMenuUseHover = opera ? true : false; webfxMenuHideTime = 500; webfxMenuShowTime = 200; var webFXMenuHandler = { idCounter : 0, idPrefix : "webfx-menu-object-", all : {}, getId : function () { return this.idPrefix + this.idCounter++; }, overMenuItem : function (oItem) { if (this.showTimeout != null) window.clearTimeout(this.showTimeout); if (this.hideTimeout != null) window.clearTimeout(this.hideTimeout); var jsItem = this.all[oItem.id]; if (webfxMenuShowTime <= 0) this._over(jsItem); else //this.showTimeout = window.setTimeout(function () { webFXMenuHandler._over(jsItem) ; }, webfxMenuShowTime); // I hate IE5.0 because the piece of shit crashes when using setTimeout with a function object this.showTimeout = window.setTimeout("webFXMenuHandler._over(webFXMenuHandler.all['" + jsItem.id + "'])", webfxMenuShowTime); }, outMenuItem : function (oItem) { if (this.showTimeout != null) window.clearTimeout(this.showTimeout); if (this.hideTimeout != null) window.clearTimeout(this.hideTimeout); var jsItem = this.all[oItem.id]; if (webfxMenuHideTime <= 0) this._out(jsItem); else //this.hideTimeout = window.setTimeout(function () { webFXMenuHandler._out(jsItem) ; }, webfxMenuHideTime); this.hideTimeout = window.setTimeout("webFXMenuHandler._out(webFXMenuHandler.all['" + jsItem.id + "'])", webfxMenuHideTime); }, blurMenu : function (oMenuItem) { window.setTimeout("webFXMenuHandler.all[\"" + oMenuItem.id + "\"].subMenu.hide();", webfxMenuHideTime); }, _over : function (jsItem) { if (jsItem.subMenu) { jsItem.parentMenu.hideAllSubs(); jsItem.subMenu.show(); } else jsItem.parentMenu.hideAllSubs(); }, _out : function (jsItem) { // find top most menu var root = jsItem; var m; if (root instanceof WebFXMenuButton) m = root.subMenu; else { m = jsItem.parentMenu; while (m.parentMenu != null && !(m.parentMenu instanceof WebFXMenuBar)) m = m.parentMenu; } if (m != null) m.hide(); }, hideMenu : function (menu) { if (this.showTimeout != null) window.clearTimeout(this.showTimeout); if (this.hideTimeout != null) window.clearTimeout(this.hideTimeout); this.hideTimeout = window.setTimeout("webFXMenuHandler.all['" + menu.id + "'].hide()", webfxMenuHideTime); }, showMenu : function (menu, src, dir) { if (this.showTimeout != null) window.clearTimeout(this.showTimeout); if (this.hideTimeout != null) window.clearTimeout(this.hideTimeout); if (arguments.length < 3) dir = "vertical"; menu.show(src, dir); } }; function WebFXMenu() { this._menuItems = []; this._subMenus = []; this.id = webFXMenuHandler.getId(); this.top = 0; this.left = 0; this.shown = false; this.parentMenu = null; webFXMenuHandler.all[this.id] = this; } WebFXMenu.prototype.width = webfxMenuDefaultWidth; WebFXMenu.prototype.emptyText = webfxMenuDefaultEmptyText; WebFXMenu.prototype.useAutoPosition = webfxMenuDefaultUseAutoPosition; WebFXMenu.prototype.borderLeft = webfxMenuDefaultBorderLeft; WebFXMenu.prototype.borderRight = webfxMenuDefaultBorderRight; WebFXMenu.prototype.borderTop = webfxMenuDefaultBorderTop; WebFXMenu.prototype.borderBottom = webfxMenuDefaultBorderBottom; WebFXMenu.prototype.paddingLeft = webfxMenuDefaultPaddingLeft; WebFXMenu.prototype.paddingRight = webfxMenuDefaultPaddingRight; WebFXMenu.prototype.paddingTop = webfxMenuDefaultPaddingTop; WebFXMenu.prototype.paddingBottom = webfxMenuDefaultPaddingBottom; WebFXMenu.prototype.shadowLeft = webfxMenuDefaultShadowLeft; WebFXMenu.prototype.shadowRight = webfxMenuDefaultShadowRight; WebFXMenu.prototype.shadowTop = webfxMenuDefaultShadowTop; WebFXMenu.prototype.shadowBottom = webfxMenuDefaultShadowBottom; WebFXMenu.prototype.add = function (menuItem) { this._menuItems[this._menuItems.length] = menuItem; if (menuItem.subMenu) { this._subMenus[this._subMenus.length] = menuItem.subMenu; menuItem.subMenu.parentMenu = this; } menuItem.parentMenu = this; }; WebFXMenu.prototype.show = function (relObj, sDir) { if (this.useAutoPosition) this.position(relObj, sDir); var divElement = document.getElementById(this.id); divElement.style.left = opera ? this.left : this.left + "px"; divElement.style.top = opera ? this.top : this.top + "px"; divElement.style.visibility = "visible"; this.shown = true; if (this.parentMenu) this.parentMenu.show(); }; WebFXMenu.prototype.hide = function () { this.hideAllSubs(); var divElement = document.getElementById(this.id); divElement.style.visibility = "hidden"; this.shown = false; }; WebFXMenu.prototype.hideAllSubs = function () { for (var i = 0; i < this._subMenus.length; i++) { if (this._subMenus[i].shown) this._subMenus[i].hide(); } }; WebFXMenu.prototype.toString = function () { var top = this.top + this.borderTop + this.paddingTop; var str = "
"; for (var i = 0; i < this._subMenus.length; i++) { this._subMenus[i].left = this.left + this.width - this._subMenus[i].borderLeft; str += this._subMenus[i]; } return str; }; // WebFXMenu.prototype.position defined later function WebFXMenuItem(sText, sHref, sToolTip, oSubMenu) { this.text = sText || webfxMenuItemDefaultText; this.href = (sHref == null || sHref == "") ? webfxMenuItemDefaultHref : sHref; this.subMenu = oSubMenu; if (oSubMenu) oSubMenu.parentMenuItem = this; this.toolTip = sToolTip; this.id = webFXMenuHandler.getId(); webFXMenuHandler.all[this.id] = this; }; WebFXMenuItem.prototype.height = webfxMenuItemDefaultHeight; WebFXMenuItem.prototype.toString = function () { return "" + (this.subMenu ? "