⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ncbi_menu_dnd.js

📁 ncbi源码
💻 JS
📖 第 1 页 / 共 3 页
字号:
/* * Menu 0.8 990602 * by gary smith, July 1997 * Copyright (c) 1997-1999 Netscape Communications Corp. * * Netscape grants you a royalty free license to use or modify this * software provided that this copyright notice appears on all copies. * This software is provided "AS IS," without a warranty of any kind. * ------------------------------------------------------------------- * * Modified by Vladimir Ivanov, NIH, NCBI, February 2002 *    Added support dynamic menu (all menus use one container). *    Added automaticaly menu adjustment in the browsers window. *    Fixed some errors. */// By default dynamic menu is offwindow.useDynamicMenu = false;// NOTE:// By default all menu use a one container if "useDynamicMenu == TRUE"// Accordingly only one menu can be shown at a time.//// Dynamic menu work only in browsers that support property innerHTML// (Internet Explorer > 4.x & Netscape Navigator > 6.x) function dynamiccontentNS6(el, content){  if (document.getElementById){    rng = document.createRange();    rng.setStartBefore(el);    htmlFrag = rng.createContextualFragment(content);    while (el.hasChildNodes())      el.removeChild(el.lastChild);    el.appendChild(htmlFrag);  }}function Menu(label) {    this.version = "0.8d [menu.js; Menu; 020412]";    this.type = "Menu";    if (document.layers) {       this.fontSize = 14;    } else {       this.fontSize = 12;    }    this.fontWeight = "plain";    this.fontFamily = "arial,helvetica,espy,sans-serif";    this.fontColor = "#000000";    this.fontColorHilite = "#ffffff";    this.bgColor = "#555555";    this.menuBorder = 1;    this.menuItemBorder = 1;    this.menuItemBgColor = "#cccccc";    this.menuLiteBgColor = "#ffffff";    this.menuBorderBgColor = "#777777";    this.menuHiliteBgColor = "#000084";    this.menuContainerBgColor = "#cccccc";    this.childMenuIcon = "images/arrows.gif";    this.childMenuIconHilite = "images/arrows2.gif";    this.items = new Array();    this.actions = new Array();    this.colors = new Array();    this.mouseovers = new Array();    this.mouseouts = new Array();    this.childMenus = new Array();    this.addMenuItem = addMenuItem;    this.addMenuSeparator = addMenuSeparator;    this.writeMenus = writeMenus;    this.showMenu = showMenu;    this.onMenuItemOver = onMenuItemOver;    this.onMenuItemOut = onMenuItemOut;    this.onMenuItemDown = onMenuItemDown;    this.onMenuItemAction = onMenuItemAction;    this.hideMenu = hideMenu;    this.hideChildMenu = hideChildMenu;    this.mouseTracker = mouseTracker;    this.setMouseTracker = setMouseTracker;    if (!window.menus) window.menus = new Array();    this.label = label || "menuLabel" + window.menus.length;    this.number = window.menus.length;    window.menus[this.label] = this;    window.menus[window.menus.length] = this;    if (!window.activeMenus) window.activeMenus = new Array();    if (!window.menuContainers) window.menuContainers = new Array();    if (!window.mDrag) {        window.mDrag    = new Object();        mDrag.startMenuDrag = startMenuDrag;        mDrag.doMenuDrag    = doMenuDrag;        this.setMouseTracker();    }    // Disable drag: problemm with using touchpads on notebooks    this.disableDrag = 1;    if (window.MenuAPI) MenuAPI(this);}function addMenuItem(label, action, color, mouseover, mouseout) {    this.items[this.items.length] = label;    this.actions[this.actions.length] = action;    this.colors[this.colors.length] = color;    this.mouseovers[this.mouseovers.length] = mouseover;    this.mouseouts[this.mouseouts.length] = mouseout;}function addMenuSeparator() {    this.items[this.items.length] = "separator";    this.actions[this.actions.length] = "";    this.menuItemBorder = 0;}function getMenuItemID(menu_index, item_index) {	return menu_index * 1000 + item_index + 1;}function getMenuContent(container, index) {	menu = container.menus[index];	if (!menu) return '';    var proto = menu.prototypeStyles || this.prototypeStyles || menu;    var mouseOut = '';    if (!document.getElementById) mouseOut = ' onMouseOut="hideMenu(this);"';	    var content = ''+    '<DIV ID="menuLayer'+ index +'" STYLE="position:absolute;left:0;top:0;visibility:hidden;cursor:pointer;cursor:hand;">'+    '  <DIV ID="menuLite'+ index +'" STYLE="position:absolute;left:'+ proto.menuBorder +';top:'+ proto.menuBorder +';visibility:hide;"'+mouseOut+'>'+    '    <DIV ID="menuFg'+ index +'" STYLE="position:absolute;left:1;top:1;visibility:hide;">';	proto.menuWidth = 0;    if (!document.layers) {		proto.menuWidth = proto.menuWidth || proto.menuItemWidth + (proto.menuBorder * 2) + 2 || 200;	}    for (var i=0; i<menu.items.length; i++) {        var item = menu.items[i];        var childMenu = false;        var defaultHeight = 20;        var defaultIndent = 15;		var id = getMenuItemID(index,i);        if (item.label) {            item = item.label;            childMenu = true;//        } else if (item.indexOf(".gif") != -1 && item.indexOf("<IMG") == -1) {//            item = '<IMG SRC="' + item + '" NAME="menuItem'+ id +'Img">';//            defaultIndent = 0;//            if (document.layers) {//                defaultHeight = null;//            }        }   		proto.menuItemHeight = proto.menuItemHeight || defaultHeight;		h4 = proto.menuItemHeight/4;    	proto.menuItemIndent = proto.menuItemIndent || defaultIndent;        var itemProps = 'visibility:hide;font-Family:' + proto.fontFamily +';font-Weight:' + proto.fontWeight + ';fontSize:' + proto.fontSize + ';';        if (document.all || document.getElementById)        	itemProps += 'font-size:' + proto.fontSize + ';" onMouseOver="onMenuItemOver(null,this);" onMouseOut="onMenuItemOut(null,this);" onClick="onMenuItemAction(null,this);';        var dTag  = '<DIV ID="menuItem'+ id +'" STYLE="position:absolute;left:0;top:'+ (i * proto.menuItemHeight) +';'+ itemProps +'">';        var dText = '<DIV ID="menuItemText'+ id +'" STYLE="position:absolute;left:' + proto.menuItemIndent + ';top:0;color:'+ proto.fontColor +';">'+ item +'</DIV><DIV ID="menuItemHilite'+ id +'" STYLE="position:absolute;left:' + proto.menuItemIndent + ';top:0;color:'+ proto.fontColorHilite +';visibility:hidden;">'+ item +'</DIV>';        if (item == "separator") {//            content += ( dTag + '<DIV ID="menuSeparator'+ id +'" STYLE="position:absolute;left:1;top:2;"></DIV><DIV ID="menuSeparatorLite'+ id +'" STYLE="position:absolute;left:1;top:3;"></DIV></DIV>');            content += ( dTag + '<DIV ID="menuSeparator'+ id +'" STYLE="position:absolute;left:1;top:'+(h4-1)+';width:'+proto.menuWidth+';height:1;"></DIV>'+								'<DIV ID="menuSeparatorLite'+ id +'" STYLE="position:absolute;left:1;top:'+(h4)+';width:'+proto.menuWidth+';height:1;"></DIV></DIV>');        } else if (childMenu) {            content += ( dTag + dText + '<DIV ID="childMenu'+ id +'" STYLE="position:absolute;left:0;top:3;'+ itemProps +'"><IMG SRC="'+ proto.childMenuIcon +'"></DIV></DIV>');        } else {            content += ( dTag + dText + '</DIV>');        }    }    content += '<DIV ID="focusItem'+ index +'" STYLE="position:absolute;left:0;top:0;visibility:hide;" onClick="onMenuItemAction(null,this);">&nbsp;</DIV>';    content += '</DIV></DIV></DIV>\n\n';	return content;}function setMenuProperty(container, index) {    var proto = null;	var x = index;    if (document.layers) {        proto = container.menus[x].prototypeStyles || this.prototypeStyles || container.menus[x];        var menu = container.document.layers[x];        container.menus[x].menuLayer = menu;        container.menus[x].menuLayer.Menu = container.menus[x];        container.menus[x].menuLayer.Menu.container = container;        var body = menu.document.layers[0].document.layers[0];        body.clip.width = proto.menuWidth || body.clip.width;        body.clip.height = proto.menuHeight || body.clip.height;        for (var i=0; i<body.document.layers.length-1; i++) {            var l = body.document.layers[i];            l.Menu = container.menus[x];            l.menuHiliteBgColor = proto.menuHiliteBgColor;            l.document.bgColor = proto.menuItemBgColor;            l.saveColor = proto.menuItemBgColor;            l.mouseout  = l.Menu.mouseouts[i];            l.mouseover = l.Menu.mouseovers[i];            l.onmouseover = proto.onMenuItemOver;            l.onclick = proto.onMenuItemAction;            l.action = container.menus[x].actions[i];            l.focusItem = body.document.layers[body.document.layers.length-1];            l.clip.width = proto.menuItemWidth || body.clip.width + proto.menuItemIndent;            l.clip.height = proto.menuItemHeight || l.clip.height;            if ( i>0 ) l.top = body.document.layers[i-1].top + body.document.layers[i-1].clip.height + proto.menuItemBorder;            l.hilite = l.document.layers[1];            l.document.layers[1].isHilite = true;            if (l.document.layers[0].id.indexOf("menuSeparator") != -1) {                l.hilite = null;                l.clip.height -= l.clip.height / 2;                l.document.layers[0].document.bgColor = proto.bgColor;                l.document.layers[0].clip.width = l.clip.width -2;                l.document.layers[0].clip.height = 1;                l.document.layers[1].document.bgColor = proto.menuLiteBgColor;                l.document.layers[1].clip.width = l.clip.width -2;                l.document.layers[1].clip.height = 1;                l.document.layers[1].top = l.document.layers[0].top + 1;            } else if (l.document.layers.length > 2) {                l.childMenu = container.menus[x].items[i].menuLayer;                l.icon = proto.childMenuIcon;                l.iconHilite = proto.childMenuIconHilite;                l.document.layers[2].left = l.clip.width -13;                l.document.layers[2].top = (l.clip.height / 2) -4;                l.document.layers[2].clip.left += 3;                l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;            }        }        body.document.bgColor = proto.bgColor;        body.clip.width  = l.clip.width +1;        body.clip.height = l.top + l.clip.height +1;        body.document.layers[i].clip.width = body.clip.width;        body.document.layers[i].captureEvents(Event.MOUSEDOWN);        body.document.layers[i].onmousedown = proto.onMenuItemDown;        body.document.layers[i].onmouseout = proto.onMenuItemOut;        body.document.layers[i].Menu = l.Menu;        body.document.layers[i].top = -30;        menu.document.bgColor = proto.menuBorderBgColor;        menu.document.layers[0].document.bgColor = proto.menuLiteBgColor;        menu.document.layers[0].clip.width = body.clip.width +1;        menu.document.layers[0].clip.height = body.clip.height +1;        menu.clip.width = body.clip.width + (proto.menuBorder * 2) +1;        menu.clip.height = body.clip.height + (proto.menuBorder * 2) +1;        if (menu.Menu.enableTracker) {            menu.Menu.disableHide = true;            setMenuTracker(menu.Menu);        }      } else if (document.all) {        var menu = container.document.all("menuLayer" + x);        container.menus[x].menuLayer = menu;        container.menus[x].menuLayer.Menu = container.menus[x];        container.menus[x].menuLayer.Menu.container = menu;        proto = container.menus[x].prototypeStyles || this.prototypeStyles || container.menus[x];        proto.menuItemWidth = proto.menuItemWidth || 200;        menu.style.backgroundColor = proto.menuBorderBgColor;        for (var i=0; i<container.menus[x].items.length; i++) {			var id = getMenuItemID(x,i);            var l  = container.document.all["menuItem" + id];            l.Menu = container.menus[x];            proto = container.menus[x].prototypeStyles || this.prototypeStyles || container.menus[x];            l.style.pixelWidth = proto.menuItemWidth;            l.style.pixelHeight = proto.menuItemHeight;            if (i>0) l.style.pixelTop = container.document.all["menuItem" + (id-1)].style.pixelTop + container.document.all["menuItem" + (id-1)].style.pixelHeight + proto.menuItemBorder;            l.style.fontSize = proto.fontSize;            l.style.backgroundColor = proto.menuItemBgColor;            l.style.visibility = "inherit";            l.saveColor = proto.menuItemBgColor;            l.menuHiliteBgColor = proto.menuHiliteBgColor;            l.action = container.menus[x].actions[i];            l.hilite = container.document.all["menuItemHilite" + id];            l.focusItem = container.document.all["focusItem" + x];            l.focusItem.style.pixelTop = -30;            l.mouseover = l.Menu.mouseovers[x];            l.mouseout  = l.Menu.mouseouts[x];            var childItem = container.document.all["childMenu" + id];            if (childItem) {                l.childMenu = container.menus[x].items[i].menuLayer;                childItem.style.pixelLeft = l.style.pixelWidth -11;                childItem.style.pixelTop = (l.style.pixelHeight /2) -4;                childItem.style.pixelWidth = 30 || 7;                childItem.style.clip = "rect(0 7 7 3)";                l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;            }            var sep = container.document.all["menuSeparator" + id];            if (sep) {                sep.style.clip = "rect(0 " + (proto.menuItemWidth - 3) + " 1 0)";                sep.style.backgroundColor = proto.bgColor;                sep = container.document.all["menuSeparatorLite" + id];                sep.style.clip = "rect(1 " + (proto.menuItemWidth - 3) + " 2 0)";                sep.style.backgroundColor = proto.menuLiteBgColor;                l.style.pixelHeight = proto.menuItemHeight/2;                l.isSeparator = true            }        }        proto.menuHeight = (l.style.pixelTop + l.style.pixelHeight);        var lite = container.document.all["menuLite" + x];        lite.style.pixelHeight = proto.menuHeight +2;        lite.style.pixelWidth = proto.menuItemWidth + 2;        lite.style.backgroundColor = proto.menuLiteBgColor;        var body = container.document.all["menuFg" + x];        body.style.pixelHeight = proto.menuHeight + 1;        body.style.pixelWidth = proto.menuItemWidth + 1;        body.style.backgroundColor = proto.bgColor;        container.menus[x].menuLayer.style.pixelWidth  = proto.menuWidth || proto.menuItemWidth + (proto.menuBorder * 2) +2;        container.menus[x].menuLayer.style.pixelHeight = proto.menuHeight + (proto.menuBorder * 2) +2;        if (menu.Menu.enableTracker) {            menu.Menu.disableHide = true;            setMenuTracker(menu.Menu);        }    } else if (document.getElementById) {        var menu = document.getElementById("menuLayer" + x);        container.menus[x].menuLayer = menu;        container.menus[x].menuLayer.Menu = container.menus[x];        container.menus[x].menuLayer.Menu.container = menu;        proto = container.menus[x].prototypeStyles || this.prototypeStyles || container.menus[x];        proto.menuItemWidth = proto.menuItemWidth || 200;        menu.style.backgroundColor = proto.menuBorderBgColor;        for (var i=0; i<container.menus[x].items.length; i++) {	        var id = getMenuItemID(x,i);            var l = document.getElementById("menuItem" + id);            l.Menu = container.menus[x];            proto = container.menus[x].prototypeStyles || this.prototypeStyles || container.menus[x];            l.style.width = proto.menuItemWidth;            l.style.height = proto.menuItemHeight;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -