欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

BBS(php & mysql)完整版(六)

程序员文章站 2022-08-11 15:56:35
+proto.menuborder;            &...
+proto.menuborder;
            var focusitem = body.document.layers[n];
            focusitem.clip.width = body.clip.width;
            focusitem.menu = l.menu;
            focusitem.top = -30;
            focusitem.captureevents(event.mousedown);
            focusitem.onmousedown = onmenuitemdown;
            menu.document.bgcolor = proto.menuborderbgcolor;
            var lite = menu.document.layers[0];
            lite.document.bgcolor = proto.menulitebgcolor;
            lite.clip.width = body.clip.width +1;
            lite.clip.height = body.clip.height +1;
            menu.clip.width = body.clip.width + (proto.menuborder * 3) ;
            menu.clip.height = body.clip.height + (proto.menuborder * 3);
        }
    } else {
        if ((!document.all) && (container.haschildnodes)) {
            container.innerhtml=content;
        } else {
            container.document.open("text/html");
            container.document.writeln(content);
            container.document.close();     
        }
        if (!find("menulayer0")) return;
        var menucount = 0;
        for (var x=0; x<container.menus.length; x++) {
            var menulayer = find("menulayer" + x);
            container.menus[x].menulayer = "menulayer" + x;
            menulayer.menu = container.menus[x];
            menulayer.menu.container = "menulayer" + x;
            menulayer.style.zindex = 1;
            var s = menulayer.style;
            s.top = s.pixeltop = -300;
            s.left = s.pixelleft = -300;

            var menu = container.menus[x];
            menu.menuitemwidth = menu.menuwidth || menu.menuiewidth || 140;
            menulayer.style.backgroundcolor = menu.menuborderbgcolor;
            var top = 0;
            for (var i=0; i<container.menus[x].items.length; i++) {
                var l = find("menuitem" + menucount);
                l.menu = container.menus[x];
                if (l.addeventlistener) { // ns6
                    l.style.width = menu.menuitemwidth;     
                    l.style.height = menu.menuitemheight;
                    l.style.top = top;
                    l.addeventlistener("mouseover", onmenuitemover, false);
                    l.addeventlistener("click", onmenuitemaction, false);
                    l.addeventlistener("mouseout", mouseoutmenu, false);
                } else { //ie
                    l.style.pixelwidth = menu.menuitemwidth;     
                    l.style.pixelheight = menu.menuitemheight;
                    l.style.pixeltop = top;
                }
                top = top + menu.menuitemheight+menu.menuitemborder;
                l.style.fontsize = menu.fontsize;
                l.style.backgroundcolor = menu.menuitembgcolor;
                l.style.visibility = "inherit";
                l.savecolor = menu.menuitembgcolor;
                l.menuhilitebgcolor = menu.menuhilitebgcolor;
                l.action = container.menus[x].actions[i];
                l.hilite = find("menuitemhilite" + menucount);
                l.focusitem = find("focusitem" + x);
                l.focusitem.style.pixeltop = l.focusitem.style.top = -30;
                var childitem = find("childmenu" + menucount);
                if (childitem) {
                    l.childmenu = container.menus[x].items[i].menulayer;
                    childitem.style.pixelleft = childitem.style.left = menu.menuitemwidth -11;
                    childitem.style.pixeltop = childitem.style.top =(menu.menuitemheight /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 = find("menuseparator" + menucount);
                if (sep) {
                    sep.style.clip = "rect(0 " + (menu.menuitemwidth - 3) + " 1 0)";
                    sep.style.width = sep.style.pixelwidth = menu.menuitemwidth;     
                    sep.style.backgroundcolor = menu.bgcolor;
                    sep = find("menuseparatorlite" + menucount);
                    sep.style.clip = "rect(1 " + (menu.menuitemwidth - 3) + " 2 0)";
                    sep.style.width = sep.style.pixelwidth = menu.menuitemwidth;     
                    sep.style.backgroundcolor = menu.menulitebgcolor;
                    l.style.height = l.style.pixelheight = menu.menuitemheight/2;
                    l.isseparator = true
                    top -= (menu.menuitemheight - l.style.pixelheight)
                } else {
                    l.style.cursor = "hand"
                }
                menucount++;
            }
            menu.menuheight = top-1;
            var lite = find("menulite" + x);
            var s = lite.style;
            s.height = s.pixelheight = menu.menuheight +(menu.menuborder * 2);
            s.width = s.pixelwidth = menu.menuitemwidth + (menu.menuborder * 2);
            s.backgroundcolor = menu.menulitebgcolor;

            var body = find("menufg" + x);
            s = body.style;
            s.height = s.pixelheight = menu.menuheight + menu.menuborder;
            s.width = s.pixelwidth = menu.menuitemwidth + menu.menuborder;
            s.backgroundcolor = menu.bgcolor;

            s = menulayer.style;
            s.width = s.pixelwidth  = menu.menuitemwidth + (menu.menuborder * 4);
            s.height = s.pixelheight  = menu.menuheight+(menu.menuborder*4);
        }
    }
    if (document.captureevents) {     
        document.captureevents(event.mouseup);
    }
    if (document.addeventlistener) {     
        document.addeventlistener("mouseup", onmenuitemover, false);
    }
    if (document.layers && window.innerwidth) {
        window.onresize = ns4resize;
        window.ns4siw = window.innerwidth;
        window.ns4sih = window.innerheight;
    }
    document.onmouseup = mouseupmenu;
    window.fwwrotemenu = true;
    status = "";
}

function ns4resize() {
    if (ns4siw < window.innerwidth ||  
        ns4siw > window.innerwidth ||  
        ns4sih > window.innerheight ||  
        ns4sih < window.innerheight )  
    {
        window.location.reload();
    }
}

function onmenuitemover(e, l) {
    fw_cleartimeout();
    l = l || this;
    a = window.activemenuitem;
    if (document.layers) {
        if (a) {
            a.document.bgcolor = a.savecolor;
            if (a.hilite) a.hilite.visibility = "hidden";
            if (a.menu.bgimageover) {
                a.background.src = a.menu.bgimageup;
            }
            a.focusitem.top = -100;
            a.clicked = false;
        }
        if (l.hilite) {
            l.document.bgcolor = l.menuhilitebgcolor;
            l.zindex = 1;
            l.hilite.visibility = "inherit";
            l.hilite.zindex = 2;
            l.document.layers[1].zindex = 1;
            l.focusitem.zindex = this.zindex +2;
        }
        if (l.menu.bgimageover) {
            l.background.src = l.menu.bgimageover;
        }
        l.focusitem.top = this.top;
        l.menu.hidechildmenu(l);
    } else if (l.style && l.menu) {
        if (a) {
            a.style.backgroundcolor = a.savecolor;
            if (a.hilite) a.hilite.style.visibility = "hidden";
            if (a.menu.bgimageup) {
                a.style.background = "url(" + a.menu.bgimageup +")";;
            }
        }  
        if (l.isseparator) return;
        l.style.backgroundcolor = l.menuhilitebgcolor;
        l.zindex = 1;  // magic ie 4.5 mac happy doohicky.    jba
        if (l.menu.bgimageover) {
            l.style.background = "url(" + l.menu.bgimageover +")";
        }
        if (l.hilite) {
            l.style.backgroundcolor = l.menuhilitebgcolor;
            l.hilite.style.visibility = "inherit";
        }
        l.focusitem.style.top = l.focusitem.style.pixeltop = l.style.pixeltop;
        l.focusitem.style.zindex = l.zindex +1;
        l.menu.hidechildmenu(l);
    } else {
        return; // not a menu - magic ie 4.5 mac happy doohicky.  jba
    }
    window.activemenuitem = l;
}

function onmenuitemaction(e, l) {
    l = window.activemenuitem;
    if (!l) return;
    hideactivemenus();
    if (l.action) {
        eval("" + l.action);
    }
    window.activemenuitem = 0;
}

function fw_cleartimeout()
{
    if (fwhidemenutimer) cleartimeout(fwhidemenutimer);
    fwhidemenutimer = null;
    fwdhflag = false;
}
function fw_starttimeout()
{
    fwstart = new date();
    fwdhflag = true;
    fwhidemenutimer = settimeout("fwdohide()", 1000);
}

function fwdohide()
{
    if (!fwdhflag) return;
    var elapsed = new date() - fwstart;
    if (elapsed < 1000) {
        fwhidemenutimer = settimeout("fwdohide()", 1100-elapsed);
        return;
    }
    fwdhflag = false;
    hideactivemenus();
    window.activemenuitem = 0;
}

function fw_showmenu(menu, x, y, child) {
    if (!window.fwwrotemenu) return;
    fw_cleartimeout();
    if (document.layers) {
        if (menu) {
            var l = menu.menulayer || menu;
            l.left = 1;
            l.top = 1;
            hideactivemenus();
            if (this.visibility) l = this;
            window.activemenu = l;
        } else {
            var l = child;
        }
        if (!l) return;
        for (var i=0; i<l.layers.length; i++) {                 
            if (!l.layers[i].ishilite)  
                l.layers[i].visibility = "inherit";
            if (l.layers[i].document.layers.length > 0)  
                fw_showmenu(null, "relative", "relative", l.layers[i]);
        }
        if (l.parentlayer) {
            if (x != "relative")  
                l.parentlayer.left = x || window.pagex || 0;
            if (l.parentlayer.left + l.clip.width > window.innerwidth)  
                l.parentlayer.left -= (l.parentlayer.left + l.clip.width - window.innerwidth);
            if (y != "relative")  
                l.parentlayer.top = y || window.pagey || 0;
            if (l.parentlayer.iscontainer) {
                l.menu.xoffset = window.pagexoffset;
                l.menu.yoffset = window.pageyoffset;
                l.parentlayer.clip.width = window.activemenu.clip.width +2;
                l.parentlayer.clip.height = window.activemenu.clip.height +2;
                if (l.parentlayer.menucontainerbgcolor) l.parentlayer.document.bgcolor = l.parentlayer.menucontainerbgcolor;
            }
        }
        l.visibility = "inherit";
        if (l.menu) l.menu.container.visibility = "inherit";
    } else if (find("menuitem0")) {
        var l = menu.menulayer || menu;     
        hideactivemenus();
        if (typeof(l) == "string") {
            l = find(l);
        }
        window.activemenu = l;
        var s = l.style;
        s.visibility = "inherit";
        if (x != "relative")  
            s.left = s.pixelleft = x || (window.pagex + document.body.scrollleft) || 0;
        if (y != "relative")  
            s.top = s.pixeltop = y || (window.pagey + document.body.scrolltop) || 0;
        l.menu.xoffset = document.body.scrollleft;
        l.menu.yoffset = document.body.scrolltop;
    }
    if (menu) {
        window.activemenus[window.activemenus.length] = l;
    }
}

function onmenuitemdown(e, l) {
    var a = window.activemenuitem;
    if (document.layers) {
        if (a) {
            a.ex = e.pagex;
            a.ey = e.pagey;
            a.clicked = true;
        }
    }
}

function mouseupmenu(e)
{
    hidemenu(true, e);
    hideactivemenus();
    return true;
}

function mouseoutmenu()
{
    hidemenu(false, false);
    return true;
}


function hidemenu(mouseup, e) {
    var a = window.activemenuitem;
    if (a && document.layers) {
        a.document.bgcolor = a.savecolor;
        a.focusitem.top = -30;
        if (a.hilite) a.hilite.visibility = "hidden";
        if (mouseup && a.action && a.clicked && window.activemenu) {
             if (a.ex <= e.pagex+15 && a.ex >= e.pagex-15 && a.ey <= e.pagey+10 && a.ey >= e.pagey-10) {
                settimeout('window.activemenu.menu.onmenuitemaction();', 2);
            }
        }
        a.clicked = false;
        if (a.menu.bgimageover) {
            a.background.src = a.menu.bgimageup;
        }
    } else if (window.activemenu && find("menuitem0")) {
        if (a) {
            a.style.backgroundcolor = a.savecolor;
            if (a.hilite) a.hilite.style.visibility = "hidden";
            if (a.menu.bgimageup) {
                a.style.background = "url(" + a.menu.bgimageup +")";;
            }
        }
    }
    if (!mouseup && window.activemenu) {
        if (window.activemenu.menu) {
            if (window.activemenu.menu.hideonmouseout) {
                fw_starttimeout();
            }
            return(true);
        }
    }
    return(true);
}

function pxtonum(pxstr)
{ // pxstr == 27px, we want 27.
    if (pxstr.length > 2) {
        n = number(pxstr.substr(0, pxstr.length-2));
        return(n);
    }
    return(0);
}

function hidechildmenu(hcmlayer) {
    fw_cleartimeout();
    var l = hcmlayer;
    for (var i=0; i < l.menu.childmenus.length; i++) {
        var thelayer = l.menu.childmenus[i];
        if (document.layers) {
            thelayer.visibility = "hidden";
        } else {
            thelayer = find(thelayer);
            thelayer.style.visibility = "hidden";
        }
        thelayer.menu.hidechildmenu(thelayer);
    }

    if (l.childmenu) {
        var childmenu = l.childmenu;
        if (document.layers) {
            l.menu.fw_showmenu(null,null,null,childmenu.layers[0]);
            childmenu.zindex = l.parentlayer.zindex +1;
            childmenu.top = l.top + l.parentlayer.top + l.menu.menulayer.top + l.menu.menuitemheight/3;
            if (childmenu.left + childmenu.clip.width > window.innerwidth) {
                childmenu.left = l.parentlayer.left - childmenu.clip.width + l.menu.menulayer.left + 15;
                l.menu.container.clip.left -= childmenu.clip.width;
            } else {
                childmenu.left = l.parentlayer.left + l.parentlayer.clip.width  + l.menu.menulayer.left -5;
            }
            var w = childmenu.clip.width+childmenu.left-l.menu.container.clip.left;
            if (w > l.menu.container.clip.width)   
                l.menu.container.clip.width = w;
            var h = childmenu.clip.height+childmenu.top-l.menu.container.clip.top;
            if (h > l.menu.container.clip.height) l.menu.container.clip.height = h;
            l.document.layers[1].zindex = 0;
            childmenu.visibility = "inherit";
        } else if (find("menuitem0")) {
            childmenu = find(l.childmenu);
            var menulayer = find(l.menu.menulayer);
            var s = childmenu.style;
            s.zindex = menulayer.style.zindex+1;
            if (document.all) { // ie case.
                s.pixeltop = l.style.pixeltop + menulayer.style.pixeltop + l.menu.menuitemheight/3;
                s.left = s.pixelleft = (menulayer.style.pixelwidth) + menulayer.style.pixelleft -5;
            } else { // zilla case
                var top = pxtonum(l.style.top) + pxtonum(menulayer.style.top) + l.menu.menuitemheight/3;
                var left = (pxtonum(menulayer.style.width)) + pxtonum(menulayer.style.left) -5;
                s.top = top;
                s.left = left;
            }
            childmenu.style.visibility = "inherit";
        } else {
            return;
        }
        window.activemenus[window.activemenus.length] = childmenu;
    }
}

function hideactivemenus() {
    if (!window.activemenus) return;
    for (var i=0; i < window.activemenus.length; i++) {
        if (!activemenus[i]) continue;
        if (activemenus[i].visibility && activemenus[i].menu) {
            activemenus[i].visibility = "hidden";
            activemenus[i].menu.container.visibility = "hidden";
            activemenus[i].menu.container.clip.left = 0;
        } else if (activemenus[i].style) {
            var s = activemenus[i].style;
            s.visibility = "hidden";
            s.left = -200;
            s.top = -200;
        }
    }
    if (window.activemenuitem) {
        hidemenu(false, false);
    }
    window.activemenus.length = 0;