0byt3m1n1
Path:
C:
/
Program Files (x86)
/
Microsoft Office
/
Office12
/
Groove
/
ToolData
/
groove.net
/
GrooveForms
/
[
Home
]
File: MENUS.JS
// ======================================================================== // === menus.js === // ======================================================================== // The popup object that will hold the menu. var g_objPopup = window.createPopup(); // === Menu() ========= // the main menu object function Menu() { this.MenuHTML = ""; this.AddMenuItem = AddMenuItem; this.AddSeparator = AddSeparator; this.Create = Create; } // === AddMenuItem(string, string, boolean) ==================== // add an item to the menu object with the given text and action function AddMenuItem(i_strTitle, i_strAction, i_blnEnabled) { i_strTitle = i_strTitle.replace(/ /g, " "); var strHTML = ""; if (i_blnEnabled) { strHTML += "<div style=\"width:100%; cursor:default; padding:1px 22px 3px 17px; border:1px solid menu; font-family:tahoma; font-size:8pt;\" onmouseover=\"this.style.backgroundColor='highlight'; this.style.color='highlighttext';\" onmouseout=\"this.style.backgroundColor=''; this.style.color='';\""; if (i_strAction != "") strHTML += " onclick=\"" + i_strAction + "\""; } else strHTML += "<div style=\"width:100%; cursor:default; padding:2px 23px 4px 18px; font-family:tahoma; font-size:8pt; color:threedshadow;\""; strHTML += ">" + i_strTitle + "</div>"; this.MenuHTML += strHTML; } // === AddSeparator() ==================== // add a separator item to the menu object function AddSeparator() { var strHTML = ""; strHTML += "<div style=\"margin:4px 3px 4px 3px; border-width:1px; border-style:solid; border-color:buttonshadow buttonhighlight buttonhighlight buttonshadow;\"></div>"; this.MenuHTML += strHTML; } // === Create() ============================ // create the final HTML for the menu object function Create() { this.MenuHTML = "<div style=\"background:menu; color:menutext; border-width:2px; border-color:buttonhighlight buttonshadow buttonshadow buttonhighlight; border-style:outset; z-index:100;\">" + this.MenuHTML + "</div>"; } // === MenuPopup(object, object) ============================================ // called to display the menu, reference object and menu to display passed in function MenuPopup(i_objRef, i_objMenu) { var intTop = GetOffset(i_objRef, "top") + i_objRef.offsetHeight + 1; var intLeft = GetOffset(i_objRef, "left"); var objPopupBody = g_objPopup.document.body; objPopupBody.innerHTML = i_objMenu.MenuHTML; g_objPopup.show(0, 0, 0, 0); var realWidth = objPopupBody.scrollWidth; var realHeight = objPopupBody.scrollHeight; g_objPopup.show(intLeft, intTop, realWidth, realHeight, document.body); } // === GetOffset(object, string) ========================================= // utility function used to get offset of reference object passed in, gets // either top or left offset of the object function GetOffset(i_objPos, i_strDir) { var intOffset = 0; var objOffset = i_objPos; while (objOffset.tagName != "BODY") { if (i_strDir == "top") intOffset += objOffset.offsetTop; else if (i_strDir == "left") intOffset += objOffset.offsetLeft; objOffset = objOffset.offsetParent; } return intOffset; }