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

📄 menu.ie.js

📁 Bindows 1.01 完全版 Bindows 框架提供给你: 基于类的面向对象 API; 一个完整的窗口系统
💻 JS
📖 第 1 页 / 共 5 页
字号:
        {            if (items[i].mnemonic == c)            {                items[i].dispatchAction();                break;            }        }    }    oEvent.returnValue = false;    oEvent.keyCode = 0;};Menu.prototype._startClosePoll = function(){    var oThis = this;    window.clearInterval(this._onCloseInterval);    this._onCloseInterval = window.setInterval("eventListeners.menu.oncloseinterval(\"" + this.id + "\")", 100);};Menu.prototype._checkCloseState = function(){    var closed = this.popup == null || !this.popup.isOpen;    if (closed && this._closed != closed)    {        this._closed = closed;        this._closedAt = new Date().valueOf();        window.clearInterval(this._onCloseInterval);        if (typeof this._onclose == "function")        {            var e = this.getDocument().parentWindow.event;            if (e != null && e.keyCode == 27)                this._closeReason = "escape";            else                this._closeReason = "unknown";            this._onclose();        }        if (typeof this.onclose == "function")            this.onclose();    }};Menu.prototype._isCssFileLoaded = function(){    if (this.cssText != null)        return true;    var d = this.getMeasureDocument();    var l = d.getElementsByTagName("LINK")[0];    return l.readyState == "complete";};Menu.prototype.destroy = function(){    var l = this.items.length;    for (var i = l - 1; i >= 0; i--)        this.items[i].destroy();    this.detachEvents();    this.items = [];    this.parentMenu = null;    this.parentMenuItem = null;    this.shownSubMenu = null;    this._cachedSizes = null;    this.eventListeners = null;    if (this.popup != null)    {        var d = this.popup.document;        d.open("text/plain", "replace");        d.write("");        d.close();        this.popup = null;    }    if (Menu._measureMenu == this)    {        Menu._measureMenu = null;        var d = Menu._measureFrame.contentWindow.document;        d.open("text/plain", "replace");        d.write("");        d.close();        Menu._measureFrame.parentNode.removeChild(Menu._measureFrame);        Menu._measureFrame = null;    }    menuCache.remove(this);};function MenuItem(sLabelText, fAction, sIconSrc, oSubMenu){    this.icon = sIconSrc || "";    this.text = sLabelText;    this.action = fAction;    this.subMenu = oSubMenu;    this.parentMenu = null;    this._selected = false;    this._useInsets = true;    this.id = menuCache.getId();    menuCache[this.id] = this;}MenuItem.prototype.subMenuDirection = "horizontal";MenuItem.prototype.disabled = false;MenuItem.prototype.mnemonic = null;MenuItem.prototype.shortcut = null;MenuItem.prototype.toolTip = "";MenuItem.prototype.target = null;MenuItem.prototype.visible = true;MenuItem.prototype.toHtml = function(){    var cssClass = this.getCssClass();    var toolTip = this.getToolTip();    return "<tr"+(cssClass!=""?" class=\""+cssClass+"\"":"")+(toolTip!=""?" title=\""+toolTip+"\"":"")+(!this.visible?" style=\"display: none\"":"")+">" + this.getIconCellHtml() + this.getTextCellHtml() + this.getShortcutCellHtml() + this.getSubMenuArrowCellHtml()        + "</tr>";};MenuItem.prototype.getTextHtml = function(){    var s = this.text;    if (!s || !this.mnemonic)        return s;    var re = new RegExp("^(((<([^>]|" + this.mnemonic + ")+>)|[^<" + this.mnemonic + "])*)(" + this.mnemonic + ")",                        "i");    re.exec(s);    if (RegExp.index != -1 && RegExp.$5 != "")        return RegExp.$1 + "<u>" + RegExp.$5 + "</u>" + RegExp.rightContext;    else        return s;};MenuItem.prototype.getIconHtml = function(){    return this.icon != "" ? "<img src=\""+this.icon+"\">" : "<span>&nbsp;</span>";} ;MenuItem.prototype.getTextCellHtml = function(){    return "<td class=\"label-cell\" nowrap=\"nowrap\">" + this.makeDisabledContainer(this.getTextHtml()) + "</td>";} ;MenuItem.prototype.getIconCellHtml = function(){    return "<td class=\""+(this.icon!=""?"icon-cell":"empty-icon-cell")+"\">" + this.makeDisabledContainer(                                                                                    this.getIconHtml()) + "</td>";} ;MenuItem.prototype.getCssClass = function(){    if (this.disabled && this._selected)        return "disabled-hover";    else if (this.disabled)        return "disabled";    else if (this._selected)        return "hover";    return "";};MenuItem.prototype.getToolTip = function(){    return this.toolTip;} ;MenuItem.prototype.getShortcutHtml = function(){    if (this.shortcut == null)        return "&nbsp;";    return this.shortcut;};MenuItem.prototype.getShortcutCellHtml = function(){    return "<td class=\"shortcut-cell\" nowrap=\"nowrap\">" + this.makeDisabledContainer(                                                                  this.getShortcutHtml()) + "</td>";} ;MenuItem.prototype.getSubMenuArrowHtml = function(){    if (this.subMenu == null)        return "&nbsp;";    return 4;};MenuItem.prototype.getSubMenuArrowCellHtml = function(){    return "<td class=\"arrow-cell\">" + this.makeDisabledContainer(this.getSubMenuArrowHtml()) + "</td>";} ;MenuItem.prototype.makeDisabledContainer = function(s){    if (this.disabled)        return "<span class=\"disabled-container\"><span class=\"disabled-container\">" + s + "</span></span>";    return s;};MenuItem.prototype.dispatchAction = function(){    if (this.disabled)        return;    this.setSelected(true);    if (this.subMenu)    {        if (!this.subMenu.isShown())            this.showSubMenu(false);        return;    }    if (typeof this.action == "function")    {        this.setSelected(false);        this.parentMenu.closeAllMenus();        this.action();    }    else if (typeof this.action == "string")    {        this.setSelected(false);        this.parentMenu.closeAllMenus();        if (this.target != null)            window.open(this.action, this.target);        else            document.location.href = this.action;    }};MenuItem.prototype.setSelected = function(bSelected){    if (this._selected == bSelected)        return;    this._selected = Boolean(bSelected);    var tr = this._htmlElement;    if (tr)        tr.className = this.getCssClass();    if (!this._selected)        this.closeSubMenu(true);    var pm = this.parentMenu;    if (bSelected)    {        pm.setSelectedIndex(this.itemIndex);        this.scrollIntoView();        if (pm.parentMenuItem)            pm.parentMenuItem.setSelected(true);    }    else        pm.setSelectedIndex(-1);    if (this._selected)    {        window.clearTimeout(pm._closeTimer);    }};MenuItem.prototype.getSelected = function(){    return this.itemIndex == this.parentMenu.selectedIndex;} ;MenuItem.prototype.showSubMenu = function(bDelayed){    var sm = this.subMenu;    var pm = this.parentMenu;    if (sm && !this.disabled)    {        pm._aboutToShowSubMenu = true;        window.clearTimeout(sm._showTimer);        window.clearTimeout(sm._closeTimer);        var showTimeout = bDelayed ? sm.showTimeout : 0;        var oThis = this;        sm._showTimer = window.setTimeout("eventListeners.menuItem.onshowtimer(\"" + this.id + "\")", showTimeout);    }};MenuItem.prototype.closeSubMenu = function(bDelay){    var sm = this.subMenu;    if (sm)    {        window.clearTimeout(sm._showTimer);        window.clearTimeout(sm._closeTimer);        if (sm.popup)        {            if (!bDelay)                sm.close();            else            {                var oThis = this;                sm._closeTimer = window.setTimeout("eventListeners.menuItem.onclosetimer(\"" + this.id + "\")",                                                   sm.closeTimeout);            }        }    }};MenuItem.prototype.scrollIntoView = function(){    if (this.parentMenu._scrollingMode)    {        var d = this.parentMenu.getDocument();        var sc = d.getElementById("scroll-container");        var scrollTop = sc.scrollTop;        var clientHeight = sc.clientHeight;        var offsetTop = this._htmlElement.offsetTop;        var offsetHeight = this._htmlElement.offsetHeight;        if (offsetTop < scrollTop)            sc.scrollTop = offsetTop;        else if (offsetTop + offsetHeight > scrollTop + clientHeight)            sc.scrollTop = offsetTop + offsetHeight - clientHeight;    }};MenuItem.prototype.positionSubMenu = function(){    var dir = this.subMenuDirection;    var el = this._htmlElement;    var useInsets = this._useInsets;    var sm = this.subMenu;    var oThis = this;    if (!sm._isCssFileLoaded())    {        window.setTimeout("eventListeners.menuItem.onpositionsubmenutimer(\"" + this.id + "\")", 1);        return;    }    var rect = {        left: posLib.getScreenLeft(el), top: posLib.getScreenTop(el), width: el.offsetWidth, height: el.offsetHeight    };    var menuRect = {        left: sm.getLeft(),                           top: sm.getTop(),        width: sm.getPreferredWidth(),                height: sm.getPreferredHeight(),        insetLeft: useInsets ? sm.getInsetLeft() : 0, insetRight: useInsets ? sm.getInsetRight() : 0,        insetTop: useInsets ? sm.getInsetTop() : 0,   insetBottom: useInsets ? sm.getInsetBottom() : 0    };    var screenWidth = screen.width;    var screenHeight = screen.height;    while (rect.left > screenWidth)        screenWidth += screen.width;    while (rect.top > screenHeight)        screenHeight += screen.height;    var left, top, width = menuRect.width, height = menuRect.height;    if (dir == "vertical")    {        if (rect.left + menuRect.width - menuRect.insetLeft <= screenWidth)            left = rect.left - menuRect.insetLeft;        else if (screenWidth >= menuRect.width)            left = screenWidth - menuRect.width;        else            left = 0;        if (rect.top + rect.height + menuRect.height - menuRect.insetTop <= screenHeight)            top = rect.top + rect.height - menuRect.insetTop;        else if (rect.top - menuRect.height + menuRect.insetBottom >= 0)            top = rect.top - menuRect.height + menuRect.insetBottom;        else        {            var sizeAbove = rect.top + menuRect.insetBottom;            var sizeBelow = screenHeight - rect.top - rect.height + menuRect.insetTop;            if (sizeBelow >= sizeAbove)            {                top = rect.top + rect.height - menuRect.insetTop;                height = sizeBelow;            }            else            {                top = 0;                height = sizeAbove;            }        }    }    else    {        if (rect.top + menuRect.height - menuRect.insetTop <= screenHeight)            top = rect.top - menuRect.insetTop;        else if (rect.top + rect.height - menuRect.height + menuRect.insetBottom >= 0)            top = rect.top + rect.height - menuRect.height + menuRect.insetBottom;        else if (screenHeight >= menuRect.height)            top = screenHeight - menuRect.height;        else        {            top = 0;            height = screenHeight        }        if (rect.left + rect.width + menuRect.width - menuRect.insetLeft <= screenWidth)            left = rect.left + rect.width - menuRect.insetLeft;        else if (rect.left - menuRect.width + menuRect.insetRight >= 0)            left = rect.left - menuRect.width + menuRect.insetRight;        else if (screenWidth >= menuRect.width)            left = screenWidth - menuRect.width;        else            left = 0;    }    var scrollBefore = sm._scrollingMode;    sm.show(left, top, width, height);    if (sm._scrollingMode != scrollBefore)        this.positionSubMenu();};MenuItem.prototype.destroy = function(){    if (this.subMenu != null)        this.subMenu.destroy();    this.subMenu = null;    this.parentMenu = null;    var el = this._htmlElement    if (el != null)        el._menuItem = null;    this._htmlElement = null;    menuCache.remove(this);};function CheckBoxMenuItem(sLabelText, bChecked, fAction, oSubMenu){    this.MenuItem = MenuItem;    this.MenuItem(sLabelText, fAction, null, oSubMenu);    this.checked = bChecked;}CheckBoxMenuItem.prototype = new MenuItem;CheckBoxMenuItem.prototype.getIconHtml = function(){    return "<span class=\"check-box\">" + (this.checked ? "a" : "&nbsp;") + "</span>";} ;CheckBoxMenuItem.prototype.getIconCellHtml = function(){    return "<td class=\"icon-cell\">" + this.makeDisabledContainer(this.getIconHtml()) + "</td>";} ;CheckBoxMenuItem.prototype.getCssClass = function(){    var s = (this.checked ? " checked" : "");    if (this.disabled && this._selected)        return "disabled-hover" + s;    else if (this.disabled)        return "disabled" + s;    else if (this._selected)        return "hover" + s;    return s;};CheckBoxMenuItem.prototype._menuItem_dispatchAction = MenuItem.prototype.dispatchAction;CheckBoxMenuItem.prototype.dispatchAction = function(){    if (!this.disabled)    {        this.checked = !this.checked;        this._menuItem_dispatchAction();        this.parentMenu.invalidate();        this.parentMenu.closeAllMenus();    }

⌨️ 快捷键说明

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