From 9baff55e0765975d4d1bbf838cf25e4cc9684e5d Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 21 Aug 2006 22:36:33 +0000 Subject: [PATCH] Monotone-Parent: 8aed7f96f4edadf4d9b9bc814518b9cafc6eb5f8 Monotone-Revision: 3def5bc0bcb4f109c2b09a172c968677c59f3dec Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-08-21T22:36:33 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 7 ++ UI/WebServerResources/ContactsUI.js | 133 +-------------------------- UI/WebServerResources/MailerUI.js | 126 +------------------------ UI/WebServerResources/SchedulerUI.js | 88 ++++++++++++++---- UI/WebServerResources/generic.js | 116 +++++++++++++++++++++++ 5 files changed, 194 insertions(+), 276 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9eb69ccc6..c54f8d9d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2006-08-21 Wolfgang Sourdeau + * UI/WebServerResources/MailerUI.js: fixed the contact creation + from email addresses. + + * UI/WebServerResources/generic.js: centralized the search-related + functions here since the same code was used across the 3 + applications. + * UI/Scheduler/UIxCalAptListView.m ([UIxCalAptListView -startDate]) ([UIxCalAptListView -endDate]): return the required dates needed depending on the value given to the "filterpopup" url parameter. diff --git a/UI/WebServerResources/ContactsUI.js b/UI/WebServerResources/ContactsUI.js index ae8f274c1..7206c238e 100644 --- a/UI/WebServerResources/ContactsUI.js +++ b/UI/WebServerResources/ContactsUI.js @@ -488,127 +488,6 @@ function moveTo(uri) { alert("MoveTo: " + uri); } -function popupSearchMenu(event, menuId) -{ - var node = event.target; - - superNode = node.parentNode.parentNode.parentNode; - relX = (event.pageX - superNode.offsetLeft - node.offsetLeft); - relY = (event.pageY - superNode.offsetTop - node.offsetTop); - - if (event.button == 0 - && relX < 24) { - event.cancelBubble = true; - event.returnValue = false; - - var popup = document.getElementById(menuId); - hideMenu(event, popup); - - var menuTop = superNode.offsetTop + node.offsetTop + node.offsetHeight; - var menuLeft = superNode.offsetLeft + node.offsetLeft; - var heightDiff = (window.innerHeight - - (menuTop + popup.offsetHeight)); - if (heightDiff < 0) - menuTop += heightDiff; - - var leftDiff = (window.innerWidth - - (menuLeft + popup.offsetWidth)); - if (leftDiff < 0) - menuLeft -= popup.offsetWidth; - - popup.style.top = menuTop + "px"; - popup.style.left = menuLeft + "px"; - popup.style.visibility = "visible"; - - bodyOnClick = "" + document.body.getAttribute("onclick"); - document.body.setAttribute("onclick", "onBodyClick('" + menuId + "');"); - document.currentPopupMenu = popup; - } -} - -function setSearchCriteria(event) -{ - searchValue = document.getElementById('searchValue'); - searchCriteria = document.getElementById('searchCriteria'); - - var node = event.target; - searchValue.setAttribute("ghost-phrase", node.innerHTML); - searchCriteria = node.getAttribute('id'); -} - -function checkSearchValue(event) -{ - var form = event.target; - var searchValue = document.getElementById('searchValue'); - var ghostPhrase = searchValue.getAttribute('ghost-phrase'); - - if (searchValue.value == ghostPhrase) - searchValue.value = ""; -} - -function onSearchChange() -{ - log ("changed..."); -} - -function onSearchMouseDown(event, searchValue) -{ - superNode = searchValue.parentNode.parentNode.parentNode; - relX = (event.pageX - superNode.offsetLeft - searchValue.offsetLeft); - relY = (event.pageY - superNode.offsetTop - searchValue.offsetTop); - - if (relY < 24) { - event.cancelBubble = true; - event.returnValue = false; - } -} - -function onSearchFocus(searchValue) -{ - ghostPhrase = searchValue.getAttribute("ghost-phrase"); - if (searchValue.value == ghostPhrase) { - searchValue.value = ""; - searchValue.setAttribute("modified", ""); - } else { - searchValue.select(); - } - - searchValue.style.color = "#000"; -} - -function onSearchBlur(searchValue) -{ - var ghostPhrase = searchValue.getAttribute("ghost-phrase"); - log ("search blur: '" + searchValue.value + "'"); - if (!searchValue.value) { - searchValue.setAttribute("modified", ""); - searchValue.style.color = "#aaa"; - searchValue.value = ghostPhrase; - } else if (searchValue.value == ghostPhrase) { - searchValue.setAttribute("modified", ""); - searchValue.style.color = "#aaa"; - } else { - searchValue.setAttribute("modified", "yes"); - searchValue.style.color = "#000"; - } -} - -function initCriteria() -{ - var searchCriteria = document.getElementById('searchCriteria'); - var searchValue = document.getElementById('searchValue'); - var firstOption; - - firstOption = document.getElementById('searchOptions').childNodes[1]; - searchCriteria.value = firstOption.getAttribute('id'); - searchValue.setAttribute('ghost-phrase', firstOption.innerHTML); - if (searchValue.value == '') { - searchValue.value = firstOption.innerHTML; - searchValue.setAttribute("modified", ""); - searchValue.style.color = "#aaa"; - } -} - /* contact menu entries */ function onContactRowDblClick(event, node) { @@ -769,7 +648,7 @@ function newContact(sender) { function onFolderSelectionChange() { var folderList = document.getElementById("contactFolders"); - var nodes = getSelectedNodes(folderList); + var nodes = folderList.getSelectedNodes(); var newFolder = nodes[0].getAttribute("id"); openContactsFolder(newFolder); @@ -784,14 +663,6 @@ function onSearchFormSubmit() return false; } -function onSearchKeyDown(searchValue) -{ - if (searchValue.timer) - clearTimeout(searchValue.timer); - - searchValue.timer = setTimeout("onSearchFormSubmit()", 1000); -} - function onConfirmContactSelection() { var folderLi = document.getElementById(currentContactFolder); @@ -804,7 +675,7 @@ function onConfirmContactSelection() var cid = rows[i].getAttribute("contactid"); if (cid) { - var cname = '' + row.getAttribute("contactname"); + var cname = '' + rows[i].getAttribute("contactname"); opener.window.log('cid = ' + cid + '; cname = ' + cname ); if (cid.length > 0) opener.window.addContact(contactSelectorId, diff --git a/UI/WebServerResources/MailerUI.js b/UI/WebServerResources/MailerUI.js index f2a83dff2..c29299616 100644 --- a/UI/WebServerResources/MailerUI.js +++ b/UI/WebServerResources/MailerUI.js @@ -813,130 +813,6 @@ function moveTo(uri) { alert("MoveTo: " + uri); } -function popupSearchMenu(event, menuId) -{ - var node = event.target; - - superNode = node.parentNode.parentNode.parentNode; - relX = (event.pageX - superNode.offsetLeft - node.offsetLeft); - relY = (event.pageY - superNode.offsetTop - node.offsetTop); - - if (event.button == 0 - && relX < 24) { - event.cancelBubble = true; - event.returnValue = false; - - var popup = document.getElementById(menuId); - hideMenu(event, popup); - - var menuTop = superNode.offsetTop + node.offsetTop + node.offsetHeight; - var menuLeft = superNode.offsetLeft + node.offsetLeft; - var heightDiff = (window.innerHeight - - (menuTop + popup.offsetHeight)); - if (heightDiff < 0) - menuTop += heightDiff; - - var leftDiff = (window.innerWidth - - (menuLeft + popup.offsetWidth)); - if (leftDiff < 0) - menuLeft -= popup.offsetWidth; - - popup.style.top = menuTop + "px"; - popup.style.left = menuLeft + "px"; - popup.style.visibility = "visible"; - - bodyOnClick = "" + document.body.getAttribute("onclick"); - document.body.setAttribute("onclick", "onBodyClick('" + menuId + "');"); - document.currentPopupMenu = popup; - } -} - -function setSearchCriteria(event) -{ - searchField = document.getElementById('searchValue'); - searchCriteria = document.getElementById('searchCriteria'); - - var node = event.target; - searchField.setAttribute("ghost-phrase", node.innerHTML); - searchCriteria = node.getAttribute('id'); -} - -function checkSearchValue(event) -{ - var form = event.target; - var searchField = document.getElementById('searchValue'); - var ghostPhrase = searchField.getAttribute('ghost-phrase'); - - if (searchField.value == ghostPhrase) - searchField.value = ""; -} - -function onSearchChange() -{ -} - -function onSearchMouseDown(event) -{ - searchField = document.getElementById('searchValue'); - superNode = searchField.parentNode.parentNode.parentNode; - relX = (event.pageX - superNode.offsetLeft - searchField.offsetLeft); - relY = (event.pageY - superNode.offsetTop - searchField.offsetTop); - - if (relY < 24) { - event.cancelBubble = true; - event.returnValue = false; - } -} - -function onSearchFocus(event) -{ - searchField = document.getElementById('searchValue'); - ghostPhrase = searchField.getAttribute("ghost-phrase"); - if (searchField.value == ghostPhrase) { - searchField.value = ""; - searchField.setAttribute("modified", ""); - } else { - searchField.select(); - } - - searchField.style.color = "#000"; -} - -function onSearchBlur() -{ - var searchField = document.getElementById('searchValue'); - var ghostPhrase = searchField.getAttribute("ghost-phrase"); - - if (searchField.value == "") { - searchField.setAttribute("modified", ""); - searchField.style.color = "#aaa"; - searchField.value = ghostPhrase; - } else if (searchField.value == ghostPhrase) { - searchField.setAttribute("modified", ""); - searchField.style.color = "#aaa"; - } else { - searchField.setAttribute("modified", "yes"); - searchField.style.color = "#000"; - } -} - -function initCriteria() -{ - var searchCriteria = document.getElementById('searchCriteria'); - var searchField = document.getElementById('searchValue'); - var firstOption; - - if (searchCriteria.value == '' - || searchField.value == '') { - firstOption = document.getElementById('searchOptions').childNodes[1]; - searchCriteria.value = firstOption.getAttribute('id'); - searchField.value = firstOption.innerHTML; - searchField.setAttribute('ghost-phrase', firstOption.innerHTML); - searchField.setAttribute("modified", ""); - searchField.style.color = "#aaa"; - } -} - function deleteSelectedMails() { } @@ -994,7 +870,7 @@ function newContactFromEmail(sender) { if (email.length > 0) { emailre.exec(""); - w = window.open(UserFolderURL + "/Contacts/new?contactEmail=" + email, + w = window.open(UserFolderURL + "Contacts/new?contactEmail=" + email, "SOGo_new_contact", "width=680,height=520,resizable=1,scrollbars=1,toolbar=0," + "location=0,directories=0,status=0,menubar=0," diff --git a/UI/WebServerResources/SchedulerUI.js b/UI/WebServerResources/SchedulerUI.js index 09e7a9881..9cac73cd1 100644 --- a/UI/WebServerResources/SchedulerUI.js +++ b/UI/WebServerResources/SchedulerUI.js @@ -2,6 +2,7 @@ var activeAjaxRequests = 0; var sortOrder = ''; var sortKey = ''; +var listFilter = 'view_all'; function triggerAjaxRequest(url, callback, userdata) { this.http = createHTTPClient(); @@ -12,6 +13,7 @@ function triggerAjaxRequest(url, callback, userdata) { if (http) { http.onreadystatechange = function() { +// log ("state changed (" + http.readyState + "): " + url); try { if (http.readyState == 4 && activeAjaxRequests > 0) { @@ -65,12 +67,42 @@ var currentView = 'day'; function newEvent(sender) { var urlstr = ApplicationBaseURL + "new"; - window.open(urlstr, "SOGo_compose", + window.open(urlstr, "", "width=680,height=520,resizable=1,scrollbars=1,toolbar=0," + "location=0,directories=0,status=0,menubar=0,copyhistory=0"); + return false; /* stop following the link */ } +function _editEventId(id) { + var urlstr = ApplicationBaseURL + id + "/edit"; + + var win = window.open(urlstr, "SOGo_edit_" + id, + "width=680,height=520,resizable=1,scrollbars=1,toolbar=0," + + "location=0,directories=0,status=0,menubar=0,copyhistory=0"); + win.focus(); +} + +function editEvent() { + var list = document.getElementById("appointmentsList"); + var nodes = list.getSelectedRowsId(); + + if (nodes.length > 0) { + var row = nodes[0]; + _editEventId(row); + } + + return false; /* stop following the link */ +} + +function editDoubleClickedEvent(node) +{ + var id = node.getAttribute("id"); + _editEventId(id); + + return false; +} + function displayAppointment(sender) { var aptId = sender.getAttribute("aptId"); var urlstr = ApplicationBaseURL + aptId + "/view"; @@ -125,14 +157,12 @@ function onDaySelect(node) document.selectedDate = td; changeDayDisplay(currentDay, null); + if (listFilter == 'view_selectedday') + refreshAppointments(); return false; } -function initCriteria() -{ -} - function onDateSelectorGotoMonth(node) { var day = node.getAttribute("date"); @@ -153,8 +183,8 @@ function onCalendarGotoDay(node) function gotoToday() { - changeDateSelectorDisplay(); changeDayDisplay(); + changeDateSelectorDisplay(); return false; } @@ -163,6 +193,8 @@ function dateSelectorCallback(http) { var div = document.getElementById("dateSelectorView"); + log ("dateselectorcallback: " + div); + if (http.readyState == 4 && http.status == 200) { document.dateSelectorAjaxRequest = null; @@ -180,18 +212,18 @@ function appointmentsListCallback(http) if (http.readyState == 4 && http.status == 200) { - log ("babla"); +// log ("babla"); document.dateSelectorAjaxRequest = null; - log ("babla"); +// log ("babla"); div.innerHTML = http.responseText; - log ("babla"); +// log ("babla"); - log ("received " + http.callbackData); +// log ("received " + http.callbackData); var params = parseQueryParameters(http.callbackData); sortKey = params["sort"]; sortOrder = params["desc"]; - log ("sorting = " + sortKey + sortOrder); +// log ("sorting = " + sortKey + sortOrder); } else log ("ajax fuckage"); @@ -232,8 +264,10 @@ function changeDateSelectorDisplay(day, event) // if (currentDay.length > 0) // url += '&selectedDay=' + currentDay; + log ("changeDateSelectorDisplay: " + url); if (document.dateSelectorAjaxRequest) { +// log ("aborting dateselector ajaxrq"); document.dateSelectorAjaxRequest.aborted = true; document.dateSelectorAjaxRequest.abort(); } @@ -251,7 +285,10 @@ function changeDayDisplay(day, event) if (day) url += "?day=" + day; + log ("changeDayDisplay: " + url); + if (document.dayDisplayAjaxRequest) { +// log ("aborting day ajaxrq"); document.dayDisplayAjaxRequest.aborted = true; document.dayDisplayAjaxRequest.abort(); } @@ -266,6 +303,7 @@ function dayDisplayCallback(http) { var div = document.getElementById("calendarView"); + log ("daydisplaycallback: " + div); if (http.readyState == 4 && http.status == 200) { document.dateSelectorAjaxRequest = null; @@ -293,19 +331,17 @@ function onAppointmentContextMenu(event, element) var topNode = document.getElementById('appointmentsList'); log(topNode); - var menu = document.getElementById('appointmentsListMenu'); menu.addEventListener("hideMenu", onAppointmentContextMenuHide, false); onMenuClick(event, 'appointmentsListMenu'); var topNode = document.getElementById('appointmentsList'); - var selectedNodeIds = collectSelectedRows(); - topNode.menuSelectedRows = selectedNodeIds; - for (var i = 0; i < selectedNodeIds.length; i++) { - var selectedNode = document.getElementById(selectedNodeIds[i]); - deselectNode (selectedNode); - } + var selectedNodes = topNode.getSelectedRows(); + topNode.menuSelectedRows = selectedNodes; + for (var i = 0; i < selectedNodes.length; i++) + deselectNode (selectedNodes[i]); + topNode.menuSelectedEntry = element; selectNode(element); } @@ -338,7 +374,7 @@ function _loadAppointmentHref(href) { this.document.appointmentsListAjaxRequest.abort(); } url = ApplicationBaseURL + href; - log ("url: " + url); +// log ("url: " + url); this.document.appointmentsListAjaxRequest = triggerAjaxRequest(url, appointmentsListCallback, href); @@ -353,7 +389,19 @@ function onHeaderClick(node) } function refreshAppointments() { - var href = "aptlist?desc=" + sortOrder + "&sort=" + sortKey; + var href = ("aptlist?desc=" + sortOrder + + "&sort=" + sortKey + + "&day=" + currentDay + + "&filterpopup=" + listFilter); return _loadAppointmentHref(href); } + +function onListFilterChange() { + var node = document.getElementById("filterpopup"); + + listFilter = node.value; +// log ("listFilter = " + listFilter); + + return refreshAppointments(); +} diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index feeb30367..25e1f53d5 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -727,6 +727,122 @@ function dragHandleDoubleClick(event) { } } } + +/* search field */ +function popupSearchMenu(event, menuId) +{ + var node = event.target; + relX = event.pageX - node.cascadeLeftOffset(); + relY = event.pageY - node.cascadeTopOffset(); + + if (event.button == 0 + && relX < 24) { + event.cancelBubble = true; + event.returnValue = false; + + var popup = document.getElementById(menuId); + hideMenu(event, popup); + + popup.style.top = node.offsetHeight + "px"; + popup.style.left = (node.offsetLeft + 3) + "px"; + popup.style.visibility = "visible"; + + bodyOnClick = "" + document.body.getAttribute("onclick"); + document.body.setAttribute("onclick", "onBodyClick('" + menuId + "');"); + document.currentPopupMenu = popup; + } +} + +function setSearchCriteria(event) +{ + searchValue = document.getElementById('searchValue'); + searchCriteria = document.getElementById('searchCriteria'); + + var node = event.target; + searchValue.setAttribute("ghost-phrase", node.innerHTML); + searchCriteria = node.getAttribute('id'); +} + +function checkSearchValue(event) +{ + var form = event.target; + var searchValue = document.getElementById('searchValue'); + var ghostPhrase = searchValue.getAttribute('ghost-phrase'); + + if (searchValue.value == ghostPhrase) + searchValue.value = ""; +} + +function onSearchChange() +{ + log ("changed..."); +} + +function onSearchMouseDown(event, searchValue) +{ + superNode = searchValue.parentNode.parentNode.parentNode; + relX = (event.pageX - superNode.offsetLeft - searchValue.offsetLeft); + relY = (event.pageY - superNode.offsetTop - searchValue.offsetTop); + + if (relY < 24) { + event.cancelBubble = true; + event.returnValue = false; + } +} + +function onSearchFocus(searchValue) +{ + ghostPhrase = searchValue.getAttribute("ghost-phrase"); + if (searchValue.value == ghostPhrase) { + searchValue.value = ""; + searchValue.setAttribute("modified", ""); + } else { + searchValue.select(); + } + + searchValue.style.color = "#000"; +} + +function onSearchBlur(searchValue) +{ + var ghostPhrase = searchValue.getAttribute("ghost-phrase"); + log ("search blur: '" + searchValue.value + "'"); + if (!searchValue.value) { + searchValue.setAttribute("modified", ""); + searchValue.style.color = "#aaa"; + searchValue.value = ghostPhrase; + } else if (searchValue.value == ghostPhrase) { + searchValue.setAttribute("modified", ""); + searchValue.style.color = "#aaa"; + } else { + searchValue.setAttribute("modified", "yes"); + searchValue.style.color = "#000"; + } +} + +function onSearchKeyDown(searchValue) +{ + if (searchValue.timer) + clearTimeout(searchValue.timer); + + searchValue.timer = setTimeout("onSearchFormSubmit()", 1000); +} + +function initCriteria() +{ + var searchCriteria = document.getElementById('searchCriteria'); + var searchValue = document.getElementById('searchValue'); + var firstOption; + + firstOption = document.getElementById('searchOptions').childNodes[1]; + searchCriteria.value = firstOption.getAttribute('id'); + searchValue.setAttribute('ghost-phrase', firstOption.innerHTML); + if (searchValue.value == '') { + searchValue.value = firstOption.innerHTML; + searchValue.setAttribute("modified", ""); + searchValue.style.color = "#aaa"; + } +} /* contact selector */