From 1f4bd69db3eaf70ac00272e389b3f96ab5dd948f Mon Sep 17 00:00:00 2001 From: Frank Dillon Date: Wed, 14 Jun 2006 16:27:57 +0000 Subject: [PATCH] right click menu --- www/extras/wobject/ProjectManager/cMenu.css | 36 +++ www/extras/wobject/ProjectManager/cMenu.js | 327 ++++++++++++++++++++ 2 files changed, 363 insertions(+) create mode 100644 www/extras/wobject/ProjectManager/cMenu.css create mode 100644 www/extras/wobject/ProjectManager/cMenu.js diff --git a/www/extras/wobject/ProjectManager/cMenu.css b/www/extras/wobject/ProjectManager/cMenu.css new file mode 100644 index 000000000..d1a5eae62 --- /dev/null +++ b/www/extras/wobject/ProjectManager/cMenu.css @@ -0,0 +1,36 @@ +.cMenu_skin { + background-color: #FFFFFF; + background-image: url(office_xp_menu_left.png); + background-repeat: repeat-y; + border: 1px solid #8A867A; + cursor: default; + position: absolute; /* Do not alter this line! */ + visibility: hidden; + z-index: 100; + color: #000000; + font-family: Tahoma, Helvetica, sans, Arial, sans-serif; + font-size: 12px; + font-weight: normal; + padding-bottom: 3px; + padding-left: 30px; + padding-right: 15px; + padding-top: 3px; +} + +.cMenu_skin A, .cMenu_skin A:link, .cMenu_skin A:visited { + font-weight: normal; + width: 100%; + color: black; + text-decoration: none; + margin: 1px; + font-size: 10px; +} + +.cMenu_skin A:hover { + background-color: #C1D2EE; + border: 1px solid #316AC5; + color: #000000; + font-family: Tahoma, Helvetica, sans, Arial, sans-serif; + font-size: 12px; + position: relative; +} diff --git a/www/extras/wobject/ProjectManager/cMenu.js b/www/extras/wobject/ProjectManager/cMenu.js new file mode 100644 index 000000000..c3432e6c3 --- /dev/null +++ b/www/extras/wobject/ProjectManager/cMenu.js @@ -0,0 +1,327 @@ +/* +Determine whether the browser is IE5.0. +*/ +function isIE50() { // Private method + return isIE5() && !isIE55(); +} + +/* +Determine whether the browser is IE5.5. +*/ +function isIE55() { // Private method + return navigator.userAgent.indexOf("MSIE 5.5") > -1; +} + +/* +Determine whether the browser is IE5.0 or IE5.5. +*/ +function isIE5() { // Private method + return navigator.userAgent.indexOf("MSIE 5") > -1; +} + +/* +Determine whether the browser is IE6. +*/ +function isIE6() { // Private method + return navigator.userAgent.indexOf("MSIE 6") > -1 && navigator.userAgent.indexOf("Opera") == -1; +} + +/* +Determine whether the browser is IE. +*/ +function isIE() { // Private method + return isIE5() || isIE6(); +} + +/* +Determine whether the browser is Opera. +*/ +function isOpera() { // Private method + return navigator.userAgent.indexOf("Opera") > -1; +} + +/* +Determine whether the browser is Safari. +*/ +function isSafari() { // Private method + return navigator.userAgent.indexOf("Safari") > -1; +} + +var ie50 = isIE50(); // Private field +var ie55 = isIE55(); // Private field +var ie5 = isIE5(); // Private field +var ie6 = isIE6(); // Private field +var ie = isIE(); // Private field +var opera = isOpera(); // Private field +var safari = isSafari(); // Private field +var pageMode = getPageMode(); +var px = "px"; + +var cMenu_items = new Array(); + +if (cMenu_old == undefined) +{ + var cMenu_old = (document.onclick) ? document.onclick : function () {}; + document.onclick= function () {cMenu_old();cMenu_hide();}; +} + +/* +Determine the page render mode. + +0: Quirks mode. +1: Strict mode. +*/ +function getPageMode() { // Private method + if (document.compatMode) { + switch (document.compatMode) { + case "BackCompat": + return 0; + case "CSS1Compat": + return 1; + case "QuirksMode": + return 0; + } + } + else { + if (ie5) { + return 0; + } + if (safari) { + return 1; + } + } + return 0; +} + +function getMainMenuLeftPos(menuObj, x) { // Private method + //alert(x); + if (x + menuObj.offsetWidth <= getClientWidth()) { + return x; + } + else { + return x - menuObj.offsetWidth; + } +} + +/* +Get the top position of the pop-up menu. +*/ +function getMainMenuTopPos(menuObj, y) { // Private method + //alert(y); + if (y + menuObj.offsetHeight <= getClientHeight()) { + return y; + } + else { + return y - menuObj.offsetHeight; + } +} + +/* +Get the clientHeight property. +*/ +function getClientHeight() { // Private method + switch (pageMode) { + case 0: + return document.body.clientHeight; + case 1: + if (safari) { + return self.innerHeight; + } + else { + if (!opera && document.documentElement && document.documentElement.clientHeight > 0) { + return document.documentElement.clientHeight; + } + else { + return document.body.clientHeight; + } + } + } +} + +/* +Get the clientWidth property. +*/ +function getClientWidth() { // Private method + switch (pageMode) { + case 0: + return document.body.clientWidth; + case 1: + if (safari) { + return self.innerWidth; + } + else { + if (!opera && document.documentElement && document.documentElement.clientWidth > 0) { + return document.documentElement.clientWidth; + } + else { + return document.body.clientWidth; + } + } + } +} + +/* +Get the x-coordinate of the cursor position relative to the window. +*/ +function getX(e) { // Private method + if (!e) { + var e = window.event; + } + if (safari) { + return e.clientX - getScrollLeft(); + } + else { + return e.clientX; + } +} + +/* +Get the y-coordinate of the cursor position relative to the window. +*/ +function getY(e) { // Private method + if (!e) { + var e = window.event; + } + if (safari) { + return e.clientY - getScrollTop(); + } + else { + return e.clientY; + } +} + +/* +Get the scrollLeft property. +*/ +function getScrollLeft() { // Private method + switch (pageMode) { + case 0: + return document.body.scrollLeft; + case 1: + if (document.documentElement && document.documentElement.scrollLeft > 0) { + return document.documentElement.scrollLeft; + } + else { + return document.body.scrollLeft; + } + } +} + +/* +Get the scrollTop property. +*/ +function getScrollTop() { // Private method + switch (pageMode) { + case 0: + return document.body.scrollTop; + case 1: + if (document.documentElement && document.documentElement.scrollTop > 0) { + return document.documentElement.scrollTop; + } + else { + return document.body.scrollTop; + } + } +} + +function cMenu_renderLeftClick(menuId,e) { + cMenu_hide(e); + cMenu_show(menuId,e); + e.cancelBubble=true; + e.returnValue=false; + return false; +} + +function cMenu_show(menuId,e){ + // alert(menuId); + var menuobj=document.getElementById(menuId) + var posx = 0; + var posy = 0; + var yoffset = 0; + var xoffset = 0; + var firedobj = ie5?e.srcElement:e.target; + /*while (firedobj!=null && firedobj.tagName!="HTML"){ + //this is a hack, need to revisit + if (firedobj.tagName == "DIV") { + xoffset+=firedobj.offsetLeft; + yoffset+=firedobj.offsetTop; + } + firedobj=firedobj.offsetParent; + } + + var el = document.documentElement; + posx = e.clientX - xoffset + (ie5? el.scrollLeft : window.pageXOffset); + posy = e.clientY - yoffset + (ie5? el.scrollTop : window.pageYOffset); + alert(posx); + alert(posy); + //menuobj.style.left=posx + "px"; + //menuobj.style.top=posy + "px"; + */ + var hackedTopOffset = (ie?180:130); + menuobj.style.left = (getMainMenuLeftPos(menuobj, getX(e)) + getScrollLeft()) + px; + menuobj.style.top = (getMainMenuTopPos(menuobj, getY(e)) + getScrollTop() - hackedTopOffset) + px; + //alert(menuobj.style.left); + //alert(menuobj.style.top); + menuobj.style.visibility="visible" + return false +} + +function cMenu_hide(){ + for (i=0;i'; + for (i=0;i" + this.linkLabels[i] + "
"; + } + output += ''; + if (this.type == "image") { + output += '' + this.name + ''; + } else { + output += '' + this.name + ''; + } + return output; +} + +function cMenu_print(){ + document.write(this.draw()); +} + +function cMenu_addLink(linkUrl,linkLabel){ + this.linkUrls.push(linkUrl); + this.linkLabels.push(linkLabel); +}