📄 menu.ie.js
字号:
/* * Bindows 1.01 * http://www.bindows.net/ * Copyright (c) 2003-2004 MB Technologies * * Bindows(tm) belongs to MB Technologies (Georgia, USA). All rights reserved. * You are not allowed to copy or modify this code. Commercial use requires * license. */var posLib = { getIeBox: function(el){ return this.ie && el.document.compatMode != "CSS1Compat";} , getClientLeft: function(el){ var r = el.getBoundingClientRect(); return r.left - this.getBorderLeftWidth(this.getCanvasElement(el));}, getClientTop: function(el){ var r = el.getBoundingClientRect(); return r.top - this.getBorderTopWidth(this.getCanvasElement(el));}, getLeft: function(el){ return this.getClientLeft(el) + this.getCanvasElement(el).scrollLeft;} , getTop: function(el){ return this.getClientTop(el) + this.getCanvasElement(el).scrollTop;} , getInnerLeft: function(el){ return this.getLeft(el) + this.getBorderLeftWidth(el);} , getInnerTop: function(el){ return this.getTop(el) + this.getBorderTopWidth(el);} , getWidth: function(el){ return el.offsetWidth;} , getHeight: function(el){ return el.offsetHeight;} , getCanvasElement: function(el){ var doc = el.ownerDocument || el.document; if (doc.compatMode == "CSS1Compat") return doc.documentElement; else return doc.body;}, getBorderLeftWidth: function(el){ return el.clientLeft;} , getBorderTopWidth: function(el){ return el.clientTop;} , getScreenLeft: function(el){ var doc = el.ownerDocument || el.document; var w = doc.parentWindow; return w.screenLeft + this.getBorderLeftWidth(this.getCanvasElement(el)) + this.getClientLeft(el);}, getScreenTop: function(el){ var doc = el.ownerDocument || el.document; var w = doc.parentWindow; return w.screenTop + this.getBorderTopWidth(this.getCanvasElement(el)) + this.getClientTop(el);}};posLib.ua = navigator.userAgent;posLib.opera = /opera[56789]|opera\/[56789]/i.test(posLib.ua);posLib.ie = (!posLib.opera) && (/MSIE/.test(posLib.ua));posLib.ie6 = posLib.ie && (/MSIE[6789]/.test(posLib.ua));posLib.moz = !posLib.opera && (/gecko/i.test(posLib.ua));var scrollButtonCache = { _count: 0, _idPrefix: "-scroll-button-cache-", getId: function(){ return this._idPrefix + this._count++;} , remove: function(o){ delete this[o.id];}};function ScrollButton(oEl, oScrollContainer, nDir){ this.htmlElement = oEl; this.scrollContainer = oScrollContainer; this.dir = nDir; this.id = scrollButtonCache.getId(); scrollButtonCache[this.id] = this; this.makeEventListeners(); this.attachEvents();}ScrollButton.scrollIntervalPause = 100;ScrollButton.scrollAmount = 18;ScrollButton.prototype.startScroll = function(){ this._interval = window.setInterval("ScrollButton.eventListeners.oninterval(\"" + this.id + "\")", ScrollButton.scrollIntervalPause);} ;ScrollButton.prototype.endScroll = function(){ if (this._interval != null) { window.clearInterval(this._interval); delete this._interval; }};ScrollButton.prototype.makeEventListeners = function(){ if (this.eventListeners != null) return; this.eventListeners = { onmouseover: new Function("ScrollButton.eventListeners.onmouseover(\"" + this.id + "\")"), onmouseout: new Function("ScrollButton.eventListeners.onmouseout(\"" + this.id + "\")"), onunload: new Function("ScrollButton.eventListeners.onunload(\"" + this.id + "\")") };};ScrollButton.prototype.attachEvents = function(){ if (this.eventListeners == null) return; this.htmlElement.attachEvent("onmouseover", this.eventListeners.onmouseover); this.htmlElement.attachEvent("onmouseout", this.eventListeners.onmouseout); window.attachEvent("onunload", this.eventListeners.onunload);};ScrollButton.prototype.detachEvents = function(){ if (this.eventListeners == null) return; this.htmlElement.detachEvent("onmouseover", this.eventListeners.onmouseover); this.htmlElement.detachEvent("onmouseout", this.eventListeners.onmouseout); window.detachEvent("onunload", this.eventListeners.onunload);};ScrollButton.prototype.destroy = function(){ this.endScroll(); this.detachEvents(); this.htmlElement = null; this.scrollContainer = null; this.eventListeners = null; scrollButtonCache.remove(this);};ScrollButton.eventListeners = { onmouseover: function(id){ scrollButtonCache[id].startScroll();} , onmouseout: function(id){ scrollButtonCache[id].endScroll();} , oninterval: function(id){ var oThis = scrollButtonCache[id]; switch (oThis.dir) { case 8: oThis.scrollContainer.scrollTop -= ScrollButton.scrollAmount; break; case 2: oThis.scrollContainer.scrollTop += ScrollButton.scrollAmount; break; case 4: oThis.scrollContainer.scrollLeft -= ScrollButton.scrollAmount; break; case 6: oThis.scrollContainer.scrollLeft += ScrollButton.scrollAmount; break; }}, onunload: function(id){ scrollButtonCache[id].destroy();}};var menuCache = { _count: 0, _idPrefix: "-menu-cache-", getId: function(){ return this._idPrefix + this._count++;} , remove: function(o){ delete this[o.id];}};function Menu(){ this.items = []; this.parentMenu = null; this.parentMenuItem = null; this.popup = null; this.shownSubMenu = null; this._aboutToShowSubMenu = false; this.selectedIndex = -1; this._drawn = false; this._scrollingMode = false; this._showTimer = null; this._closeTimer = null; this._onCloseInterval = null; this._closed = true; this._closedAt = 0; this._cachedSizes = { }; this._measureInvalid = true; this.id = menuCache.getId(); menuCache[this.id] = this;}Menu.prototype.cssFile = "skins/winclassic.css";Menu.prototype.cssText = null;Menu.prototype.mouseHoverDisabled = true;Menu.prototype.showTimeout = 250;Menu.prototype.closeTimeout = 250;Menu.keyboardAccelKey = 27;Menu.keyboardAccelKey2 = 121;Menu.keyboardAccelProperty = "ctrlKey";Menu.prototype.add = function(mi, beforeMi){ if (beforeMi != null) { var items = this.items; var l = items.length; var i = 0; for (;i < l; i++) { if (items[i] == beforeMi) break; } this.items = items.slice(0, i).concat(mi).concat(items.slice(i, l)); for (var j = i; j < l + 1; j++) this.items[j].itemIndex = j; } else { this.items.push(mi); mi.itemIndex = this.items.length - 1; } mi.parentMenu = this; if (mi.subMenu) { mi.subMenu.parentMenu = this; mi.subMenu.parentMenuItem = mi; } return mi;};Menu.prototype.remove = function(mi){ var res = []; var items = this.items; var l = items.length; for (var i = 0; i < l; i++) { if (items[i] != mi) { res.push(items[i]); items[i].itemIndex = res.length - 1; } } this.items = res; mi.parentMenu = null; return mi;};Menu.prototype.toHtml = function(){ var items = this.items; var l = items.length var itemsHtml = new Array(l); for (var i = 0; i < l; i++) itemsHtml[i] = items[i].toHtml(); return "<html><head>" + (this.cssText == null ? "<link type=\"text/css\" rel=\"StyleSheet\" href=\""+this.cssFile+"\" />" : "<style type=\"text/css\">" + this.cssText + "</style>") + "</head><body class=\"menu-body\">" + "<div class=\"outer-border\"><div class=\"inner-border\">" + "<table id=\"scroll-up-item\" cellspacing=\"0\" style=\"display: none\">" + "<tr class=\"disabled\"><td>" + "<span class=\"disabled-container\"><span class=\"disabled-container\">" + "5" + "</span></span>" + "</td></tr></table>" + "<div id=\"scroll-container\">" + "<table cellspacing=\"0\">" + itemsHtml.join( "") + "</table>" + "</div>" + "<table id=\"scroll-down-item\" cellspacing=\"0\" style=\"display: none\">" + "<tr><td>" + "<span class=\"disabled-container\"><span class=\"disabled-container\">" + "6" + "</span></span>" + "</td></tr></table>" + "</div></div>" + "</body></html>";};Menu.prototype.createPopup = function(){ var w; var pm = this.parentMenu; if (pm == null) w = window; else w = pm.getDocument().parentWindow; this.popup = w.createPopup();};Menu.prototype.getMeasureDocument = function(){ if (this.isShown() && this._drawn) return this.getDocument(); var mf = Menu._measureFrame; if (mf == null) { mf = Menu._measureFrame = document.createElement("IFRAME"); var mfs = mf.style; mfs.position = "absolute"; mfs.visibility = "hidden"; mfs.left = "-100px"; mfs.top = "-100px"; mfs.width = "10px"; mfs.height = "10px"; mf.frameBorder = 0; document.body.appendChild(mf); } var d = mf.contentWindow.document if (Menu._measureMenu == this && !this._measureInvalid) return d; d.open("text/html", "replace"); d.write(this.toHtml()); d.close(); Menu._measureMenu = this; this._measureInvalid = false; return d;};Menu.prototype.getDocument = function(){ if (this.popup) return this.popup.document; else return null;};Menu.prototype.getPopup = function(){ if (this.popup == null) this.createPopup(); return this.popup;};Menu.prototype.invalidate = function(){ if (this._drawn) { if (this._scrollUpButton) this._scrollUpButton.destroy(); if (this._scrollDownButton) this._scrollDownButton.destroy(); var items = this.items; var l = items.length; var mi; for (var i = 0; i < l; i++) { mi = items[i]; mi._htmlElement_menuItem = null; mi._htmlElement = null; } this.detachEvents(); } this._drawn = false; this.resetSizeCache(); this._measureInvalid = true;};Menu.prototype.redrawMenu = function(){ this.invalidate(); this.drawMenu();};Menu.prototype.drawMenu = function(){ if (this._drawn) return; this.getPopup(); var d = this.getDocument(); d.open("text/html", "replace"); d.write(this.toHtml()); d.close(); this._drawn = true; var up = d.getElementById("scroll-up-item"); var down = d.getElementById("scroll-down-item"); var scrollContainer = d.getElementById("scroll-container"); new ScrollButton(up, scrollContainer, 8); new ScrollButton(down, scrollContainer, 2); var rows = scrollContainer.firstChild.tBodies[0].rows; var items = this.items; var l = rows.length; var mi; for (var i = 0; i < l; i++) { mi = items[i]; rows[i]._menuItem = mi; mi._htmlElement = rows[i]; } this.hookupMenu(d);};Menu.prototype.show = function(left, top, w, h){ var pm = this.parentMenu; if (pm) pm.closeAllSubs(this); var wasShown = this.isShown(); if (typeof this.onbeforeshow == "function" && !wasShown) this.onbeforeshow(); this.drawMenu(); if (left == null) left = 0; if (top == null) top = 0; w = w || Math.min(window.screen.width, this.getPreferredWidth()); h = h || Math.min(window.screen.height, this.getPreferredHeight()); this.popup.show(left, top, w, h); if (this.getPreferredWidth() == 0) { this.invalidate(); this.show(left, top, w, h); return; } this.fixScrollButtons(); this.fixScrollEnabledState(); if (this.selectedIndex != -1) { if (this.items[this.selectedIndex]) this.items[this.selectedIndex].setSelected(false); } if (pm) { pm.shownSubMenu = this; pm._aboutToShowSubMenu = false; } window.clearTimeout(this._showTimer); window.clearTimeout(this._closeTimer); this._closed = false; this._startClosePoll(); if (typeof this.onshow == "function" && !wasShown && this.isShown()) this.onshow();};Menu.prototype.isShown = function(){ this._checkCloseState(); return this.popup != null && this.popup.isOpen;};Menu.prototype.fixSize = function(){ var w = Math.min(window.screen.width, this.getPreferredWidth()); var h = Math.min(window.screen.height, this.getPreferredHeight()); var l = Math.max(0, this.getLeft()); var t = Math.max(0, this.getTop()); this.popup.show(l, t, w, h);};Menu.prototype.getWidth = function(){ var d = this.getDocument(); if (d != null) return d.body.offsetWidth;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -