function contextMenu() { this.items = new Array(); this.addItem = function(item) { this.items[this.items.length] = item; } this.show = function(oDoc) { var strShow = ""; var i; strShow = "
"; strShow += ""; strShow += ""; strShow += ""; strShow += ""; strShow += "
"; strShow += ""; strShow += "
"; strShow += "
"; strShow += ""; oDoc.write(strShow); for (i = 0; i < this.items.length; i++) { this.items[i].show(oDoc); } strShow = "
"; strShow += ""; strShow += "
"; strShow += "
\n"; oDoc.write(strShow); } } // menu Item object /* * text ���˵��������� icon ���˵�ǰ���ͼƬ cmd �����õ�JS���� type ��menu �˵� * separator �ָ��� */ function contextItem(text, icon, cmd, type) { this.text = text ? text : ""; this.icon = icon ? icon : ""; this.cmd = cmd ? cmd : ""; this.type = type ? type : "menu"; this.show = function(oDoc) { var strShow = ""; if (this.type == "menu") { strShow += ""; strShow += ""; if (this.icon == "") strShow += " "; else { strShow += ""; } strShow += " "; strShow += this.text; strShow += " "; } else if (this.type == "separator") { strShow += " "; strShow += "
"; } oDoc.write(strShow); } } function changeStyle(obj, cmd) { if (obj) try { var imgObj = obj.children(0).children(0); if (cmd == 'on') { obj.children(0).className = "ltdfocusmenu"; obj.children(1).className = "mtdfocusmenu"; obj.children(2).className = "rtdfocusmenu"; if (imgObj) { if (imgObj.tagName.toUpperCase() == "IMG") { imgObj.style.left = "-1px"; imgObj.style.top = "-1px"; } } } else if (cmd == 'out') { obj.children(0).className = "ltdexitmenu"; obj.children(1).className = "mtdexitmenu"; obj.children(2).className = "rtdexitmenu"; if (imgObj) { if (imgObj.tagName.toUpperCase() == "IMG") { imgObj.style.left = "0px"; imgObj.style.top = "0px"; } } } } catch (e) { } } function rightUp(obj) { selectTdObj = obj; var x, y, w, h, ox, oy; x = event.clientX; y = event.clientY; var obj = document.getElementById("rightmenu"); if (obj == null) return true; ox = document.body.clientWidth; oy = document.body.clientHeight; if (x > ox || y > oy) return false; w = obj.offsetWidth; h = obj.offsetHeight; if ((x + w) > ox) x = x - w; if ((y + h) > oy) y = y - h; obj.style.posLeft = x + document.body.scrollLeft; obj.style.posTop = y + document.body.scrollTop; obj.style.visibility = "visible"; return false; } function hideMenu() { if (event.button == 0) { var obj = document.getElementById("rightmenu"); if (obj == null) return true; obj.style.visibility = "hidden"; obj.style.posLeft = 0; obj.style.posTop = 0; } } function toggleMenu(isEnable) { if (isEnable) document.oncontextmenu = showMenu; else document.oncontextmenu = new function() { return true; }; } function tdchangeStyle(obj, cmd) { if (obj) try { if (cmd == 'on') { obj.className = "tdfocus"; } else if (cmd == 'out') { obj.className = ""; } } catch (e) { } } function inputbtchangeStyle(obj, cmd) { if (obj) try { if (cmd == 'on') { obj.className = "tdfocus"; } else if (cmd == 'out') { obj.className = "button"; } } catch (e) { } } function imgbtchangeStyle(obj, cmd) { if (obj) try { if (cmd == 'on') { obj.className = "tdfocus"; } else if (cmd == 'out') { obj.className = ""; } } catch (e) { } }