From 4485c71cd0ce06926b387f033368669ab15fc334 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 7 Feb 2008 23:09:16 +0000 Subject: [PATCH] Monotone-Parent: eb80137abbc0c0a426a654921250804b1c3d92ab Monotone-Revision: 9afbcfbc31ab96049b1a603edff5f9ed02a4a00d Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-02-07T23:09:16 Monotone-Branch: ca.inverse.sogo --- UI/WebServerResources/ContactsUI.js | 39 ++++++++++++++++++++++++++--- UI/WebServerResources/generic.js | 8 +++++- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/UI/WebServerResources/ContactsUI.js b/UI/WebServerResources/ContactsUI.js index 4ec024786..b9e8e95d7 100644 --- a/UI/WebServerResources/ContactsUI.js +++ b/UI/WebServerResources/ContactsUI.js @@ -169,7 +169,7 @@ function onContactFoldersContextMenu(event) { $(this).selectElement(); } -function onContactContextMenu(event, element) { log ("onContactContextMenu"); +function onContactContextMenu(event, element) {// log ("onContactContextMenu"); var menu = $("contactMenu"); Event.observe(menu, "mousedown", onContactContextMenuHide, false); @@ -326,6 +326,14 @@ function onMenuWriteToContact(event) { window.close(); } +function onMenuAIMContact(event) { + var contactId = document.menuTarget.getAttribute('id'); + var contactRow = $(contactId); + var aimCell = contactRow.down('td', 2); + + window.location.href = "aim:goim?ScreenName=" + aimCell.firstChild.nodeValue; +} + function onMenuDeleteContact(event) { uixDeleteSelectedContacts(this); } @@ -808,7 +816,7 @@ function onMenuSharing(event) { function onContactFoldersMenuPrepareVisibility() { var folders = $("contactFolders"); - var selected = folders.getSelectedNodes(); + var selected = folders.getSelectedNodes(); if (selected.length > 0) { var folderOwner = selected[0].getAttribute("owner"); @@ -827,19 +835,42 @@ function onContactFoldersMenuPrepareVisibility() { } } +function onContactMenuPrepareVisibility() { + var contactId = document.menuTarget.getAttribute('id'); + var contactRow = $(contactId); + var elements = $(this).down("ul").childElements(); + + var writeOption = elements[2]; + var emailCell = contactRow.down('td', 1); + if (emailCell.firstChild) + writeOption.removeClassName("disabled"); + else + writeOption.addClassName("disabled"); + + var aimOption = elements[3]; + var aimCell = contactRow.down('td', 2); + if (aimCell.firstChild) + aimOption.removeClassName("disabled"); + else + aimOption.addClassName("disabled"); +} + function getMenus() { var menus = {}; menus["contactFoldersMenu"] = new Array(onMenuModify, "-", null, null, "-", null, "-", onMenuSharing); menus["contactMenu"] = new Array(onMenuEditContact, "-", - onMenuWriteToContact, null, "-", - onMenuDeleteContact); + onMenuWriteToContact, onMenuAIMContact, + "-", onMenuDeleteContact); menus["searchMenu"] = new Array(setSearchCriteria); var contactFoldersMenu = $("contactFoldersMenu"); if (contactFoldersMenu) contactFoldersMenu.prepareVisibility = onContactFoldersMenuPrepareVisibility; + var contactMenu = $("contactMenu"); + if (contactMenu) + contactMenu.prepareVisibility = onContactMenuPrepareVisibility; return menus; } diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index 0888d79a5..41d184bde 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -652,6 +652,11 @@ function onBodyClickMenuHandler(event) { preventDefault(event); } +function onMenuClickHandler(event) { + if (!this.hasClassName("disabled")) + this.menuCallback.apply(this, [event]); +} + function hideMenu(menuNode) { var onHide; @@ -1198,7 +1203,8 @@ function initMenu(menuDIV, callbacks) { } else { node.observe("mouseup", onBodyClickMenuHandler); - node.observe("click", callback); + node.menuCallback = callback; + node.observe("click", onMenuClickHandler); } } else