123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- 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 = "<div id=\"rightmenu\" style=\"BACKGROUND-COLOR: #ffffff; BORDER: #000000 1px solid; LEFT: 0px; POSITION: absolute; TOP: 0px; VISIBILITY: hidden; Z-INDEX: 10\">";
- strShow += "<table border=\"0\" height=\"";
- strShow += this.items.length * 20;
- strShow += "\" cellpadding=\"0\" cellspacing=\"0\">";
- strShow += "<tr height=\"3\"><td bgcolor=\"#d0d0ce\" width=\"2\"></td><td>";
- strShow += "<table border=\"0\" width=\"100%\" height=\"100%\" cellpadding=0 cellspacing=0 bgcolor=\"#ffffff\">";
- strShow += "<tr><td bgcolor=\"#d0d0ce\" width=\"23\"></td><td><img src=\" \" height=\"1\" border=\"0\"></td></tr></table>";
- strShow += "</td><td width=\"2\"></td></tr>";
- strShow += "<tr><td bgcolor=\"#d0d0ce\"></td><td nowrap>";
- strShow += "<table border=\"0\" width=\"100%\" class=tablemenu height=\"100%\" cellpadding=3 cellspacing=0 bgcolor=\"#ffffff\">";
- oDoc.write(strShow);
- for (i = 0; i < this.items.length; i++) {
- this.items[i].show(oDoc);
- }
- strShow = "</table></td><td></td></tr>";
- strShow += "<tr height=\"3\"><td bgcolor=\"#d0d0ce\"></td><td>";
- strShow += "<table border=\"0\" width=\"100%\" height=\"100%\" cellpadding=0 cellspacing=0 bgcolor=\"#ffffff\">";
- strShow += "<tr><td bgcolor=\"#d0d0ce\" width=\"23\"></td><td><img src=\" \" height=\"1\" border=\"0\"></td></tr></table>";
- strShow += "</td><td></td></tr>";
- strShow += "</table></div>\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 += "<tr ";
- strShow += "onmouseover=\"changeStyle(this, 'on');\" ";
- strShow += "onmouseout=\"changeStyle(this, 'out');\" ";
- strShow += "onclick=\"";
- strShow += this.cmd;
- strShow += "\">";
- strShow += "<td class=\"ltdexitmenu\" width=\"16\">";
- if (this.icon == "")
- strShow += " ";
- else {
- strShow += "<img border=\"0\" src=\"";
- strShow += this.icon;
- strShow += "\" width=\"16\" height=\"16\" style=\"POSITION: relative\"></img>";
- }
- strShow += "</td><td class=\"mtdexitmenu\" nowrap> ";
- strShow += this.text;
- strShow += "</td><td class=\"rtdexitmenu\" width=\"5\"> </td></tr>";
- } else if (this.type == "separator") {
- strShow += "<tr><td class=\"ltdexitmenu\"> </td>";
- strShow += "<td class=\"mtdexitmenu\" colspan=\"2\"><hr color=\"#000000\" size=\"1\"></td></tr>";
- }
- 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) {
- }
- }
|