3 function ContextMenuManager() {}
5 /* builds a new menu and stores it */
6 ContextMenuManager.prototype.buildMenu = function(name) {
9 this.menus = new Array();
10 /* here we hijack the body onclick to
11 hide menus that may be visible */
12 getDocument().body.onclick = function() {
13 globalMenuManager.hideAll();
17 if(name == null) name = new Date().getTime();
18 this.menus[name] = new ContextMenu(name);
19 return this.menus[name];
22 /* returns the menu with the given name */
23 ContextMenuManager.prototype.getMenu = function(name) {
24 return this.menus[name];
27 /* hides all visible menus and brings the
28 selected menu to the front */
29 ContextMenuManager.prototype.toggle = function(name) {
31 this.getMenu(name).toggle();
34 /* hides all menues */
35 ContextMenuManager.prototype.hideAll = function() {
36 for( var index in this.menus) {
37 this.menus[index].hideMe();
41 /* sets a context object for the given menu. When a user clicks
42 in the context area, the menu appears */
43 ContextMenuManager.prototype.setContext = function(node, menu) {
45 node.oncontextmenu = function(evt) {
46 var win = getAppWindow();
47 if(!win.event) win.event = evt;
48 obj.toggle(menu.name);