From fcb174bdfd2544dee9d64b2cb1291fe23daa99d6 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 28 Aug 2008 14:48:45 +0000 Subject: [PATCH] Monotone-Parent: d2bec7005b1132e0cdbaba9d59a590f4f9b95b6b Monotone-Revision: 7cc3351f7b4c30b2183e351afaf429ade9f6ab9b Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-08-28T14:48:45 Monotone-Branch: ca.inverse.sogo --- UI/WebServerResources/ContactsUI.js | 307 +++--- UI/WebServerResources/HTMLElement.js | 463 ++++----- UI/WebServerResources/HTMLInputElement.js | 76 +- UI/WebServerResources/HTMLTableElement.js | 2 + UI/WebServerResources/HTMLUListElement.js | 2 + .../JavascriptAPIExtensions.js | 26 +- UI/WebServerResources/MailerUI+dTree.js | 74 +- UI/WebServerResources/MailerUI.js | 544 +++++----- UI/WebServerResources/SOGoDragAndDrop.js | 396 +++---- UI/WebServerResources/SOGoDragHandles.js | 94 +- UI/WebServerResources/SOGoRootPage.js | 168 +-- UI/WebServerResources/SchedulerUI.js | 594 +++++------ UI/WebServerResources/UIxAclEditor.js | 164 +-- UI/WebServerResources/UIxAppointmentEditor.js | 38 +- UI/WebServerResources/UIxAttendeesEditor.js | 784 +++++++------- .../UIxCalUserRightsEditor.js | 2 + .../UIxCalendarProperties.js | 10 +- UI/WebServerResources/UIxColorPicker.js | 2 + UI/WebServerResources/UIxComponentEditor.js | 18 +- UI/WebServerResources/UIxContactEditor.js | 62 +- .../UIxContactsUserFolders.js | 160 +-- .../UIxContactsUserRightsEditor.js | 4 +- UI/WebServerResources/UIxMailEditor.js | 978 +++++++++--------- UI/WebServerResources/UIxMailPopupView.js | 12 +- UI/WebServerResources/UIxMailToSelection.js | 34 +- .../UIxMailUserRightsEditor.js | 6 +- UI/WebServerResources/UIxMailView.js | 2 + UI/WebServerResources/UIxOccurenceDialog.js | 6 +- UI/WebServerResources/UIxPreferences.js | 12 +- UI/WebServerResources/UIxRecurrenceEditor.js | 78 +- UI/WebServerResources/UIxTaskEditor.js | 150 +-- UI/WebServerResources/generic.js | 216 ++-- 32 files changed, 2773 insertions(+), 2711 deletions(-) diff --git a/UI/WebServerResources/ContactsUI.js b/UI/WebServerResources/ContactsUI.js index 7187b0275..cdb140ef2 100644 --- a/UI/WebServerResources/ContactsUI.js +++ b/UI/WebServerResources/ContactsUI.js @@ -1,3 +1,4 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ /* JavaScript for SOGoContacts */ var cachedContacts = {}; @@ -23,7 +24,7 @@ function validateEditorInput(sender) { if (errortext.length > 0) { alert(labels.error_validationfailed + ":\n" - + errortext); + + errortext); return false; } return true; @@ -39,11 +40,11 @@ function openContactsFolder(contactsFolder, reload, idx) { var searchValue = search["value"]; if (searchValue && searchValue.length > 0) url += ("&search=" + search["criteria"] - + "&value=" + escape(searchValue.utf8encode())); + + "&value=" + escape(searchValue.utf8encode())); var sortAttribute = sorting["attribute"]; if (sortAttribute && sortAttribute.length > 0) url += ("&sort=" + sorting["attribute"] - + "&asc=" + sorting["ascending"]); + + "&asc=" + sorting["ascending"]); var selection; if (idx) { @@ -52,9 +53,9 @@ function openContactsFolder(contactsFolder, reload, idx) { else if (contactsFolder == Contact.currentAddressBook) { var contactsList = $("contactsList"); if (contactsList) - selection = contactsList.getSelectedRowsId(); -// else -// window.alert("no contactsList"); + selection = contactsList.getSelectedRowsId(); + // else + // window.alert("no contactsList"); } else selection = null; @@ -88,85 +89,85 @@ function contactsListCallback(http) { var div = $("contactsListContent"); var table = $("contactsList"); if (table) { - // Update table - var data = http.responseText; - var html = data.replace(/^(.*\n)*.*( 0) { - var sortHeader; - if (sorting["attribute"] == "displayName") - sortHeader = $("nameHeader"); - else if (sorting["attribute"] == "mail") - sortHeader = $("mailHeader"); - else if (sorting["attribute"] == "screenName") - sortHeader = $("screenNameHeader"); - else if (sorting["attribute"] == "org") - sortHeader = $("orgHeader"); - else if (sorting["attribute"] == "phone") - sortHeader = $("phoneHeader"); - else - sortHeader = null; + var sortHeader; + if (sorting["attribute"] == "displayName") + sortHeader = $("nameHeader"); + else if (sorting["attribute"] == "mail") + sortHeader = $("mailHeader"); + else if (sorting["attribute"] == "screenName") + sortHeader = $("screenNameHeader"); + else if (sorting["attribute"] == "org") + sortHeader = $("orgHeader"); + else if (sorting["attribute"] == "phone") + sortHeader = $("phoneHeader"); + else + sortHeader = null; - if (sortHeader) { - var sortImages = $(table.tHead).select(".sortImage"); - $(sortImages).each(function(item) { - item.remove(); - }); + if (sortHeader) { + var sortImages = $(table.tHead).select(".sortImage"); + $(sortImages).each(function(item) { + item.remove(); + }); - var sortImage = createElement("img", "messageSortImage", "sortImage"); - sortHeader.insertBefore(sortImage, sortHeader.firstChild); - if (sorting["ascending"]) - sortImage.src = ResourcesURL + "/title_sortdown_12x12.png"; - else - sortImage.src = ResourcesURL + "/title_sortup_12x12.png"; - } + var sortImage = createElement("img", "messageSortImage", "sortImage"); + sortHeader.insertBefore(sortImage, sortHeader.firstChild); + if (sorting["ascending"]) + sortImage.src = ResourcesURL + "/title_sortdown_12x12.png"; + else + sortImage.src = ResourcesURL + "/title_sortup_12x12.png"; + } } var selected = http.callbackData; if (selected) { - for (var i = 0; i < selected.length; i++) { - var row = $(selected[i]); - if (row) { - var rowPosition = row.rowIndex * row.getHeight(); - if (div.getHeight() < rowPosition) - div.scrollTop = rowPosition; // scroll to selected contact - row.selectElement(); - } - } + for (var i = 0; i < selected.length; i++) { + var row = $(selected[i]); + if (row) { + var rowPosition = row.rowIndex * row.getHeight(); + if (div.getHeight() < rowPosition) + div.scrollTop = rowPosition; // scroll to selected contact + row.selectElement(); + } + } } } else { var table = $("contactsList"); if (table) { - var sortImages = $(table.tHead).select(".sortImage"); - $(sortImages).each(function(item) { - item.remove(); - }); - var tBody = $(table.tBodies[0]); - var length = tBody.rows.length; - for (var i = length - 1; i > -1; i--) - tBody.removeChild(tBody.rows[i]); + var sortImages = $(table.tHead).select(".sortImage"); + $(sortImages).each(function(item) { + item.remove(); + }); + var tBody = $(table.tBodies[0]); + var length = tBody.rows.length; + for (var i = length - 1; i > -1; i--) + tBody.removeChild(tBody.rows[i]); } } } @@ -243,7 +244,7 @@ function _onContactMenuAction(folderItem, action, refresh) { if (Object.isArray(document.menuTarget) && selectedFolders.length > 0) { var selectedFolderId = $(selectedFolders[0]).readAttribute("id"); var contactIds = $(document.menuTarget).collect(function(row) { - return row.getAttribute("id"); + return row.getAttribute("id"); }); var url = ApplicationBaseURL + selectedFolderId + "/" + action + "?folder=" + folderId + "&uid=" @@ -269,16 +270,16 @@ function actionContactCallback(http) { if (isHttpStatus204(http.status)) { var refreshFolderId = http.callbackData; if (refreshFolderId) - openContactsFolder(refreshFolderId, true); + openContactsFolder(refreshFolderId, true); } else { var html = new Element("div").update(http.responseText); var error = html.select("p").first().firstChild.nodeValue.trim(); log("actionContactCallback failed: error " + http.status + " (" + error + ")"); if (parseInt(http.status) == 403) - window.alert(labels["You don't have the required privileges to perform the operation."]); + window.alert(labels["You don't have the required privileges to perform the operation."]); else if (error) - window.alert(labels[error]); + window.alert(labels[error]); refreshCurrentFolder(); } } @@ -296,7 +297,7 @@ function loadContact(idx) { } else { var url = (URLForFolderID(Contact.currentAddressBook) - + "/" + idx + "/view?noframe=1"); + + "/" + idx + "/view?noframe=1"); document.contactAjaxRequest = triggerAjaxRequest(url, contactLoadCallback, idx); } @@ -353,7 +354,7 @@ function onContactRowDblClick(event) { var contactId = this.getAttribute('contactid'); openContactWindow(URLForFolderID(Contact.currentAddressBook) - + "/" + contactId + "/edit", contactId); + + "/" + contactId + "/edit", contactId); return false; } @@ -404,7 +405,7 @@ function onToolbarEditSelectedContacts(event) { for (var i = 0; i < rows.length; i++) { openContactWindow(URLForFolderID(Contact.currentAddressBook) - + "/" + rows[i] + "/edit", rows[i]); + + "/" + rows[i] + "/edit", rows[i]); } return false; @@ -421,8 +422,8 @@ function onToolbarWriteToSelectedContacts(event) { } openMailComposeWindow(ApplicationBaseURL + "../Mail/compose" - + "?folder=" + Contact.currentAddressBook.substring(1) - + "&uid=" + rows.join("&uid=")); + + "?folder=" + Contact.currentAddressBook.substring(1) + + "&uid=" + rows.join("&uid=")); if (document.body.hasClassName("popup")) window.close(); @@ -459,7 +460,7 @@ function onContactDeleteEventCallback(http) { var row = $(http.callbackData); row.parentNode.removeChild(row); if (Contact.currentContact == http.callbackData) - $("contactView").update(); + $("contactView").update(); } else if (parseInt(http.status) == 403) { var row = $(http.callbackData); @@ -550,8 +551,8 @@ function onConfirmContactSelection(event) { if (selector) { var selectorId = selector.getAttribute("id"); selectorList = opener.window.document.getElementById('uixselector-' - + selectorId - + '-uidList'); + + selectorId + + '-uidList'); initialValues = selectorList.value; } @@ -563,7 +564,7 @@ function onConfirmContactSelection(event) { var email = '' + rows[i].cells[1].innerHTML; window.opener.addContact(tag, currentAddressBookName + '/' + cname, - cid, cname, email); + cid, cname, email); } if (selector && selector.changeNotification @@ -583,7 +584,7 @@ function refreshContacts(contactId) { function onAddressBookNew(event) { createFolder(window.prompt(labels["Name of the Address Book"], ""), - appendAddressBook); + appendAddressBook); preventDefault(event); } @@ -620,8 +621,8 @@ function appendAddressBook(name, folder) { li.setAttribute("owner", owner); li.addClassName("local"); li.appendChild(document.createTextNode(name - .replace("<", "<", "g") - .replace(">", ">", "g"))); + .replace("<", "<", "g") + .replace(">", ">", "g"))); setEventsOnAddressBook(li); updateAddressBooksMenus(); } @@ -657,8 +658,8 @@ function onAddressBookRemove(event) { node.deselect(); var owner = node.getAttribute("owner"); if (owner == "nobody") { - var label = labels["You cannot remove nor unsubscribe from a public addressbook."]; - window.alert(label); + var label = labels["You cannot remove nor unsubscribe from a public addressbook."]; + window.alert(label); } else if (owner == UserLogin) { var folderIdElements = node.getAttribute("id").split(":"); @@ -669,8 +670,8 @@ function onAddressBookRemove(event) { onFolderSelectionChange(); } else { - var folderId = node.getAttribute("id"); - unsubscribeFromFolder(folderId, owner, onFolderUnsubscribeCB, folderId); + var folderId = node.getAttribute("id"); + unsubscribeFromFolder(folderId, owner, onFolderUnsubscribeCB, folderId); } } @@ -678,24 +679,24 @@ function onAddressBookRemove(event) { } function deletePersonalAddressBook(folderId) { - if (folderId == "personal") { - var label = labels["You cannot remove nor unsubscribe from your personal addressbook."]; - window.alert(label); - } - else { - var label - = labels["Are you sure you want to delete the selected address book?"]; - if (window.confirm(label)) { - if (document.deletePersonalABAjaxRequest) { - document.deletePersonalABAjaxRequest.aborted = true; - document.deletePersonalABAjaxRequest.abort(); - } - var url = ApplicationBaseURL + folderId + "/deleteFolder"; - document.deletePersonalABAjaxRequest - = triggerAjaxRequest(url, deletePersonalAddressBookCallback, - folderId); - } - } + if (folderId == "personal") { + var label = labels["You cannot remove nor unsubscribe from your personal addressbook."]; + window.alert(label); + } + else { + var label + = labels["Are you sure you want to delete the selected address book?"]; + if (window.confirm(label)) { + if (document.deletePersonalABAjaxRequest) { + document.deletePersonalABAjaxRequest.aborted = true; + document.deletePersonalABAjaxRequest.abort(); + } + var url = ApplicationBaseURL + folderId + "/deleteFolder"; + document.deletePersonalABAjaxRequest + = triggerAjaxRequest(url, deletePersonalAddressBookCallback, + folderId); + } + } } function deletePersonalAddressBookCallback(http) { @@ -707,13 +708,13 @@ function deletePersonalAddressBookCallback(http) { var i = 0; var done = false; while (!done && i < children.length) { - var currentFolderId = children[i].getAttribute("id").substr(1); - if (currentFolderId == http.callbackData) { - ul.removeChild(children[i]); - done = true; - } - else - i++; + var currentFolderId = children[i].getAttribute("id").substr(1); + if (currentFolderId == http.callbackData) { + ul.removeChild(children[i]); + done = true; + } + else + i++; } } document.deletePersonalABAjaxRequest = null; @@ -791,10 +792,10 @@ function onAddressBookMenuPrepareVisibility() { if (selectedFolder) { var selectedFolderId = selectedFolder.readAttribute("id"); $(this).select("li").each(function(menuEntry) { - if (menuEntry.readAttribute("folderId") == selectedFolderId) - menuEntry.addClassName("disabled"); - else - menuEntry.removeClassName("disabled"); + if (menuEntry.readAttribute("folderId") == selectedFolderId) + menuEntry.addClassName("disabled"); + else + menuEntry.removeClassName("disabled"); }); } } @@ -805,39 +806,39 @@ function updateAddressBooksMenus() { var pageContent = $("pageContent"); var contactFolders = contactFoldersList.select("li"); var contactActions = new Hash({ move: onContactMenuMove, - copy: onContactMenuCopy }); + copy: onContactMenuCopy }); var actions = contactActions.keys(); for (var j = 0; j < actions.size(); j++) { var key = actions[j]; - var callbacks = new Array(); - var menuId = key + "ContactMenu"; - var menuDIV = $(menuId); - if (menuDIV) - menuDIV.parentNode.removeChild(menuDIV); + var callbacks = new Array(); + var menuId = key + "ContactMenu"; + var menuDIV = $(menuId); + if (menuDIV) + menuDIV.parentNode.removeChild(menuDIV); - menuDIV = document.createElement("div"); - pageContent.appendChild(menuDIV); + menuDIV = document.createElement("div"); + pageContent.appendChild(menuDIV); - var menu = document.createElement("ul"); - menuDIV.appendChild(menu); + var menu = document.createElement("ul"); + menuDIV.appendChild(menu); - $(menuDIV).addClassName("menu"); - menuDIV.setAttribute("id", menuId); + $(menuDIV).addClassName("menu"); + menuDIV.setAttribute("id", menuId); - var submenuIds = new Array(); - for (var i = 0; i < contactFolders.length; i++) { - if (contactFolders[i].hasClassName("local")) { - var menuEntry = new Element("li", - { folderId: contactFolders[i].readAttribute("id"), - owner: contactFolders[i].readAttribute("owner") } - ).update(contactFolders[i].innerHTML); - menu.appendChild(menuEntry); - callbacks.push(contactActions.get(key)); - } - } - menuDIV.prepareVisibility = onAddressBookMenuPrepareVisibility; - initMenu(menuDIV, callbacks); - } + var submenuIds = new Array(); + for (var i = 0; i < contactFolders.length; i++) { + if (contactFolders[i].hasClassName("local")) { + var menuEntry = new Element("li", + { folderId: contactFolders[i].readAttribute("id"), + owner: contactFolders[i].readAttribute("owner") } + ).update(contactFolders[i].innerHTML); + menu.appendChild(menuEntry); + callbacks.push(contactActions.get(key)); + } + } + menuDIV.prepareVisibility = onAddressBookMenuPrepareVisibility; + initMenu(menuDIV, callbacks); + } } } @@ -857,13 +858,13 @@ function onAddressBookModify(event) { if (UserLogin == selected.getAttribute("owner")) { var currentName = selected.innerHTML; var newName = window.prompt(labels["Address Book Name"], - currentName); + currentName); if (newName && newName.length > 0 - && newName != currentName) { + && newName != currentName) { var url = (URLForFolderID(selected.getAttribute("id")) - + "/renameFolder?name=" + escape(newName.utf8encode())); + + "/renameFolder?name=" + escape(newName.utf8encode())); triggerAjaxRequest(url, folderRenameCallback, - {node: selected, name: newName}); + {node: selected, name: newName}); } } else window.alert(clabels["Unable to rename that folder!"]); @@ -887,7 +888,7 @@ function onMenuSharing(event) { var owner = selected.getAttribute("owner"); if (owner == "nobody") window.alert(clabels["The user rights cannot be" - + " edited for this object!"]); + + " edited for this object!"]); else { var title = this.innerHTML; var url = URLForFolderID(selected.getAttribute("id")); @@ -971,12 +972,12 @@ function onContactMenuPrepareVisibility() { function getMenus() { var menus = {}; menus["contactFoldersMenu"] = new Array(onAddressBookModify, "-", newContact, - null, "-", onAddressBookRemove, "-", - onMenuSharing); + null, "-", onAddressBookRemove, "-", + onMenuSharing); menus["contactMenu"] = new Array(onMenuEditContact, "-", - onMenuWriteToContact, onMenuAIMContact, - "-", onMenuDeleteContact, "-", - "moveContactMenu", "copyContactMenu"); + onMenuWriteToContact, onMenuAIMContact, + "-", onMenuDeleteContact, "-", + "moveContactMenu", "copyContactMenu"); menus["searchMenu"] = new Array(setSearchCriteria); var contactFoldersMenu = $("contactFoldersMenu"); diff --git a/UI/WebServerResources/HTMLElement.js b/UI/WebServerResources/HTMLElement.js index e225fc3c1..cf415acf0 100644 --- a/UI/WebServerResources/HTMLElement.js +++ b/UI/WebServerResources/HTMLElement.js @@ -1,281 +1,282 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + /* custom extensions to the DOM api */ -Element.addMethods({ +Element.addMethods( +{ + addInterface: function(element, objectInterface) { + element = $(element); + Object.extend(element, objectInterface); + if (element.bind) + element.bind(); + }, - addInterface: function(element, objectInterface) { - element = $(element); - Object.extend(element, objectInterface); - if (element.bind) - element.bind(); - }, + childNodesWithTag: function(element, tagName) { + element = $(element); - childNodesWithTag: function(element, tagName) { - element = $(element); - - var matchingNodes = new Array(); - var tagName = tagName.toUpperCase(); + var matchingNodes = new Array(); + var tagName = tagName.toUpperCase(); - for (var i = 0; i < element.childNodes.length; i++) { - var childNode = $(element.childNodes[i]); - if (Object.isElement(childNode) - && childNode.tagName - && childNode.tagName.toUpperCase() == tagName) - matchingNodes.push(childNode); - } + for (var i = 0; i < element.childNodes.length; i++) { + var childNode = $(element.childNodes[i]); + if (Object.isElement(childNode) + && childNode.tagName + && childNode.tagName.toUpperCase() == tagName) + matchingNodes.push(childNode); + } - return matchingNodes; - }, + return matchingNodes; + }, - getParentWithTagName: function(element, tagName) { - element = $(element); - var currentElement = element; - tagName = tagName.toUpperCase(); + getParentWithTagName: function(element, tagName) { + element = $(element); + var currentElement = element; + tagName = tagName.toUpperCase(); - currentElement = currentElement.parentNode; - while (currentElement - && currentElement.tagName != tagName) { - currentElement = currentElement.parentNode; - } + currentElement = currentElement.parentNode; + while (currentElement + && currentElement.tagName != tagName) { + currentElement = currentElement.parentNode; + } - return currentElement; - }, + return currentElement; + }, - cascadeLeftOffset: function(element) { - element = $(element); - var currentElement = element; + cascadeLeftOffset: function(element) { + element = $(element); + var currentElement = element; - var offset = 0; - while (currentElement) { - offset += currentElement.offsetLeft; - currentElement = $(currentElement).getParentWithTagName("div"); - } + var offset = 0; + while (currentElement) { + offset += currentElement.offsetLeft; + currentElement = $(currentElement).getParentWithTagName("div"); + } - return offset; - }, + return offset; + }, - cascadeTopOffset: function(element) { - element = $(element); - var currentElement = element; - var offset = 0; + cascadeTopOffset: function(element) { + element = $(element); + var currentElement = element; + var offset = 0; - var i = 0; + var i = 0; - while (currentElement && currentElement.tagName) { - offset += currentElement.offsetTop; - currentElement = currentElement.parentNode; - i++; - } + while (currentElement && currentElement.tagName) { + offset += currentElement.offsetTop; + currentElement = currentElement.parentNode; + i++; + } - return offset; - }, + return offset; + }, - dump: function(element, additionalInfo, additionalKeys) { - element = $(element); - var id = element.getAttribute("id"); - var nclass = element.getAttribute("class"); + dump: function(element, additionalInfo, additionalKeys) { + element = $(element); + var id = element.getAttribute("id"); + var nclass = element.getAttribute("class"); - var str = element.tagName; - if (id) - str += "; id = " + id; - if (nclass) - str += "; class = " + nclass; + var str = element.tagName; + if (id) + str += "; id = " + id; + if (nclass) + str += "; class = " + nclass; - if (additionalInfo) - str += "; " + additionalInfo; + if (additionalInfo) + str += "; " + additionalInfo; - if (additionalKeys) - for (var i = 0; i < additionalKeys.length; i++) { - var value = element.getAttribute(additionalKeys[i]); - if (value) - str += "; " + additionalKeys[i] + " = " + value; - } + if (additionalKeys) + for (var i = 0; i < additionalKeys.length; i++) { + var value = element.getAttribute(additionalKeys[i]); + if (value) + str += "; " + additionalKeys[i] + " = " + value; + } - log (str); - }, + log (str); + }, - getSelectedNodes: function(element) { - element = $(element); - var selArray = new Array(); + getSelectedNodes: function(element) { + element = $(element); + var selArray = new Array(); - for (var i = 0; i < element.childNodes.length; i++) { - node = element.childNodes.item(i); - if (node.nodeType == 1 - && isNodeSelected(node)) - selArray.push(node); - } + for (var i = 0; i < element.childNodes.length; i++) { + node = element.childNodes.item(i); + if (node.nodeType == 1 + && isNodeSelected(node)) + selArray.push(node); + } - return selArray; - }, + return selArray; + }, - getSelectedNodesId: function(element) { - element = $(element); - var selArray = new Array(); + getSelectedNodesId: function(element) { + element = $(element); + var selArray = new Array(); - for (var i = 0; i < element.childNodes.length; i++) { - node = element.childNodes.item(i); - if (node.nodeType == 1 - && isNodeSelected(node)) { - selArray.push(node.getAttribute("id")); } - } + for (var i = 0; i < element.childNodes.length; i++) { + node = element.childNodes.item(i); + if (node.nodeType == 1 + && isNodeSelected(node)) { + selArray.push(node.getAttribute("id")); } + } - return selArray; - }, + return selArray; + }, - onContextMenu: function(element, event) { - element = $(element); - var popup = element.sogoContextMenu; + onContextMenu: function(element, event) { + element = $(element); + var popup = element.sogoContextMenu; - if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); + if (document.currentPopupMenu) + hideMenu(document.currentPopupMenu); - var menuTop = Event.pointerY(event); - var menuLeft = Event.pointerX(event); - var heightDiff = (window.height() - - (menuTop + popup.offsetHeight)); - if (heightDiff < 0) - menuTop += heightDiff; + var menuTop = Event.pointerY(event); + var menuLeft = Event.pointerX(event); + var heightDiff = (window.height() + - (menuTop + popup.offsetHeight)); + if (heightDiff < 0) + menuTop += heightDiff; - var leftDiff = (window.width() - - (menuLeft + popup.offsetWidth)); - if (leftDiff < 0) - menuLeft -= popup.offsetWidth; + var leftDiff = (window.width() + - (menuLeft + popup.offsetWidth)); + if (leftDiff < 0) + menuLeft -= popup.offsetWidth; - if (popup.prepareVisibility) - popup.prepareVisibility(); + if (popup.prepareVisibility) + popup.prepareVisibility(); - popup.setStyle( { top: menuTop + "px", - left: menuLeft + "px", - visibility: "visible" } ); + popup.setStyle( { top: menuTop + "px", + left: menuLeft + "px", + visibility: "visible" } ); - document.currentPopupMenu = popup; - document.body.observe("click", onBodyClickMenuHandler); - }, + document.currentPopupMenu = popup; + document.body.observe("click", onBodyClickMenuHandler); + }, - attachMenu: function(element, menuName) { - element = $(element); - element.sogoContextMenu = $(menuName); - element.observe("contextmenu", - element.onContextMenu.bindAsEventListener(element)); - }, + attachMenu: function(element, menuName) { + element = $(element); + element.sogoContextMenu = $(menuName); + element.observe("contextmenu", + element.onContextMenu.bindAsEventListener(element)); + }, - selectElement: function(element) { - element = $(element); - element.addClassName('_selected'); - }, + selectElement: function(element) { + element = $(element); + element.addClassName('_selected'); + }, - selectRange: function(element, startIndex, endIndex) { - element = $(element); - var s; - var e; - var rows; + selectRange: function(element, startIndex, endIndex) { + element = $(element); + var s; + var e; + var rows; - if (startIndex > endIndex) { - s = endIndex; - e = startIndex; - } - else { - s = startIndex; - e = endIndex; - } - if (element.tagName == 'UL') - rows = element.getElementsByTagName('LI'); - else - rows = element.getElementsByTagName('TR'); - while (s <= e) { - if (rows[s].nodeType == 1) - $(rows[s]).selectElement(); - s++; - } - }, + if (startIndex > endIndex) { + s = endIndex; + e = startIndex; + } + else { + s = startIndex; + e = endIndex; + } + if (element.tagName == 'UL') + rows = element.getElementsByTagName('LI'); + else + rows = element.getElementsByTagName('TR'); + while (s <= e) { + if (rows[s].nodeType == 1) + $(rows[s]).selectElement(); + s++; + } + }, - deselect: function(element) { - element = $(element); - element.removeClassName('_selected'); - }, + deselect: function(element) { + element = $(element); + element.removeClassName('_selected'); + }, - deselectAll: function(element) { - element = $(element); - for (var i = 0; i < element.childNodes.length; i++) { - var node = element.childNodes.item(i); - if (node.nodeType == 1) - $(node).deselect(); - } - }, + deselectAll: function(element) { + element = $(element); + for (var i = 0; i < element.childNodes.length; i++) { + var node = element.childNodes.item(i); + if (node.nodeType == 1) + $(node).deselect(); + } + }, - setCaretTo: function(element, pos) { - element = $(element); - if (element.selectionStart) { // For Mozilla and Safari - element.focus(); - element.setSelectionRange(pos, pos); - } - else if (element.createTextRange) { // For IE - var range = element.createTextRange(); - range.move("character", pos); - range.select(); - } - }, + setCaretTo: function(element, pos) { + element = $(element); + if (element.selectionStart) { // For Mozilla and Safari + element.focus(); + element.setSelectionRange(pos, pos); + } + else if (element.createTextRange) { // For IE + var range = element.createTextRange(); + range.move("character", pos); + range.select(); + } + }, - selectText: function(element, start, end) { - element = $(element); - if (element.setSelectionRange) { // For Mozilla and Safari - element.setSelectionRange(start, end); - } - else if (element.createTextRange) { // For IE - var textRange = element.createTextRange(); - textRange.moveStart("character", start); - textRange.moveEnd("character", end-element.value.length); - textRange.select(); - } - else { - element.select(); - } - }, + selectText: function(element, start, end) { + element = $(element); + if (element.setSelectionRange) { // For Mozilla and Safari + element.setSelectionRange(start, end); + } + else if (element.createTextRange) { // For IE + var textRange = element.createTextRange(); + textRange.moveStart("character", start); + textRange.moveEnd("character", end-element.value.length); + textRange.select(); + } + else { + element.select(); + } + }, - getRadioValue: function(element, radioName) { - element = $(element); - var radioValue; - Form.getInputs(element, 'radio', radioName).each(function(input) { - if (input.checked) - radioValue = input.value; - }); - return radioValue; - }, + getRadioValue: function(element, radioName) { + element = $(element); + var radioValue; + Form.getInputs(element, 'radio', radioName).each(function(input) { + if (input.checked) + radioValue = input.value; + }); + return radioValue; + }, - setRadioValue: function(element, radioName, value) { - element = $(element); - var i = 0; + setRadioValue: function(element, radioName, value) { + element = $(element); + var i = 0; - Form.getInputs(element, 'radio', radioName).each(function(input) { - if (i == value) - input.checked = 1; - i++; - }); - }, + Form.getInputs(element, 'radio', radioName).each(function(input) { + if (i == value) + input.checked = 1; + i++; + }); + }, - getCheckBoxListValues: function(element, checkboxName) { - element = $(element); - var values = new Array(); - var i = 0; + getCheckBoxListValues: function(element, checkboxName) { + element = $(element); + var values = new Array(); + var i = 0; - Form.getInputs(element, 'checkbox', checkboxName).each(function(input) { - if (input.checked) - values.push(i+1); + Form.getInputs(element, 'checkbox', checkboxName).each(function(input) { + if (input.checked) + values.push(i+1); - i++; - }); - return values.join(","); - }, + i++; + }); + return values.join(","); + }, - setCheckBoxListValues: function(element, checkboxName, values) { - element = $(element); - var v = values.split(','); - var i = 1; + setCheckBoxListValues: function(element, checkboxName, values) { + element = $(element); + var v = values.split(','); + var i = 1; - Form.getInputs(element, 'checkbox', checkboxName).each(function(input) { + Form.getInputs(element, 'checkbox', checkboxName).each(function(input) { - if ($(v).indexOf(i+"") != -1) - input.checked = 1; - i++; - }); - } - -}); + if ($(v).indexOf(i+"") != -1) + input.checked = 1; + i++; + }); + } + }); diff --git a/UI/WebServerResources/HTMLInputElement.js b/UI/WebServerResources/HTMLInputElement.js index af297c9d2..6a142b490 100644 --- a/UI/WebServerResources/HTMLInputElement.js +++ b/UI/WebServerResources/HTMLInputElement.js @@ -1,4 +1,6 @@ -Form.Element.Methods._replicate = function(element) { +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + +Form.Element.Methods._replicate = function(element) { element = $(element); if (element.replica) { element.replica.value = $F(element); @@ -6,56 +8,56 @@ Form.Element.Methods._replicate = function(element) { onReplicaChangeEvent.initEvent("change", true, true); element.replica.dispatchEvent(onReplicaChangeEvent); } -} +}; Form.Element.Methods.assignReplica = function(element, otherInput) { - element = $(element); - if (!element._onChangeBound) { - element.observe("change", element._replicate, false); - element._onChangeBound = true; - } - element.replica = otherInput; -} + element = $(element); + if (!element._onChangeBound) { + element.observe("change", element._replicate, false); + element._onChangeBound = true; + } + element.replica = otherInput; +}; Form.Element.Methods.valueAsDate = function(element) { - return $F(element).asDate(); -} + return $F(element).asDate(); +}; Form.Element.Methods.setValueAsDate = function(element, dateValue) { - element = $(element); - if (!element.dateSeparator) - element._detectDateSeparator(); - element.value = dateValue.stringWithSeparator(element.dateSeparator); -} + element = $(element); + if (!element.dateSeparator) + element._detectDateSeparator(); + element.value = dateValue.stringWithSeparator(element.dateSeparator); +}; Form.Element.Methods.updateShadowValue = function(element) { - element = $(element); - element.setAttribute("shadow-value", $F(element)); -} + element = $(element); + element.setAttribute("shadow-value", $F(element)); +}; Form.Element.Methods._detectDateSeparator = function(element) { - element = $(element); - var date = $F(element).split("/"); - if (date.length == 3) - element.dateSeparator = "/"; - else - element.dateSeparator = "-"; -} + element = $(element); + var date = $F(element).split("/"); + if (date.length == 3) + element.dateSeparator = "/"; + else + element.dateSeparator = "-"; +}; Form.Element.Methods.valueAsShortDateString = function(element) { - element = $(element); - var dateStr = ''; + element = $(element); + var dateStr = ''; - if (!element.dateSeparator) - element._detectDateSeparator(); + if (!element.dateSeparator) + element._detectDateSeparator(); - var date = $F(element).split(element.dateSeparator); - if (element.dateSeparator == '/') - dateStr += date[2] + date[1] + date[0]; - else - dateStr += date[0] + date[1] + date[2]; + var date = $F(element).split(element.dateSeparator); + if (element.dateSeparator == '/') + dateStr += date[2] + date[1] + date[0]; + else + dateStr += date[0] + date[1] + date[2]; - return dateStr; -} + return dateStr; +}; Element.addMethods(); diff --git a/UI/WebServerResources/HTMLTableElement.js b/UI/WebServerResources/HTMLTableElement.js index b7275a783..02b1bc478 100644 --- a/UI/WebServerResources/HTMLTableElement.js +++ b/UI/WebServerResources/HTMLTableElement.js @@ -1,3 +1,5 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + Element.addMethods({ getSelectedRows: function(element) { element = $(element); diff --git a/UI/WebServerResources/HTMLUListElement.js b/UI/WebServerResources/HTMLUListElement.js index 6e7b793b4..5c7c290fb 100644 --- a/UI/WebServerResources/HTMLUListElement.js +++ b/UI/WebServerResources/HTMLUListElement.js @@ -1,3 +1,5 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + //HTMLUListElement.prototype.getSelectedRows = function() { // return this.getSelectedNodes(); //} diff --git a/UI/WebServerResources/JavascriptAPIExtensions.js b/UI/WebServerResources/JavascriptAPIExtensions.js index 9bb065151..171ca9946 100644 --- a/UI/WebServerResources/JavascriptAPIExtensions.js +++ b/UI/WebServerResources/JavascriptAPIExtensions.js @@ -1,3 +1,5 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + String.prototype.trim = function() { return this.replace(/(^\s+|\s+$)/g, ''); }; @@ -22,17 +24,17 @@ String.prototype.repeat = function(count) { String.prototype.capitalize = function() { return this.replace(/\w+/g, - function(a) { - return ( a.charAt(0).toUpperCase() - + a.substr(1).toLowerCase() ); - }); + function(a) { + return ( a.charAt(0).toUpperCase() + + a.substr(1).toLowerCase() ); + }); }; String.prototype.decodeEntities = function() { return this.replace(/&#(\d+);/g, - function(wholematch, parenmatch1) { - return String.fromCharCode(+parenmatch1); - }); + function(wholematch, parenmatch1) { + return String.fromCharCode(+parenmatch1); + }); }; String.prototype.asDate = function () { @@ -46,9 +48,9 @@ String.prototype.asDate = function () { newDate = new Date(date[0], date[1] - 1, date[2]); else { if (this.length == 8) { - newDate = new Date(this.substring(0, 4), - this.substring(4, 6) - 1, - this.substring(6, 8)); + newDate = new Date(this.substring(0, 4), + this.substring(4, 6) - 1, + this.substring(6, 8)); } } } @@ -177,7 +179,7 @@ Date.prototype.earlierDate = function(otherDate) { workDate.setTime(otherDate.getTime()); workDate.setHours(0); return ((this.getTime() < workDate.getTime()) - ? this : otherDate); + ? this : otherDate); }; Date.prototype.laterDate = function(otherDate) { @@ -188,7 +190,7 @@ Date.prototype.laterDate = function(otherDate) { workDate.setSeconds(59); workDate.setMilliseconds(999); return ((this.getTime() < workDate.getTime()) - ? otherDate : this); + ? otherDate : this); }; Date.prototype.beginOfWeek = function() { diff --git a/UI/WebServerResources/MailerUI+dTree.js b/UI/WebServerResources/MailerUI+dTree.js index 8d756a779..b14fb03f6 100644 --- a/UI/WebServerResources/MailerUI+dTree.js +++ b/UI/WebServerResources/MailerUI+dTree.js @@ -1,57 +1,59 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + var MailerUIdTreeExtension = { - elementCounter: 1, - folderIcons: { account: "tbtv_account_17x17.png", - inbox: "tbtv_inbox_17x17.png", - sent: "tbtv_sent_17x17.png", - draft: "tbtv_drafts_17x17.png", - trash: "tbtv_trash_17x17.png" }, - folderNames: { inbox: labels["InboxFolderName"], - sent: labels["SentFolderName"], - draft: labels["DraftsFolderName"], - trash: labels["TrashFolderName"] }, - _addFolderNode: function (parent, name, fullName, type) { - var icon = this.folderIcons[type]; - if (icon) - icon = ResourcesURL + "/" + icon; - else - icon = ""; - var displayName = this.folderNames[type]; - if (!displayName) - displayName = name; - this.add(this.elementCounter, parent, displayName, 1, '#', fullName, - type, '', '', icon, icon); - this.elementCounter++; - }, - _addFolder: function (parent, folder) { - var thisCounter = this.elementCounter; - this._addFolderNode(parent, folder.name, folder.fullName(), folder.type); - for (var i = 0; i < folder.children.length; i++) + elementCounter: 1, + folderIcons: { account: "tbtv_account_17x17.png", + inbox: "tbtv_inbox_17x17.png", + sent: "tbtv_sent_17x17.png", + draft: "tbtv_drafts_17x17.png", + trash: "tbtv_trash_17x17.png" }, + folderNames: { inbox: labels["InboxFolderName"], + sent: labels["SentFolderName"], + draft: labels["DraftsFolderName"], + trash: labels["TrashFolderName"] }, + _addFolderNode: function (parent, name, fullName, type) { + var icon = this.folderIcons[type]; + if (icon) + icon = ResourcesURL + "/" + icon; + else + icon = ""; + var displayName = this.folderNames[type]; + if (!displayName) + displayName = name; + this.add(this.elementCounter, parent, displayName, 1, '#', fullName, + type, '', '', icon, icon); + this.elementCounter++; + }, + _addFolder: function (parent, folder) { + var thisCounter = this.elementCounter; + this._addFolderNode(parent, folder.name, folder.fullName(), folder.type); + for (var i = 0; i < folder.children.length; i++) this._addFolder(thisCounter, folder.children[i]); - }, - addMailAccount: function (mailAccount) { - this._addFolder(0, mailAccount); + }, + addMailAccount: function (mailAccount) { + this._addFolder(0, mailAccount); }, - setCookie: function(cookieName, cookieValue, expires, path, domain, secure) { + setCookie: function(cookieName, cookieValue, expires, path, domain, secure) { }, - getCookie: function(cookieName) { + getCookie: function(cookieName) { return (""); }, - updateCookie: function () { + updateCookie: function () { if (Mailer.foldersStateTimer) clearTimeout(Mailer.foldersStateTimer); Mailer.foldersStateTimer = setTimeout('saveFoldersState()', 3000); // 3 seconds }, - getFoldersState: function () { + getFoldersState: function () { var expandedFolders = new Array(); for (var n = 0; n < this.aNodes.length; n++) { if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) { - expandedFolders.push(this.aNodes[n].dataname); + expandedFolders.push(this.aNodes[n].dataname); } } return expandedFolders.toJSON(); }, - autoSync: function() { + autoSync: function() { this.config.useCookies = true; } }; diff --git a/UI/WebServerResources/MailerUI.js b/UI/WebServerResources/MailerUI.js index 72883cc56..d674c7a73 100644 --- a/UI/WebServerResources/MailerUI.js +++ b/UI/WebServerResources/MailerUI.js @@ -1,3 +1,5 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + /* JavaScript for SOGoMail */ var accounts = {}; var mailboxTree; @@ -8,13 +10,13 @@ if (typeof textMailAccounts != 'undefined') { mailAccounts = textMailAccounts.evalJSON(true); else mailAccounts = new Array(); -} + } if (typeof textQuotaSupport != 'undefined') { if (textQuotaSupport.length > 0) quotaSupport = textQuotaSupport.evalJSON(true); else quotaSupport = new Array(); -} + } var Mailer = { currentMailbox: null, @@ -73,8 +75,8 @@ function openAddressbook(sender) { urlstr = ApplicationBaseURL + "../Contacts/?popup=YES"; var w = window.open(urlstr, "Addressbook", - "width=640,height=400,resizable=1,scrollbars=1,toolbar=0," - + "location=no,directories=0,status=0,menubar=0,copyhistory=0"); + "width=640,height=400,resizable=1,scrollbars=1,toolbar=0," + + "location=no,directories=0,status=0,menubar=0,copyhistory=0"); w.focus(); return false; @@ -86,7 +88,7 @@ function onMenuSharing(event) { if (type == "additional") window.alert(clabels["The user rights cannot be" - + " edited for this object!"]); + + " edited for this object!"]); else { var urlstr = URLForFolderID(folderID) + "/acls"; openAclWindow(urlstr); @@ -104,13 +106,13 @@ function markMailInWindow(win, msguid, markread) { subjectCell.addClassName("mailer_readmailsubject"); var img = win.$("unreaddiv_" + msguid); if (img) { - img.removeClassName("mailerUnreadIcon"); - img.addClassName("mailerReadIcon"); - img.setAttribute("id", "readdiv_" + msguid); - img.setAttribute("src", ResourcesURL + "/icon_read.gif"); - var title = img.getAttribute("title-markunread"); - if (title) - img.setAttribute("title", title); + img.removeClassName("mailerUnreadIcon"); + img.addClassName("mailerReadIcon"); + img.setAttribute("id", "readdiv_" + msguid); + img.setAttribute("src", ResourcesURL + "/icon_read.gif"); + var title = img.getAttribute("title-markunread"); + if (title) + img.setAttribute("title", title); } } else { @@ -118,13 +120,13 @@ function markMailInWindow(win, msguid, markread) { subjectCell.removeClassName('mailer_readmailsubject'); var img = win.$("readdiv_" + msguid); if (img) { - img.removeClassName("mailerReadIcon"); - img.addClassName("mailerUnreadIcon"); - img.setAttribute("id", "unreaddiv_" + msguid); - img.setAttribute("src", ResourcesURL + "/icon_unread.gif"); - var title = img.getAttribute("title-markread"); - if (title) - img.setAttribute("title", title); + img.removeClassName("mailerReadIcon"); + img.addClassName("mailerUnreadIcon"); + img.setAttribute("id", "unreaddiv_" + msguid); + img.setAttribute("src", ResourcesURL + "/icon_unread.gif"); + var title = img.getAttribute("title-markread"); + if (title) + img.setAttribute("title", title); } } return true; @@ -152,12 +154,12 @@ function openMessageWindowsForSelection(action, firstOnly) { var rows = messageList.getSelectedRowsId(); if (rows.length > 0) { for (var i = 0; i < rows.length; i++) { - openMessageWindow(Mailer.currentMailbox + "/" + rows[i].substr(4), - ApplicationBaseURL + Mailer.currentMailbox - + "/" + rows[i].substr(4) - + "/" + action); - if (firstOnly) - break; + openMessageWindow(Mailer.currentMailbox + "/" + rows[i].substr(4), + ApplicationBaseURL + Mailer.currentMailbox + + "/" + rows[i].substr(4) + + "/" + action); + if (firstOnly) + break; } } else { window.alert(labels["Please select a message."]); @@ -258,7 +260,7 @@ function deleteSelectedMessagesCallback(http) { var row = $("row_" + data["id"]); var nextRow = row.next("tr"); if (!nextRow) - nextRow = row.previous("tr"); + nextRow = row.previous("tr"); // row.addClassName("deleted"); // when we'll offer "mark as deleted" if (deleteMessageRequestCount == 0) { @@ -284,7 +286,7 @@ function moveMessages(rowIds, folder) { var messageId = Mailer.currentMailbox + "/" + rowIds[i]; url = (ApplicationBaseURL + messageId - + "/move?tofolder=" + folder); + + "/move?tofolder=" + folder); http = createHTTPClient(); http.open("GET", url, false /* not async */); http.send(""); @@ -293,9 +295,9 @@ function moveMessages(rowIds, folder) { row.parentNode.removeChild(row); deleteCachedMessage(messageId); if (Mailer.currentMessages[Mailer.currentMailbox] == rowIds[i]) { - var div = $('messageContent'); - div.update(); - Mailer.currentMessages[Mailer.currentMailbox] = null; + var div = $('messageContent'); + div.update(); + Mailer.currentMessages[Mailer.currentMailbox] = null; } } else /* request failed */ @@ -326,11 +328,11 @@ function deleteMessage(url, id, mailbox, messageId) { function deleteMessageWithDelay(url, id, mailbox, messageId) { /* this is called by UIxMailPopupView with window.opener */ setTimeout("deleteMessage('" + - url + "', '" + - id + "', '" + - mailbox + "', '" + - messageId + "')", - 50); + url + "', '" + + id + "', '" + + mailbox + "', '" + + messageId + "')", + 50); } function onPrintCurrentMessage(event) { @@ -392,32 +394,32 @@ function _onMailboxMenuAction(menuEntry, error, actionName) { else if (Object.isArray(document.menuTarget)) // Menu called from multiple selection in messages list view messages = $(document.menuTarget).collect(function(row) { - return row.getAttribute("id").substr(4); - }); + return row.getAttribute("id").substr(4); + }); else // Menu called from one selection in messages list view messages.push(document.menuTarget.getAttribute("id").substr(4)); var url_prefix = URLForFolderID(Mailer.currentMailbox) + "/"; messages.each(function(msgid, i) { - var url = url_prefix + msgid + "/" + actionName - + "?folder=" + targetMailbox; - triggerAjaxRequest(url, folderRefreshCallback, - ((i == messages.size() - 1)?Mailer.currentMailbox:"")); + var url = url_prefix + msgid + "/" + actionName + + "?folder=" + targetMailbox; + triggerAjaxRequest(url, folderRefreshCallback, + ((i == messages.size() - 1)?Mailer.currentMailbox:"")); }); } } function onMailboxMenuMove(event) { _onMailboxMenuAction(this, - "Moving a message into its own folder is impossible!", - "move"); + "Moving a message into its own folder is impossible!", + "move"); } function onMailboxMenuCopy(event) { _onMailboxMenuAction(this, - "Copying a message into its own folder is impossible!", - "copy"); + "Copying a message into its own folder is impossible!", + "copy"); } function refreshMailbox() { @@ -458,20 +460,20 @@ function openMailbox(mailbox, reload, idx) { if (!idx) { currentMessage = Mailer.currentMessages[mailbox]; if (currentMessage) { - url += '&pageforuid=' + currentMessage; - if (!reload) - loadMessage(currentMessage); + url += '&pageforuid=' + currentMessage; + if (!reload) + loadMessage(currentMessage); } } var searchValue = search["value"]; if (searchValue && searchValue.length > 0) url += ("&search=" + search["criteria"] - + "&value=" + escape(searchValue.utf8encode())); + + "&value=" + escape(searchValue.utf8encode())); var sortAttribute = sorting["attribute"]; if (sortAttribute && sortAttribute.length > 0) url += ("&sort=" + sorting["attribute"] - + "&asc=" + sorting["ascending"]); + + "&asc=" + sorting["ascending"]); if (idx) url += "&idx=" + idx; @@ -486,19 +488,19 @@ function openMailbox(mailbox, reload, idx) { var rightDragHandle = $("rightDragHandle"); rightDragHandle.setStyle({ visibility: "visible" }); messageContent.setStyle({ top: (rightDragHandle.offsetTop - + rightDragHandle.offsetHeight - + 'px') }); + + rightDragHandle.offsetHeight + + 'px') }); } document.messageListAjaxRequest = triggerAjaxRequest(url, messageListCallback, - currentMessage); + currentMessage); var account = Mailer.currentMailbox.split("/")[1]; if (accounts[account].supportsQuotas) { var quotasUrl = ApplicationBaseURL + mailbox + "/quotas"; if (document.quotaAjaxRequest) { - document.quotaAjaxRequest.aborted = true; - document.quotaAjaxRequest.abort(); + document.quotaAjaxRequest.aborted = true; + document.quotaAjaxRequest.abort(); } document.quotaAjaxRequest = triggerAjaxRequest(quotasUrl, quotasCallback); } @@ -527,7 +529,7 @@ function messageListCallback(http) { $(tmp).update(http.responseText); thead.rows[1].parentNode.replaceChild(tmp.firstChild.tHead.rows[1], thead.rows[1]); addressHeaderCell.replaceChild(tmp.firstChild.tHead.rows[0].cells[3].lastChild, - addressHeaderCell.lastChild); + addressHeaderCell.lastChild); table.replaceChild(tmp.firstChild.tBodies[0], tbody); } else { @@ -543,15 +545,15 @@ function messageListCallback(http) { if (selected) { var row = $("row_" + selected); if (row) { - row.selectElement(); - lastClickedRow = row.rowIndex - $(row).up('table').down('thead').getElementsByTagName('tr').length; - var rowPosition = row.rowIndex * row.getHeight(); - if ($(row).up('div').getHeight() > rowPosition) - rowPosition = 0; - div.scrollTop = rowPosition; // scroll to selected message + row.selectElement(); + lastClickedRow = row.rowIndex - $(row).up('table').down('thead').getElementsByTagName('tr').length; + var rowPosition = row.rowIndex * row.getHeight(); + if ($(row).up('div').getHeight() > rowPosition) + rowPosition = 0; + div.scrollTop = rowPosition; // scroll to selected message } else - $("messageContent").update(); + $("messageContent").update(); } else div.scrollTop = 0; @@ -560,17 +562,17 @@ function messageListCallback(http) { var sortHeader = $(sorting["attribute"] + "Header"); if (sortHeader) { - var sortImages = $(table.tHead).select(".sortImage"); - $(sortImages).each(function(item) { - item.remove(); - }); + var sortImages = $(table.tHead).select(".sortImage"); + $(sortImages).each(function(item) { + item.remove(); + }); - var sortImage = createElement("img", "messageSortImage", "sortImage"); - sortHeader.insertBefore(sortImage, sortHeader.firstChild); - if (sorting["ascending"]) - sortImage.src = ResourcesURL + "/title_sortdown_12x12.png"; - else - sortImage.src = ResourcesURL + "/title_sortup_12x12.png"; + var sortImage = createElement("img", "messageSortImage", "sortImage"); + sortHeader.insertBefore(sortImage, sortHeader.firstChild); + if (sorting["ascending"]) + sortImage.src = ResourcesURL + "/title_sortdown_12x12.png"; + else + sortImage.src = ResourcesURL + "/title_sortup_12x12.png"; } } } @@ -588,8 +590,8 @@ function quotasCallback(http) { if (http.responseText.length > 0) { var quotas = http.responseText.evalJSON(true); for (var i in quotas) { - hasQuotas = true; - break; + hasQuotas = true; + break; } } @@ -597,7 +599,7 @@ function quotasCallback(http) { var treePath = Mailer.currentMailbox.split("/"); var quotasMB = new Array(); for (var i = 2; i < treePath.length; i++) - quotasMB.push(treePath[i].substr(6)); + quotasMB.push(treePath[i].substr(6)); var mbQuotas = quotas["/" + quotasMB.join("/")]; var used = mbQuotas["usedSpace"]; var max = mbQuotas["maxQuota"]; @@ -688,9 +690,9 @@ function deleteCachedMessage(messageId) { var counter = 0; while (counter < Mailer.cachedMessages.length - && !done) + && !done) if (Mailer.cachedMessages[counter] - && Mailer.cachedMessages[counter]['idx'] == messageId) { + && Mailer.cachedMessages[counter]['idx'] == messageId) { Mailer.cachedMessages.splice(counter, 1); done = true; } @@ -703,9 +705,9 @@ function getCachedMessage(idx) { var counter = 0; while (counter < Mailer.cachedMessages.length - && message == null) + && message == null) if (Mailer.cachedMessages[counter] - && Mailer.cachedMessages[counter]['idx'] == Mailer.currentMailbox + '/' + idx) + && Mailer.cachedMessages[counter]['idx'] == Mailer.currentMailbox + '/' + idx) message = Mailer.cachedMessages[counter]; else counter++; @@ -723,9 +725,9 @@ function storeCachedMessage(cachedMessage) { else { while (Mailer.cachedMessages[counter]) { if (oldest == -1 - || Mailer.cachedMessages[counter]['time'] < timeOldest) { - oldest = counter; - timeOldest = Mailer.cachedMessages[counter]['time']; + || Mailer.cachedMessages[counter]['time'] < timeOldest) { + oldest = counter; + timeOldest = Mailer.cachedMessages[counter]['time']; } counter++; } @@ -762,7 +764,7 @@ function loadMessage(idx) { markMailInWindow(window, idx, true); if (cachedMessage == null) { var url = (ApplicationBaseURL + Mailer.currentMailbox + "/" - + idx + "/view?noframe=1"); + + idx + "/view?noframe=1"); document.messageAjaxRequest = triggerAjaxRequest(url, messageCallback, idx); } else { @@ -778,7 +780,7 @@ function loadMessage(idx) { function configureLinksInMessage() { var messageDiv = $('messageContent'); var mailContentDiv = document.getElementsByClassName('mailer_mailcontent', - messageDiv)[0]; + messageDiv)[0]; if (!document.body.hasClassName("popup")) mailContentDiv.observe("contextmenu", onMessageContentMenu); @@ -798,25 +800,25 @@ function configureLinksInMessage() { var editDraftButton = $("editDraftButton"); if (editDraftButton) editDraftButton.observe("click", - onMessageEditDraft.bindAsEventListener(editDraftButton)); + onMessageEditDraft.bindAsEventListener(editDraftButton)); configureiCalLinksInMessage(); } function configureiCalLinksInMessage() { var buttons = { "iCalendarAccept": "accept", - "iCalendarDecline": "decline", - "iCalendarTentative": "tentative", - "iCalendarUpdateUserStatus": "updateUserStatus", - "iCalendarAddToCalendar": "addToCalendar", - "iCalendarDeleteFromCalendar": "deleteFromCalendar" }; + "iCalendarDecline": "decline", + "iCalendarTentative": "tentative", + "iCalendarUpdateUserStatus": "updateUserStatus", + "iCalendarAddToCalendar": "addToCalendar", + "iCalendarDeleteFromCalendar": "deleteFromCalendar" }; for (var key in buttons) { var button = $(key); if (button) { button.action = buttons[key]; button.observe("click", - onICalendarButtonClick.bindAsEventListener(button)); + onICalendarButtonClick.bindAsEventListener(button)); } } } @@ -844,8 +846,8 @@ function ICalendarButtonCallback(http) { } for (var i = 0; i < Mailer.popups.length; i++) if (Mailer.popups[i].messageUID == oldMsg) { - Mailer.popups[i].location.reload(); - break; + Mailer.popups[i].location.reload(); + break; } } else @@ -857,17 +859,17 @@ function resizeMailContent() { var contentDiv = document.getElementsByClassName('mailer_mailcontent')[0]; contentDiv.setStyle({ 'top': - (Element.getHeight(headerTable) + headerTable.offsetTop) + 'px' }); + (Element.getHeight(headerTable) + headerTable.offsetTop) + 'px' }); // Show expand buttons if necessary var spans = $$("TABLE TR.mailer_fieldrow TD.mailer_fieldvalue SPAN"); spans.each(function(span) { var row = span.up("TR"); if (span.getWidth() > row.getWidth()) { - var cell = row.select("TD.mailer_fieldname").first(); - var link = cell.down("img"); - link.show(); - link.observe("click", toggleDisplayHeader); + var cell = row.select("TD.mailer_fieldname").first(); + var link = cell.down("img"); + link.show(); + link.observe("click", toggleDisplayHeader); } }); } @@ -938,7 +940,7 @@ function messageCallback(http) { cachedMessage['time'] = (new Date()).getTime(); cachedMessage['text'] = http.responseText; if (cachedMessage['text'].length < 30000) - storeCachedMessage(cachedMessage); + storeCachedMessage(cachedMessage); } } else @@ -955,7 +957,7 @@ function processMailboxMenuAction(mailbox) { upperNode = null; while (currentNode - && !currentNode.hasAttribute('mailboxaction')) + && !currentNode.hasAttribute('mailboxaction')) currentNode = currentNode.parentNode.parentNode.parentMenuItem; if (currentNode) @@ -1020,7 +1022,7 @@ function onMenuViewMessageSource(event) { if (rows.length > 0) { var url = (ApplicationBaseURL + Mailer.currentMailbox + "/" - + rows[0].substr(4) + "/viewsource"); + + rows[0].substr(4) + "/viewsource"); openMailComposeWindow(url); } @@ -1043,7 +1045,7 @@ function newContactFromEmail(event) { var c_name = extractEmailName(mailto); if (email.length > 0) { var url = (UserFolderURL + "Contacts/personal/newcontact?contactEmail=" - + encodeURI(email)); + + encodeURI(email)); if (c_name) url += "&contactFN=" + c_name; openContactWindow(url); @@ -1070,8 +1072,8 @@ function expandUpperTree(node) { var id = currentNode.getAttribute("id"); var number = parseInt(id.substr(2)); if (number > 0) { - var cn = mailboxTree.aNodes[number]; - mailboxTree.nodeStatus(1, number, cn._ls); + var cn = mailboxTree.aNodes[number]; + mailboxTree.nodeStatus(1, number, cn._ls); } } currentNode = currentNode.parentNode; @@ -1118,44 +1120,44 @@ var mailboxSpanAcceptType = function(type) { }; var mailboxSpanEnter = function() { - this.addClassName("_dragOver"); + this.addClassName("_dragOver"); }; var mailboxSpanExit = function() { - this.removeClassName("_dragOver"); + this.removeClassName("_dragOver"); }; var mailboxSpanDrop = function(data) { var success = false; if (data) { - var folder = this.parentNode.parentNode.getAttribute("dataname"); - if (folder != Mailer.currentMailbox) - success = (moveMessages(data, folder) == 0); + var folder = this.parentNode.parentNode.getAttribute("dataname"); + if (folder != Mailer.currentMailbox) + success = (moveMessages(data, folder) == 0); } else - success = false; + success = false; return success; }; var plusSignEnter = function() { - var nodeNr = parseInt(this.id.substr(2)); - if (!mailboxTree.aNodes[nodeNr]._io) - this.plusSignTimer = setTimeout("openPlusSign('" + nodeNr + "');", 1000); + var nodeNr = parseInt(this.id.substr(2)); + if (!mailboxTree.aNodes[nodeNr]._io) + this.plusSignTimer = setTimeout("openPlusSign('" + nodeNr + "');", 1000); }; var plusSignExit = function() { - if (this.plusSignTimer) { - clearTimeout(this.plusSignTimer); - this.plusSignTimer = null; - } + if (this.plusSignTimer) { + clearTimeout(this.plusSignTimer); + this.plusSignTimer = null; + } }; function openPlusSign(nodeNr) { - mailboxTree.nodeStatus(1, nodeNr, mailboxTree.aNodes[nodeNr]._ls); - mailboxTree.aNodes[nodeNr]._io = 1; - this.plusSignTimer = null; + mailboxTree.nodeStatus(1, nodeNr, mailboxTree.aNodes[nodeNr]._ls); + mailboxTree.aNodes[nodeNr]._io = 1; + this.plusSignTimer = null; } var messageListGhost = function () { @@ -1184,57 +1186,57 @@ var messageListData = function(type) { var rows = this.parentNode.parentNode.getSelectedRowsId(); var msgIds = new Array(); for (var i = 0; i < rows.length; i++) - msgIds.push(rows[i].substr(4)); + msgIds.push(rows[i].substr(4)); return msgIds; }; /* a model for a futur refactoring of the sortable table headers mechanism */ function configureMessageListEvents(table) { - if (table) { - table.multiselect = true; - // Each body row can load a message - table.observe("mousedown", - onMessageSelectionChange.bindAsEventListener(table)); - // Sortable columns - configureSortableTableHeaders(table); - } + if (table) { + table.multiselect = true; + // Each body row can load a message + table.observe("mousedown", + onMessageSelectionChange.bindAsEventListener(table)); + // Sortable columns + configureSortableTableHeaders(table); + } } function configureMessageListBodyEvents(table) { - if (table) { - // Page navigation - var cell = table.tHead.rows[1].cells[0]; - if ($(cell).hasClassName("tbtv_navcell")) { - var anchors = $(cell).childNodesWithTag("a"); - for (var i = 0; i < anchors.length; i++) - $(anchors[i]).observe("click", openMailboxAtIndex); - } + if (table) { + // Page navigation + var cell = table.tHead.rows[1].cells[0]; + if ($(cell).hasClassName("tbtv_navcell")) { + var anchors = $(cell).childNodesWithTag("a"); + for (var i = 0; i < anchors.length; i++) + $(anchors[i]).observe("click", openMailboxAtIndex); + } - rows = table.tBodies[0].rows; - for (var i = 0; i < rows.length; i++) { - var row = $(rows[i]); - row.observe("mousedown", onRowClick); - row.observe("selectstart", listRowMouseDownHandler); - row.observe("contextmenu", onMessageContextMenu); + rows = table.tBodies[0].rows; + for (var i = 0; i < rows.length; i++) { + var row = $(rows[i]); + row.observe("mousedown", onRowClick); + row.observe("selectstart", listRowMouseDownHandler); + row.observe("contextmenu", onMessageContextMenu); - row.dndTypes = function() { return new Array("mailRow"); }; - row.dndGhost = messageListGhost; - row.dndDataForType = messageListData; - // document.DNDManager.registerSource(row); + row.dndTypes = function() { return new Array("mailRow"); }; + row.dndGhost = messageListGhost; + row.dndDataForType = messageListData; + // document.DNDManager.registerSource(row); - for (var j = 0; j < row.cells.length; j++) { - var cell = $(row.cells[j]); - cell.observe("mousedown", listRowMouseDownHandler); - if (j == 2 || j == 3 || j == 5) - cell.observe("dblclick", onMessageDoubleClick.bindAsEventListener(cell)); - else if (j == 4) { - var img = $(cell.childNodesWithTag("img")[0]); - img.observe("click", mailListMarkMessage.bindAsEventListener(img)); - } - } - } - } + for (var j = 0; j < row.cells.length; j++) { + var cell = $(row.cells[j]); + cell.observe("mousedown", listRowMouseDownHandler); + if (j == 2 || j == 3 || j == 5) + cell.observe("dblclick", onMessageDoubleClick.bindAsEventListener(cell)); + else if (j == 4) { + var img = $(cell.childNodesWithTag("img")[0]); + img.observe("click", mailListMarkMessage.bindAsEventListener(img)); + } + } + } + } } function configureDragHandles() { @@ -1263,10 +1265,10 @@ function initDnd() { var images = tree.getElementsByTagName("img"); for (var i = 0; i < images.length; i++) { if (images[i].id[0] == 'j') { - images[i].dndAcceptType = mailboxSpanAcceptType; - images[i].dndEnter = plusSignEnter; - images[i].dndExit = plusSignExit; - document.DNDManager.registerDestination(images[i]); + images[i].dndAcceptType = mailboxSpanAcceptType; + images[i].dndEnter = plusSignEnter; + images[i].dndExit = plusSignExit; + document.DNDManager.registerDestination(images[i]); } } var nodes = document.getElementsByClassName("nodeName", tree); @@ -1318,7 +1320,7 @@ function initMessageCheckTimer() { interval = parseInt(messageCheck.substr(6)) * 60; } messageCheckTimer = window.setInterval(onMessageCheckCallback, - interval * 1000); + interval * 1000); } } @@ -1367,11 +1369,11 @@ function updateMailboxTreeInPage() { var nodes = document.getElementsByClassName("node", tree); for (i = 0; i < nodes.length; i++) { nodes[i].observe("click", - onMailboxTreeItemClick.bindAsEventListener(nodes[i])); + onMailboxTreeItemClick.bindAsEventListener(nodes[i])); nodes[i].observe("contextmenu", - onFolderMenuClick.bindAsEventListener(nodes[i])); + onFolderMenuClick.bindAsEventListener(nodes[i])); if (!inboxFound - && nodes[i].parentNode.getAttribute("datatype") == "inbox") { + && nodes[i].parentNode.getAttribute("datatype") == "inbox") { Mailer.currentMailboxType = "inbox"; openInbox(nodes[i]); inboxFound = true; @@ -1441,7 +1443,7 @@ function generateMenuForMailbox(mailbox, prefix, callback) { function updateMailboxMenus() { var mailboxActions = { move: onMailboxMenuMove, - copy: onMailboxMenuCopy }; + copy: onMailboxMenuCopy }; for (key in mailboxActions) { var menuId = key + "MailboxMenu"; @@ -1465,7 +1467,7 @@ function updateMailboxMenus() { menu.appendChild(menuEntry); var mailbox = accounts[mailAccounts[i]]; var newSubmenuId = generateMenuForMailbox(mailbox, - key, mailboxActions[key]); + key, mailboxActions[key]); submenuIds.push(newSubmenuId); } initMenu(menuDIV, submenuIds); @@ -1477,16 +1479,16 @@ function onLoadMailboxesCallback(http) { checkAjaxRequestsState(); if (http.responseText.length > 0) { var newAccount = buildMailboxes(http.callbackData, - http.responseText); + http.responseText); accounts[http.callbackData] = newAccount; mailboxTree.addMailAccount(newAccount); mailboxTree.pendingRequests--; activeAjaxRequests--; if (!mailboxTree.pendingRequests) { - updateMailboxTreeInPage(); - updateMailboxMenus(); - checkAjaxRequestsState(); - getFoldersState(); + updateMailboxTreeInPage(); + updateMailboxMenus(); + checkAjaxRequestsState(); + getFoldersState(); } } } @@ -1521,8 +1523,8 @@ function buildMailboxes(accountName, encoded) { for (var j = 1; j < (names.length - 1); j++) { var node = currentNode.findMailboxByName(names[j]); if (!node) { - node = new Mailbox("additional", names[j]); - currentNode.addMailbox(node); + node = new Mailbox("additional", names[j]); + currentNode.addMailbox(node); } currentNode = node; } @@ -1553,9 +1555,9 @@ function getFoldersStateCallback(http) { // of the folders that were left opened. var data = http.responseText.evalJSON(true); for (var i = 1; i < mailboxTree.aNodes.length; i++) { - if ($(data).indexOf(mailboxTree.aNodes[i].dataname) > 0) - // If the folder is found, open it - mailboxTree.o(i); + if ($(data).indexOf(mailboxTree.aNodes[i].dataname) > 0) + // If the folder is found, open it + mailboxTree.o(i); } } mailboxTree.autoSync(); @@ -1665,7 +1667,7 @@ function onMenuLabelNone() { else if (Object.isArray(document.menuTarget)) // Menu called from multiple selection in messages list view $(document.menuTarget).collect(function(row) { - messages.push(row.getAttribute("id").substr(4)); + messages.push(row.getAttribute("id").substr(4)); }); else // Menu called from one selection in messages list view @@ -1674,8 +1676,8 @@ function onMenuLabelNone() { var url = ApplicationBaseURL + Mailer.currentMailbox + "/"; messages.each(function(id) { triggerAjaxRequest(url + id + "/removeAllLabels", - messageFlagCallback, - { mailbox: Mailer.currentMailbox, msg: id, label: null } ); + messageFlagCallback, + { mailbox: Mailer.currentMailbox, msg: id, label: null } ); }); } @@ -1685,17 +1687,17 @@ function _onMenuLabelFlagX(flag) { if (document.menuTarget.tagName == "DIV") // Menu called from message content view messages.set(Mailer.currentMessages[Mailer.currentMailbox], - $('tr#row_' + Mailer.currentMessages[Mailer.currentMailbox]).getAttribute("labels")); + $('tr#row_' + Mailer.currentMessages[Mailer.currentMailbox]).getAttribute("labels")); else if (Object.isArray(document.menuTarget)) // Menu called from multiple selection in messages list view $(document.menuTarget).collect(function(row) { - messages.set(row.getAttribute("id").substr(4), - row.getAttribute("labels")); + messages.set(row.getAttribute("id").substr(4), + row.getAttribute("labels")); }); else // Menu called from one selection in messages list view messages.set(document.menuTarget.getAttribute("id").substr(4), - document.menuTarget.getAttribute("labels")); + document.menuTarget.getAttribute("labels")); var url = ApplicationBaseURL + Mailer.currentMailbox + "/"; messages.keys().each(function(id) { @@ -1703,12 +1705,12 @@ function _onMenuLabelFlagX(flag) { var operation = "add"; if (flags.indexOf("label" + flag) > -1) - operation = "remove"; + operation = "remove"; triggerAjaxRequest(url + id + "/" + operation + "Label" + flag, - messageFlagCallback, - { mailbox: Mailer.currentMailbox, msg: id, - label: operation + flag } ); + messageFlagCallback, + { mailbox: Mailer.currentMailbox, msg: id, + label: operation + flag } ); }); } @@ -1759,23 +1761,23 @@ function messageFlagCallback(http) { var row = $("row_" + data["msg"]); var operation = data["label"]; if (operation) { - var labels = row.getAttribute("labels"); - var flags; - if (labels.length > 0) - flags = labels.split(" "); - else - flags = new Array(); - if (operation.substr(0, 3) == "add") - flags.push("label" + operation.substr(3)); - else { - var flag = "label" + operation.substr(6); - var idx = flags.indexOf(flag); - flags.splice(idx, 1); - } - row.setAttribute("labels", flags.join(" ")); + var labels = row.getAttribute("labels"); + var flags; + if (labels.length > 0) + flags = labels.split(" "); + else + flags = new Array(); + if (operation.substr(0, 3) == "add") + flags.push("label" + operation.substr(3)); + else { + var flag = "label" + operation.substr(6); + var idx = flags.indexOf(flag); + flags.splice(idx, 1); + } + row.setAttribute("labels", flags.join(" ")); } else - row.setAttribute("labels", ""); + row.setAttribute("labels", ""); } } } @@ -1788,8 +1790,8 @@ function onLabelMenuPrepareVisibility() { var rows = messageList.getSelectedRows(); for (var i = 0; i < rows.length; i++) { $w(rows[i].getAttribute("labels")).each(function(flag) { - flags[flag] = true; - }); + flags[flag] = true; + }); } } @@ -1812,62 +1814,62 @@ function onLabelMenuPrepareVisibility() { function getMenus() { var menus = {} menus["accountIconMenu"] = new Array(null, null, onMenuCreateFolder, null, - null, null); + null, null); menus["inboxIconMenu"] = new Array(null, null, null, "-", null, - onMenuCreateFolder, onMenuExpungeFolder, - "-", null, - onMenuSharing); + onMenuCreateFolder, onMenuExpungeFolder, + "-", null, + onMenuSharing); menus["trashIconMenu"] = new Array(null, null, null, "-", null, - onMenuCreateFolder, onMenuExpungeFolder, - onMenuEmptyTrash, "-", null, - onMenuSharing); + onMenuCreateFolder, onMenuExpungeFolder, + onMenuEmptyTrash, "-", null, + onMenuSharing); menus["mailboxIconMenu"] = new Array(null, null, null, "-", null, - onMenuCreateFolder, - onMenuRenameFolder, - onMenuExpungeFolder, - onMenuDeleteFolder, - "folderTypeMenu", - "-", null, - onMenuSharing); + onMenuCreateFolder, + onMenuRenameFolder, + onMenuExpungeFolder, + onMenuDeleteFolder, + "folderTypeMenu", + "-", null, + onMenuSharing); menus["addressMenu"] = new Array(newContactFromEmail, newEmailTo, null); menus["messageListMenu"] = new Array(onMenuOpenMessage, "-", - onMenuReplyToSender, - onMenuReplyToAll, - onMenuForwardMessage, null, - "-", "moveMailboxMenu", - "copyMailboxMenu", "label-menu", - "mark-menu", "-", null, - onMenuViewMessageSource, null, - null, onMenuDeleteMessage); + onMenuReplyToSender, + onMenuReplyToAll, + onMenuForwardMessage, null, + "-", "moveMailboxMenu", + "copyMailboxMenu", "label-menu", + "mark-menu", "-", null, + onMenuViewMessageSource, null, + null, onMenuDeleteMessage); menus["messagesListMenu"] = new Array(onMenuForwardMessage, - "-", "moveMailboxMenu", - "copyMailboxMenu", "label-menu", - "mark-menu", "-", - null, null, - onMenuDeleteMessage); + "-", "moveMailboxMenu", + "copyMailboxMenu", "label-menu", + "mark-menu", "-", + null, null, + onMenuDeleteMessage); menus["imageMenu"] = new Array(saveImage); menus["messageContentMenu"] = new Array(onMenuReplyToSender, - onMenuReplyToAll, - onMenuForwardMessage, - null, "moveMailboxMenu", - "copyMailboxMenu", - "-", "label-menu", "mark-menu", - "-", - null, onMenuViewMessageSource, - null, onPrintCurrentMessage, - onMenuDeleteMessage); + onMenuReplyToAll, + onMenuForwardMessage, + null, "moveMailboxMenu", + "copyMailboxMenu", + "-", "label-menu", "mark-menu", + "-", + null, onMenuViewMessageSource, + null, onPrintCurrentMessage, + onMenuDeleteMessage); menus["folderTypeMenu"] = new Array(onMenuChangeToSentFolder, - onMenuChangeToDraftsFolder, - onMenuChangeToTrashFolder); + onMenuChangeToDraftsFolder, + onMenuChangeToTrashFolder); menus["label-menu"] = new Array(onMenuLabelNone, "-", onMenuLabelFlag1, - onMenuLabelFlag2, onMenuLabelFlag3, - onMenuLabelFlag4, onMenuLabelFlag5); + onMenuLabelFlag2, onMenuLabelFlag3, + onMenuLabelFlag4, onMenuLabelFlag5); menus["mark-menu"] = new Array(null, null, null, null, "-", null, "-", - null, null, null); + null, null, null); menus["searchMenu"] = new Array(setSearchCriteria, setSearchCriteria, - setSearchCriteria, setSearchCriteria, - setSearchCriteria); + setSearchCriteria, setSearchCriteria, + setSearchCriteria); var labelMenu = $("label-menu"); if (labelMenu) labelMenu.prepareVisibility = onLabelMenuPrepareVisibility; @@ -1895,31 +1897,31 @@ Mailbox.prototype = { } }, fullName: function() { - var fullName = ""; + var fullName = ""; - var currentFolder = this; - while (currentFolder.parentFolder) { - fullName = "/folder" + currentFolder.name + fullName; - currentFolder = currentFolder.parentFolder; - } + var currentFolder = this; + while (currentFolder.parentFolder) { + fullName = "/folder" + currentFolder.name + fullName; + currentFolder = currentFolder.parentFolder; + } - return "/" + currentFolder.name + fullName; - }, + return "/" + currentFolder.name + fullName; + }, findMailboxByName: function(name) { - var mailbox = null; + var mailbox = null; - var i = 0; - while (!mailbox && i < this.children.length) - if (this.children[i].name == name) - mailbox = this.children[i]; - else - i++; + var i = 0; + while (!mailbox && i < this.children.length) + if (this.children[i].name == name) + mailbox = this.children[i]; + else + i++; - return mailbox; - }, + return mailbox; + }, addMailbox: function(mailbox) { - mailbox.parentFolder = this; - this.children.push(mailbox); - } + mailbox.parentFolder = this; + this.children.push(mailbox); + } }; diff --git a/UI/WebServerResources/SOGoDragAndDrop.js b/UI/WebServerResources/SOGoDragAndDrop.js index 1056e9044..6e6b25f2c 100644 --- a/UI/WebServerResources/SOGoDragAndDrop.js +++ b/UI/WebServerResources/SOGoDragAndDrop.js @@ -1,17 +1,19 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + /* drag and drop */ /* HTMLElement interface */ var SOGODragAndDropSourceInterface = { - _removeGestureHandlers: function () { + _removeGestureHandlers: function () { window.removeEventListener("mousemove", this.dragGestureMouseMoveHandler, false); window.removeEventListener("mouseup", this.dragGestureMouseUpHandler, false); document._dragGestureStartPoint = null; document._currentMouseGestureObject = null; }, - bind: function() { + bind: function() { this.addEventListener("mousedown", this.dragGestureMouseDownHandler, false); }, - dragGestureMouseDownHandler: function (event) { + dragGestureMouseDownHandler: function (event) { if (event.button == 0) { document._dragGestureStartPoint = new Array(event.clientX, event.clientY); @@ -22,10 +24,10 @@ var SOGODragAndDropSourceInterface = { false); } }, - dragGestureMouseUpHandler: function (event) { + dragGestureMouseUpHandler: function (event) { document._currentMouseGestureObject._removeGestureHandlers(); }, - dragGestureMouseMoveHandler: function (event) { + dragGestureMouseMoveHandler: function (event) { var deltaX = event.clientX - document._dragGestureStartPoint[0]; var deltaY = event.clientY - document._dragGestureStartPoint[1]; if (Math.sqrt((deltaX * deltaX) + (deltaY * deltaY)) > 10) { @@ -37,217 +39,217 @@ var SOGODragAndDropSourceInterface = { document._currentMouseGestureObject._removeGestureHandlers(); } } -} +}; /* DNDManager */ document.DNDManager = { - lastSource: 0, - lastDestination: 0, - sources: new Array(), - destinations: new Array(), - registerSource: function (source) { - var id = source.getAttribute("id"); - if (!id) { - id = "_dndSource" + (this.lastSource + 1); - source.setAttribute("id", id); - } - this.sources[id] = source; - this.lastSource++; - source.addInterface(SOGODragAndDropSourceInterface); - }, - registerDestination: function (destination) { - var id = destination.getAttribute("id"); - if (!id) { - id = "_dndDestination" + (this.lastDestination + 1); - destination.setAttribute("id", id); - } - this.destinations[id] = destination; - this.lastDestination++; - }, - _lookupSource: function (target) { - var source = null; - var id = target.getAttribute("id"); - if (id) - source = document.DNDManager.sources[id]; - return source; - }, - _lookupDestination: function (target) { - var destination = null; - var id = target.getAttribute("id"); - if (id) - destination = document.DNDManager.destinations[id]; - return destination; - }, - startDragging: function (object, point) { - var source = document.DNDManager._lookupSource (object); - if (source) { - document.DNDManager.currentDndOperation = new document.DNDOperation(source, point); - window.addEventListener("mouseup", - document.DNDManager.destinationDrop, false); - window.addEventListener("mouseover", - document.DNDManager.destinationEnter, false); - window.addEventListener("mousemove", - document.DNDManager.destinationOver, false); - window.addEventListener("mouseout", - document.DNDManager.destinationExit, false); - } - }, - destinationEnter: function (event) { - var operation = document.DNDManager.currentDndOperation; - var destination = document.DNDManager._lookupDestination (event.target); - if (operation && destination && destination.dndAcceptType) { - operation.type = null; - var i = 0; - while (operation.type == null - && i < operation.types.length) { - if (destination.dndAcceptType(operation.types[i])) { - operation.type = operation.types[i]; - operation.setDestination(destination); - if (destination.dndEnter) - destination.dndEnter(event, operation.source, operation.type); - } - else - i++; - } - } - }, - destinationExit: function (event) { - var operation = document.DNDManager.currentDndOperation; - if (operation - && operation.destination == event.target) { - if (operation.destination.dndExit) - event.target.dndExit(); - operation.setDestination(null); - } - }, - destinationOver: function (event) { - }, - destinationDrop: function (event) { - var operation = document.DNDManager.currentDndOperation; - if (operation) { - window.removeEventListener("mouseup", - document.DNDManager.destinationDrop, false); - window.removeEventListener("mouseover", - document.DNDManager.destinationEnter, false); - window.removeEventListener("mousemove", - document.DNDManager.destinationOver, false); - window.removeEventListener("mouseout", - document.DNDManager.destinationExit, false); - if (operation.destination == event.target) { - if (operation.destination.dndExit) { - operation.destination.dndExit(); - } - if (operation.destination.dndDrop) { - var data = null; - if (operation.source.dndDataForType) - data = operation.source.dndDataForType(operation.type); - var result = operation.destination.dndDrop(data); - if (operation.ghost) { - if (result) - operation.bustGhost(); - else - operation.chaseGhost(); - } - } - else - if (operation.ghost) - operation.chaseGhost(); - } else { - if (operation.ghost) - operation.chaseGhost(); - } - document.DNDManager.currentDndOperation = null; - } - }, - currentDndOperation: null -} + lastSource: 0, + lastDestination: 0, + sources: new Array(), + destinations: new Array(), + registerSource: function (source) { + var id = source.getAttribute("id"); + if (!id) { + id = "_dndSource" + (this.lastSource + 1); + source.setAttribute("id", id); + } + this.sources[id] = source; + this.lastSource++; + source.addInterface(SOGODragAndDropSourceInterface); + }, + registerDestination: function (destination) { + var id = destination.getAttribute("id"); + if (!id) { + id = "_dndDestination" + (this.lastDestination + 1); + destination.setAttribute("id", id); + } + this.destinations[id] = destination; + this.lastDestination++; + }, + _lookupSource: function (target) { + var source = null; + var id = target.getAttribute("id"); + if (id) + source = document.DNDManager.sources[id]; + return source; + }, + _lookupDestination: function (target) { + var destination = null; + var id = target.getAttribute("id"); + if (id) + destination = document.DNDManager.destinations[id]; + return destination; + }, + startDragging: function (object, point) { + var source = document.DNDManager._lookupSource (object); + if (source) { + document.DNDManager.currentDndOperation = new document.DNDOperation(source, point); + window.addEventListener("mouseup", + document.DNDManager.destinationDrop, false); + window.addEventListener("mouseover", + document.DNDManager.destinationEnter, false); + window.addEventListener("mousemove", + document.DNDManager.destinationOver, false); + window.addEventListener("mouseout", + document.DNDManager.destinationExit, false); + } + }, + destinationEnter: function (event) { + var operation = document.DNDManager.currentDndOperation; + var destination = document.DNDManager._lookupDestination (event.target); + if (operation && destination && destination.dndAcceptType) { + operation.type = null; + var i = 0; + while (operation.type == null + && i < operation.types.length) { + if (destination.dndAcceptType(operation.types[i])) { + operation.type = operation.types[i]; + operation.setDestination(destination); + if (destination.dndEnter) + destination.dndEnter(event, operation.source, operation.type); + } + else + i++; + } + } + }, + destinationExit: function (event) { + var operation = document.DNDManager.currentDndOperation; + if (operation + && operation.destination == event.target) { + if (operation.destination.dndExit) + event.target.dndExit(); + operation.setDestination(null); + } + }, + destinationOver: function (event) { + }, + destinationDrop: function (event) { + var operation = document.DNDManager.currentDndOperation; + if (operation) { + window.removeEventListener("mouseup", + document.DNDManager.destinationDrop, false); + window.removeEventListener("mouseover", + document.DNDManager.destinationEnter, false); + window.removeEventListener("mousemove", + document.DNDManager.destinationOver, false); + window.removeEventListener("mouseout", + document.DNDManager.destinationExit, false); + if (operation.destination == event.target) { + if (operation.destination.dndExit) { + operation.destination.dndExit(); + } + if (operation.destination.dndDrop) { + var data = null; + if (operation.source.dndDataForType) + data = operation.source.dndDataForType(operation.type); + var result = operation.destination.dndDrop(data); + if (operation.ghost) { + if (result) + operation.bustGhost(); + else + operation.chaseGhost(); + } + } + else + if (operation.ghost) + operation.chaseGhost(); + } else { + if (operation.ghost) + operation.chaseGhost(); + } + document.DNDManager.currentDndOperation = null; + } + }, + currentDndOperation: null +}; /* DNDOperation */ document.DNDOperation = function (source, point) { - this.startPoint = point; - this.source = source; - if (source.dndTypes) { - this.types = source.dndTypes(); - } - this.type = null; - this.destination = null; - if (source.dndGhost) { - var ghost = source.dndGhost(); - ghost.style.position = "absolute;"; - ghost.style.zIndex = 10000; - ghost.style.MozOpacity = 0.8; - document.body.appendChild(ghost); - this.ghost = ghost; + this.startPoint = point; + this.source = source; + if (source.dndTypes) { + this.types = source.dndTypes(); + } + this.type = null; + this.destination = null; + if (source.dndGhost) { + var ghost = source.dndGhost(); + ghost.style.position = "absolute;"; + ghost.style.zIndex = 10000; + ghost.style.MozOpacity = 0.8; + document.body.appendChild(ghost); + this.ghost = ghost; - document.addEventListener("mousemove", this.moveGhost, false); - } + document.addEventListener("mousemove", this.moveGhost, false); + } - return this; + return this; }; document.DNDOperation.prototype.setDestination = function(destination) { this.destination = destination; -} +}; document.DNDOperation.prototype.moveGhost = function(event) { - var offsetX = event.clientX; - var offsetY = event.clientY; - if (document.DNDManager.currentDndOperation.ghost.ghostOffsetX) - offsetX += document.DNDManager.currentDndOperation.ghost.ghostOffsetX; - if (document.DNDManager.currentDndOperation.ghost.ghostOffsetY) - offsetY += document.DNDManager.currentDndOperation.ghost.ghostOffsetY; - - document.DNDManager.currentDndOperation.ghost.style.left = offsetX + "px;"; - document.DNDManager.currentDndOperation.ghost.style.top = offsetY + "px;"; -} + var offsetX = event.clientX; + var offsetY = event.clientY; + if (document.DNDManager.currentDndOperation.ghost.ghostOffsetX) + offsetX += document.DNDManager.currentDndOperation.ghost.ghostOffsetX; + if (document.DNDManager.currentDndOperation.ghost.ghostOffsetY) + offsetY += document.DNDManager.currentDndOperation.ghost.ghostOffsetY; + + document.DNDManager.currentDndOperation.ghost.style.left = offsetX + "px;"; + document.DNDManager.currentDndOperation.ghost.style.top = offsetY + "px;"; +}; document.DNDOperation.prototype.bustGhost = function() { - document._dyingOperation = this; - document.removeEventListener("mousemove", this.moveGhost, false); - this.ghost.bustStep = 10; - setTimeout("document._dyingOperation._fadeGhost();", 50); -} + document._dyingOperation = this; + document.removeEventListener("mousemove", this.moveGhost, false); + this.ghost.bustStep = 10; + setTimeout("document._dyingOperation._fadeGhost();", 50); +}; document.DNDOperation.prototype.chaseGhost = function() { - document._dyingOperation = this; - document.removeEventListener("mousemove", this.moveGhost, false); - this.ghost.bustStep = 25; - this.ghost.chaseStep = 25; - this.ghost.style.overflow = "hidden;" - this.ghost.style.whiteSpace = "nowrap;"; - this.ghost.chaseDeltaX = ((this.ghost.cascadeLeftOffset() - this.startPoint[0]) - / this.ghost.chaseStep); - this.ghost.chaseDeltaY = ((this.ghost.cascadeTopOffset() - this.startPoint[1]) - / this.ghost.chaseStep); - setTimeout("document._dyingOperation._chaseGhost();", 20); -} + document._dyingOperation = this; + document.removeEventListener("mousemove", this.moveGhost, false); + this.ghost.bustStep = 25; + this.ghost.chaseStep = 25; + this.ghost.style.overflow = "hidden;" + this.ghost.style.whiteSpace = "nowrap;"; + this.ghost.chaseDeltaX = ((this.ghost.cascadeLeftOffset() - this.startPoint[0]) + / this.ghost.chaseStep); + this.ghost.chaseDeltaY = ((this.ghost.cascadeTopOffset() - this.startPoint[1]) + / this.ghost.chaseStep); + setTimeout("document._dyingOperation._chaseGhost();", 20); +}; document.DNDOperation.prototype._chaseGhost = function() { - if (this.ghost.chaseStep) { - var newLeft = this.ghost.cascadeLeftOffset() - this.ghost.chaseDeltaX; - var newTop = this.ghost.cascadeTopOffset() - this.ghost.chaseDeltaY; - this.ghost.style.MozOpacity = (0.04 * this.ghost.chaseStep); - this.ghost.style.left = newLeft + "px;"; - this.ghost.style.top = newTop + "px;"; - this.ghost.chaseStep--; - setTimeout("document._dyingOperation._chaseGhost();", 20); - } - else { - document.body.removeChild(this.ghost); - this.ghost = null; - } -} + if (this.ghost.chaseStep) { + var newLeft = this.ghost.cascadeLeftOffset() - this.ghost.chaseDeltaX; + var newTop = this.ghost.cascadeTopOffset() - this.ghost.chaseDeltaY; + this.ghost.style.MozOpacity = (0.04 * this.ghost.chaseStep); + this.ghost.style.left = newLeft + "px;"; + this.ghost.style.top = newTop + "px;"; + this.ghost.chaseStep--; + setTimeout("document._dyingOperation._chaseGhost();", 20); + } + else { + document.body.removeChild(this.ghost); + this.ghost = null; + } +}; document.DNDOperation.prototype._fadeGhost = function() { - if (this.ghost.bustStep) { - this.ghost.style.MozOpacity = (0.1 * this.ghost.bustStep); - this.ghost.style.width = (this.ghost.offsetWidth * .7) + "px;"; - this.ghost.style.height = (this.ghost.offsetHeight * .7) + "px;"; - this.ghost.bustStep--; - setTimeout("document._dyingOperation._fadeGhost();", 50); - } - else { - document.body.removeChild(this.ghost); - this.ghost = null; - } -} + if (this.ghost.bustStep) { + this.ghost.style.MozOpacity = (0.1 * this.ghost.bustStep); + this.ghost.style.width = (this.ghost.offsetWidth * .7) + "px;"; + this.ghost.style.height = (this.ghost.offsetHeight * .7) + "px;"; + this.ghost.bustStep--; + setTimeout("document._dyingOperation._fadeGhost();", 50); + } + else { + document.body.removeChild(this.ghost); + this.ghost = null; + } +}; diff --git a/UI/WebServerResources/SOGoDragHandles.js b/UI/WebServerResources/SOGoDragHandles.js index 8a5167022..830a8109a 100644 --- a/UI/WebServerResources/SOGoDragHandles.js +++ b/UI/WebServerResources/SOGoDragHandles.js @@ -1,32 +1,34 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + var SOGoDragHandlesInterface = { - leftMargin: 180, - topMargin: 120, - dhType: null, - origX: -1, - origLeft: -1, - origRight: -1, - origY: -1, - origUpper: -1, - origLower: -1, - delta: -1, - leftBlock: null, - rightBlock: null, - upperBlock: null, - lowerBlock: null, - startHandleDraggingBound: null, - stopHandleDraggingBound: null, - moveBound: null, - bind: function () { + leftMargin: 180, + topMargin: 120, + dhType: null, + origX: -1, + origLeft: -1, + origRight: -1, + origY: -1, + origUpper: -1, + origLower: -1, + delta: -1, + leftBlock: null, + rightBlock: null, + upperBlock: null, + lowerBlock: null, + startHandleDraggingBound: null, + stopHandleDraggingBound: null, + moveBound: null, + bind: function () { this.startHandleDraggingBound = this.startHandleDragging.bindAsEventListener(this); this.observe("mousedown", this.startHandleDraggingBound, false); }, - _determineType: function () { + _determineType: function () { if (this.leftBlock && this.rightBlock) this.dhType = 'horizontal'; else if (this.upperBlock && this.lowerBlock) this.dhType = 'vertical'; }, - startHandleDragging: function (event) { + startHandleDragging: function (event) { if (!this.dhType) this._determineType(); var targ = getTarget(event); @@ -34,14 +36,14 @@ var SOGoDragHandlesInterface = { if (this.dhType == 'horizontal') { this.origX = this.offsetLeft; this.origLeft = this.leftBlock.offsetWidth; - delta = 0; + delta = 0; this.origRight = this.rightBlock.offsetLeft - 5; document.body.setStyle({ cursor: "e-resize" }); } else if (this.dhType == 'vertical') { this.origY = this.offsetTop; this.origUpper = this.upperBlock.offsetHeight; - var pointY = Event.pointerY(event); - if (pointY <= this.topMargin) delta = this.topMargin; + var pointY = Event.pointerY(event); + if (pointY <= this.topMargin) delta = this.topMargin; else delta = pointY - this.offsetTop - 5; this.origLower = this.lowerBlock.offsetTop - 5; document.body.setStyle({ cursor: "n-resize" }); @@ -56,34 +58,34 @@ var SOGoDragHandlesInterface = { return false; }, - stopHandleDragging: function (event) { + stopHandleDragging: function (event) { if (!this.dhType) this._determineType(); if (this.dhType == 'horizontal') { var pointerX = Event.pointerX(event); if (pointerX <= this.leftMargin) { - this.rightBlock.setStyle({ left: (this.leftMargin) + 'px' }); - this.leftBlock.setStyle({ width: (this.leftMargin) + 'px' }); + this.rightBlock.setStyle({ left: (this.leftMargin) + 'px' }); + this.leftBlock.setStyle({ width: (this.leftMargin) + 'px' }); } else { - var deltaX = Math.floor(pointerX - this.origX - (this.offsetWidth / 2)); - this.rightBlock.setStyle({ left: (this.origRight + deltaX) + 'px' }); - this.leftBlock.setStyle({ width: (this.origLeft + deltaX) + 'px' }); + var deltaX = Math.floor(pointerX - this.origX - (this.offsetWidth / 2)); + this.rightBlock.setStyle({ left: (this.origRight + deltaX) + 'px' }); + this.leftBlock.setStyle({ width: (this.origLeft + deltaX) + 'px' }); } this.saveDragHandleState(this.dhType, parseInt(this.leftBlock.getStyle("width"))); } else if (this.dhType == 'vertical') { - var pointerY = Event.pointerY(event); - if (pointerY <= this.topMargin) { - this.lowerBlock.setStyle({ top: (this.topMargin - delta) + 'px' }); - this.upperBlock.setStyle({ height: (this.topMargin - delta) + 'px' }); - } - else { - var deltaY = Math.floor(pointerY - this.origY - (this.offsetHeight / 2)); - this.lowerBlock.setStyle({ top: (this.origLower + deltaY - delta) + 'px' }); - this.upperBlock.setStyle({ height: (this.origUpper + deltaY - delta) + 'px' }); - } - this.saveDragHandleState(this.dhType, parseInt(this.lowerBlock.getStyle("top"))); + var pointerY = Event.pointerY(event); + if (pointerY <= this.topMargin) { + this.lowerBlock.setStyle({ top: (this.topMargin - delta) + 'px' }); + this.upperBlock.setStyle({ height: (this.topMargin - delta) + 'px' }); + } + else { + var deltaY = Math.floor(pointerY - this.origY - (this.offsetHeight / 2)); + this.lowerBlock.setStyle({ top: (this.origLower + deltaY - delta) + 'px' }); + this.upperBlock.setStyle({ height: (this.origUpper + deltaY - delta) + 'px' }); + } + this.saveDragHandleState(this.dhType, parseInt(this.lowerBlock.getStyle("top"))); } Event.stopObserving(document.body, "mouseup", this.stopHandleDraggingBound, true); Event.stopObserving(document.body, "mousemove", this.moveBound, true); @@ -92,27 +94,27 @@ var SOGoDragHandlesInterface = { Event.stop(event); }, - move: function (event) { + move: function (event) { if (!this.dhType) this._determineType(); if (this.dhType == 'horizontal') { var hX = Event.pointerX(event); var width = this.offsetWidth; if (hX < this.leftMargin) - hX = this.leftMargin + Math.floor(width / 2); + hX = this.leftMargin + Math.floor(width / 2); var newLeft = Math.floor(hX - (width / 2)); this.setStyle({ left: newLeft + 'px' }); } else if (this.dhType == 'vertical') { var height = this.offsetHeight; var hY = Event.pointerY(event); if (hY < this.topMargin) - hY = this.topMargin + Math.floor(height / 2); + hY = this.topMargin + Math.floor(height / 2); var newTop = Math.floor(hY - (height / 2)) - delta; this.setStyle({ top: newTop + 'px' }); } Event.stop(event); }, - doubleClick: function (event) { + doubleClick: function (event) { if (!this.dhType) this._determineType(); if (this.dhType == 'horizontal') { @@ -137,13 +139,13 @@ var SOGoDragHandlesInterface = { } } }, - saveDragHandleState: function (type, position) { + saveDragHandleState: function (type, position) { var urlstr = ApplicationBaseURL + "saveDragHandleState" + "?" + type + "=" + position; triggerAjaxRequest(urlstr, this.saveDragHandleStateCallback); }, - saveDragHandleStateCallback: function (http) { + saveDragHandleStateCallback: function (http) { if (isHttpStatus204(http.status)) { log ("drag handle state saved"); } diff --git a/UI/WebServerResources/SOGoRootPage.js b/UI/WebServerResources/SOGoRootPage.js index ac856113a..e351dda85 100644 --- a/UI/WebServerResources/SOGoRootPage.js +++ b/UI/WebServerResources/SOGoRootPage.js @@ -1,101 +1,103 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + function initLogin() { - var date = new Date(); - date.setTime(date.getTime() - 86400000); - document.cookie = ("0xHIGHFLYxSOGo-0.9=discard; path=/" - + "; expires=" + date.toGMTString()); - var submit = $("submit"); - submit.observe("click", onLoginClick); + var date = new Date(); + date.setTime(date.getTime() - 86400000); + document.cookie = ("0xHIGHFLYxSOGo-0.9=discard; path=/" + + "; expires=" + date.toGMTString()); + var submit = $("submit"); + submit.observe("click", onLoginClick); - var userName = $("userName"); - userName.focus(); + var userName = $("userName"); + userName.focus(); - var image = $("preparedAnimation"); - image.parentNode.removeChild(image); + var image = $("preparedAnimation"); + image.parentNode.removeChild(image); } function onLoginClick(event) { - var userNameField = $("userName"); - var userName = userNameField.value; - var password = $("password").value; + var userNameField = $("userName"); + var userName = userNameField.value; + var password = $("password").value; - if (userName.length > 0) { - startAnimation($("loginButton"), $("submit")); + if (userName.length > 0) { + startAnimation($("loginButton"), $("submit")); - if (typeof(loginSuffix) != "undefined" - && loginSuffix.length > 0 - && !userName.endsWith(loginSuffix)) - userName += loginSuffix; - var url = $("connectForm").getAttribute("action"); - var parameters = ("userName=" + encodeURI(userName) + "&password=" + encodeURI(password)); - document.cookie = ""; - triggerAjaxRequest(url, onLoginCallback, null, parameters, - { "Content-type": "application/x-www-form-urlencoded", - "Content-length": parameters.length, - "Connection": "close" }); - } - else - userNameField.focus(); + if (typeof(loginSuffix) != "undefined" + && loginSuffix.length > 0 + && !userName.endsWith(loginSuffix)) + userName += loginSuffix; + var url = $("connectForm").getAttribute("action"); + var parameters = ("userName=" + encodeURI(userName) + "&password=" + encodeURI(password)); + document.cookie = ""; + triggerAjaxRequest(url, onLoginCallback, null, parameters, + { "Content-type": "application/x-www-form-urlencoded", + "Content-length": parameters.length, + "Connection": "close" }); + } + else + userNameField.focus(); - preventDefault(event); + preventDefault(event); } function onLoginCallback(http) { - if (http.readyState == 4) { - var noCookiesErrorMessage = $("noCookiesErrorMessage"); - var loginErrorMessage = $("loginErrorMessage"); + if (http.readyState == 4) { + var noCookiesErrorMessage = $("noCookiesErrorMessage"); + var loginErrorMessage = $("loginErrorMessage"); - if (isHttpStatus204(http.status)) { - // Make sure browser's cookies are enabled - var cookieExists = 0; - var ca = document.cookie.split(';'); - for (var i = 0; i < ca.length; i++) { - var c = ca[i]; - while (c.charAt(0) == ' ') c = c.substring(1, c.length); - if (c.indexOf("0xHIGHFLYxSOGo-0.9=") == 0) { - cookieExists = 1; - break; - } - } - if (cookieExists === 0) { - loginErrorMessage.hide(); - noCookiesErrorMessage.show(); - return false; - } + if (isHttpStatus204(http.status)) { + // Make sure browser's cookies are enabled + var cookieExists = 0; + var ca = document.cookie.split(';'); + for (var i = 0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) == ' ') c = c.substring(1, c.length); + if (c.indexOf("0xHIGHFLYxSOGo-0.9=") == 0) { + cookieExists = 1; + break; + } + } + if (cookieExists === 0) { + loginErrorMessage.hide(); + noCookiesErrorMessage.show(); + return false; + } - // Redirect to proper page - var userName = $("userName").value; - if (typeof(loginSuffix) != "undefined" - && loginSuffix.length > 0 - && !userName.endsWith(loginSuffix)) - userName += loginSuffix; - var address = "" + window.location.href; - var baseAddress = ApplicationBaseURL + encodeURI(userName); - var altBaseAddress; - if (baseAddress[0] == "/") { - var parts = address.split("/"); - var hostpart = parts[2]; - var protocol = parts[0]; - baseAddress = protocol + "//" + hostpart + baseAddress; - } - var altBaseAddress; - var parts = baseAddress.split("/"); - parts.splice(3, 0); - altBaseAddress = parts.join("/"); + // Redirect to proper page + var userName = $("userName").value; + if (typeof(loginSuffix) != "undefined" + && loginSuffix.length > 0 + && !userName.endsWith(loginSuffix)) + userName += loginSuffix; + var address = "" + window.location.href; + var baseAddress = ApplicationBaseURL + encodeURI(userName); + var altBaseAddress; + if (baseAddress[0] == "/") { + var parts = address.split("/"); + var hostpart = parts[2]; + var protocol = parts[0]; + baseAddress = protocol + "//" + hostpart + baseAddress; + } + var altBaseAddress; + var parts = baseAddress.split("/"); + parts.splice(3, 0); + altBaseAddress = parts.join("/"); - var newAddress; - if ((address.startsWith(baseAddress) - || address.startsWith(altBaseAddress)) - && !address.endsWith("/logoff")) - newAddress = address; - else - newAddress = baseAddress; - window.location.href = newAddress; - } - else { - loginErrorMessage.show(); - noCookiesErrorMessage.hide(); - } - } + var newAddress; + if ((address.startsWith(baseAddress) + || address.startsWith(altBaseAddress)) + && !address.endsWith("/logoff")) + newAddress = address; + else + newAddress = baseAddress; + window.location.href = newAddress; + } + else { + loginErrorMessage.show(); + noCookiesErrorMessage.hide(); + } + } } FastInit.addOnLoad(initLogin); diff --git a/UI/WebServerResources/SchedulerUI.js b/UI/WebServerResources/SchedulerUI.js index 0c7868c7f..f505cebf9 100644 --- a/UI/WebServerResources/SchedulerUI.js +++ b/UI/WebServerResources/SchedulerUI.js @@ -1,3 +1,5 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + /* JavaScript for SOGoCalendar */ var listFilter = 'view_today'; @@ -104,11 +106,11 @@ function _batchDeleteEvents() { var events = eventsToDelete.shift(); var calendar = calendarsOfEventsToDelete.shift(); var urlstr = (ApplicationBaseURL + calendar - + "/batchDelete?ids=" + events.join('/')); + + "/batchDelete?ids=" + events.join('/')); document.deleteEventAjaxRequest = triggerAjaxRequest(urlstr, deleteEventCallback, - { calendar: calendar, - events: events }); + { calendar: calendar, + events: events }); } function deleteEvent() { @@ -122,32 +124,32 @@ function deleteEvent() { label = labels["eventDeleteConfirmation"]; if (nodes.length == 1 - && nodes[0].recurrenceTime) { - _editRecurrenceDialog(nodes[0], "confirmDeletion"); + && nodes[0].recurrenceTime) { + _editRecurrenceDialog(nodes[0], "confirmDeletion"); } else { - if (confirm(label)) { - if (document.deleteEventAjaxRequest) { - document.deleteEventAjaxRequest.aborted = true; - document.deleteEventAjaxRequest.abort(); - } - var sortedNodes = []; - var calendars = []; + if (confirm(label)) { + if (document.deleteEventAjaxRequest) { + document.deleteEventAjaxRequest.aborted = true; + document.deleteEventAjaxRequest.abort(); + } + var sortedNodes = []; + var calendars = []; - for (var i = 0; i < nodes.length; i++) { - var calendar = nodes[i].calendar; - if (!sortedNodes[calendar]) { - sortedNodes[calendar] = []; - calendars.push(calendar); - } - sortedNodes[calendar].push(nodes[i].cname); - } - for (var i = 0; i < calendars.length; i++) { - calendarsOfEventsToDelete.push(calendars[i]); - eventsToDelete.push(sortedNodes[calendars[i]]); - } - _batchDeleteEvents(); - } + for (var i = 0; i < nodes.length; i++) { + var calendar = nodes[i].calendar; + if (!sortedNodes[calendar]) { + sortedNodes[calendar] = []; + calendars.push(calendar); + } + sortedNodes[calendar].push(nodes[i].cname); + } + for (var i = 0; i < calendars.length; i++) { + calendarsOfEventsToDelete.push(calendars[i]); + eventsToDelete.push(sortedNodes[calendars[i]]); + } + _batchDeleteEvents(); + } } } else { window.alert(labels["Please select an event or a task."]); @@ -160,13 +162,13 @@ function deleteEvent() { else { var label = labels["eventDeleteConfirmation"]; if (confirm(label)) { - if (document.deleteEventAjaxRequest) { - document.deleteEventAjaxRequest.aborted = true; - document.deleteEventAjaxRequest.abort(); - } - eventsToDelete.push([selectedCalendarCell[0].cname]); - calendarsOfEventsToDelete.push(selectedCalendarCell[0].calendar); - _batchDeleteEvents(); + if (document.deleteEventAjaxRequest) { + document.deleteEventAjaxRequest.aborted = true; + document.deleteEventAjaxRequest.abort(); + } + eventsToDelete.push([selectedCalendarCell[0].cname]); + calendarsOfEventsToDelete.push(selectedCalendarCell[0].calendar); + _batchDeleteEvents(); } } } @@ -212,10 +214,10 @@ function modifyEventCallback(http) { if (http.status == 200) { var mailInvitation = queryParameters["mail-invitation"]; if (mailInvitation && mailInvitation.toLowerCase() == "yes") - closeInvitationWindow(); + closeInvitationWindow(); else { - window.opener.setTimeout("refreshEventsAndDisplay();", 100); - window.setTimeout("window.close();", 100); + window.opener.setTimeout("refreshEventsAndDisplay();", 100); + window.setTimeout("window.close();", 100); } } else { @@ -232,11 +234,11 @@ function _deleteCalendarEventBlocks(calendar, cname) { var occurences = events[cname]; if (occurences) for (var i = 0; i < occurences.length; i++) { - var nodes = occurences[i].blocks; - for (var j = 0; j < nodes.length; j++) { - var node = nodes[j]; - node.parentNode.removeChild(node); - } + var nodes = occurences[i].blocks; + for (var j = 0; j < nodes.length; j++) { + var node = nodes[j]; + node.parentNode.removeChild(node); + } } } } @@ -253,7 +255,7 @@ function _deleteEventFromTables(basename) { var row = $(rows[j - 1]); var id = row.getAttribute("id"); if (id.indexOf(basename) == 0) - row.parentNode.removeChild(row); + row.parentNode.removeChild(row); } } } @@ -265,19 +267,19 @@ function deleteEventCallback(http) { var calendar = http.callbackData.calendar; var events = http.callbackData.events; -// log("calendar: " + calendar + "\n"); -// log("events: " + events.join(", " ) + "\n"); + // log("calendar: " + calendar + "\n"); + // log("events: " + events.join(", " ) + "\n"); for (var i = 0; i < events.length; i++) { - var cname = events[i]; - _deleteCalendarEventBlocks(calendar, cname); - _deleteEventFromTables(calendar + "-" + cname); - delete calendarEvents[calendar][cname]; + var cname = events[i]; + _deleteCalendarEventBlocks(calendar, cname); + _deleteEventFromTables(calendar + "-" + cname); + delete calendarEvents[calendar][cname]; } if (eventsToDelete.length) - _batchDeleteEvents(); + _batchDeleteEvents(); else { - document.deleteEventAjaxRequest = null; + document.deleteEventAjaxRequest = null; } } else @@ -302,7 +304,7 @@ function getEventById(cname, owner) { function _editRecurrenceDialog(eventDiv, method) { var targetname = "SOGo_edit_" + eventDiv.cname + eventDiv.recurrenceTime; var urlstr = (ApplicationBaseURL + eventDiv.calendar + "/" + eventDiv.cname - + "/occurence" + eventDiv.recurrenceTime + "/" + method); + + "/occurence" + eventDiv.recurrenceTime + "/" + method); var win = window.open(urlstr, "_blank", "width=490,height=70,resizable=0"); if (win) @@ -324,9 +326,9 @@ function onViewEventCallback(http) { && http.status == 200) { if (http.responseText.length > 0) { var data = http.responseText.evalJSON(true); -// $H(data).keys().each(function(key) { -// log (key + " = " + data[key]); -// }); + // $H(data).keys().each(function(key) { + // log (key + " = " + data[key]); + // }); var cell = http.callbackData; var cellPosition = cell.cumulativeOffset(); var cellDimensions = cell.getDimensions(); @@ -337,56 +339,56 @@ function onViewEventCallback(http) { var top = cellPosition[1]; if (currentView != "monthview") { - view = $("daysView"); - var viewPosition = view.cumulativeOffset(); + view = $("daysView"); + var viewPosition = view.cumulativeOffset(); - if (parseInt(data["isAllDay"]) == 0) { - top -= view.scrollTop; - if (viewPosition[1] > top + 2) { - view.stopObserving("scroll", onBodyClickHandler); - view.scrollTop = cell.offsetTop; - top = viewPosition[1]; - Event.observe.delay(0.1, view, "scroll", onBodyClickHandler); - } - } + if (parseInt(data["isAllDay"]) == 0) { + top -= view.scrollTop; + if (viewPosition[1] > top + 2) { + view.stopObserving("scroll", onBodyClickHandler); + view.scrollTop = cell.offsetTop; + top = viewPosition[1]; + Event.observe.delay(0.1, view, "scroll", onBodyClickHandler); + } + } } else { - view = $("calendarView"); - top -= cell.up("DIV.day").scrollTop; + view = $("calendarView"); + top -= cell.up("DIV.day").scrollTop; } if (left > parseInt(window.width()*0.75)) { - left = left - divDimensions["width"] + 10; - div.removeClassName("left"); - div.addClassName("right"); + left = left - divDimensions["width"] + 10; + div.removeClassName("left"); + div.addClassName("right"); } else { - left = left + cellDimensions["width"] - parseInt(cellDimensions["width"]/3); - div.removeClassName("right"); - div.addClassName("left"); + left = left + cellDimensions["width"] - parseInt(cellDimensions["width"]/3); + div.removeClassName("right"); + div.addClassName("left"); } // Put the event's data in the DIV div.down("h1").update(data["summary"]); if (parseInt(data["isAllDay"]) == 0) { - div.down("P", 0).down("SPAN", 1).update(data["startTime"]); - div.down("P", 0).show(); + div.down("P", 0).down("SPAN", 1).update(data["startTime"]); + div.down("P", 0).show(); } else - div.down("P", 0).hide(); + div.down("P", 0).hide(); if (data["location"].length) { - div.down("P", 1).down("SPAN", 1).update(data["location"]); - div.down("P", 1).show(); + div.down("P", 1).down("SPAN", 1).update(data["location"]); + div.down("P", 1).show(); } else - div.down("P", 1).hide(); + div.down("P", 1).hide(); if (data["description"].length) { - div.down("P", 2).update(data["description"]); - div.down("P", 2).show(); + div.down("P", 2).update(data["description"]); + div.down("P", 2).show(); } else - div.down("P", 2).hide(); + div.down("P", 2).hide(); div.setStyle({ left: left + "px", - top: top + "px" }); + top: top + "px" }); div.show(); } } @@ -420,9 +422,9 @@ function performEventDeletion(folder, event, recurrence) { var nodes = _eventBlocksMatching(folder, event, occurenceTime); if (nodes) document.deleteEventAjaxRequest = triggerAjaxRequest(urlstr, - performDeleteEventCallback, - { nodes: nodes, - occurence: occurenceTime }); + performDeleteEventCallback, + { nodes: nodes, + occurence: occurenceTime }); } } @@ -434,30 +436,30 @@ function performDeleteEventCallback(http) { var cname = nodes[0].cname; var calendar = nodes[0].calendar; for (var i = 0; i < nodes.length; i++) { - var node = nodes[i]; -// log("node: " + node); - node.parentNode.removeChild(node); + var node = nodes[i]; + // log("node: " + node); + node.parentNode.removeChild(node); } var basename = calendar + "-" + cname; if (occurenceTime) { - var row = $(basename + "-" + occurenceTime); -// log("rowID: " + basename + "-" + occurenceTime); - if (row) - row.parentNode.removeChild(row); + var row = $(basename + "-" + occurenceTime); + // log("rowID: " + basename + "-" + occurenceTime); + if (row) + row.parentNode.removeChild(row); - var occurences = calendarEvents[calendar][cname]; - var newOccurences = []; - for (var i = 0; i < occurences.length; i++) { - var occurence = occurences[i]; - if (occurence[13] != recurrenceTime) - newOccurences.push(occurence); - } - calendarEvents[calendar][cname] = newOccurences; + var occurences = calendarEvents[calendar][cname]; + var newOccurences = []; + for (var i = 0; i < occurences.length; i++) { + var occurence = occurences[i]; + if (occurence[13] != recurrenceTime) + newOccurences.push(occurence); + } + calendarEvents[calendar][cname] = newOccurences; } else { -// log("basename: " + basename); - _deleteEventFromTables(basename); - delete calendarEvents[calendar][cname]; + // log("basename: " + basename); + _deleteEventFromTables(basename); + delete calendarEvents[calendar][cname]; } } } @@ -555,64 +557,64 @@ function eventsListCallback(http) { if (http.responseText.length > 0) { var data = http.responseText.evalJSON(true); for (var i = 0; i < data.length; i++) { - var row = $(document.createElement("tr")); - table.tBodies[0].appendChild(row); - row.addClassName("eventRow"); - var rTime = data[i][13]; - var id = escape(data[i][1] + "-" + data[i][0]); - if (rTime) - id += "-" + escape(rTime); - row.setAttribute("id", id); - row.cname = escape(data[i][0]); - row.calendar = escape(data[i][1]); - if (rTime) - row.recurrenceTime = escape(rTime); - var startDate = new Date(); - startDate.setTime(data[i][4] * 1000); - row.day = startDate.getDayString(); - row.hour = startDate.getHourString(); - row.observe("mousedown", onRowClick); - row.observe("selectstart", listRowMouseDownHandler); - row.observe("dblclick", editDoubleClickedEvent); - row.observe("contextmenu", onEventContextMenu); + var row = $(document.createElement("tr")); + table.tBodies[0].appendChild(row); + row.addClassName("eventRow"); + var rTime = data[i][13]; + var id = escape(data[i][1] + "-" + data[i][0]); + if (rTime) + id += "-" + escape(rTime); + row.setAttribute("id", id); + row.cname = escape(data[i][0]); + row.calendar = escape(data[i][1]); + if (rTime) + row.recurrenceTime = escape(rTime); + var startDate = new Date(); + startDate.setTime(data[i][4] * 1000); + row.day = startDate.getDayString(); + row.hour = startDate.getHourString(); + row.observe("mousedown", onRowClick); + row.observe("selectstart", listRowMouseDownHandler); + row.observe("dblclick", editDoubleClickedEvent); + row.observe("contextmenu", onEventContextMenu); - var td = $(document.createElement("td")); - row.appendChild(td); - td.observe("mousedown", listRowMouseDownHandler, true); - td.appendChild(document.createTextNode(data[i][3])); + var td = $(document.createElement("td")); + row.appendChild(td); + td.observe("mousedown", listRowMouseDownHandler, true); + td.appendChild(document.createTextNode(data[i][3])); - td = $(document.createElement("td")); - row.appendChild(td); - td.observe("mousedown", listRowMouseDownHandler, true); - td.appendChild(document.createTextNode(data[i][14])); + td = $(document.createElement("td")); + row.appendChild(td); + td.observe("mousedown", listRowMouseDownHandler, true); + td.appendChild(document.createTextNode(data[i][14])); - td = $(document.createElement("td")); - row.appendChild(td); - td.observe("mousedown", listRowMouseDownHandler, true); - td.appendChild(document.createTextNode(data[i][15])); + td = $(document.createElement("td")); + row.appendChild(td); + td.observe("mousedown", listRowMouseDownHandler, true); + td.appendChild(document.createTextNode(data[i][15])); - td = $(document.createElement("td")); - row.appendChild(td); - td.observe("mousedown", listRowMouseDownHandler, true); - td.appendChild(document.createTextNode(data[i][6])); + td = $(document.createElement("td")); + row.appendChild(td); + td.observe("mousedown", listRowMouseDownHandler, true); + td.appendChild(document.createTextNode(data[i][6])); } if (sorting["attribute"] && sorting["attribute"].length > 0) { - var sortHeader = $(sorting["attribute"] + "Header"); + var sortHeader = $(sorting["attribute"] + "Header"); - if (sortHeader) { - var sortImages = $(table.tHead).select(".sortImage"); - $(sortImages).each(function(item) { - item.remove(); - }); + if (sortHeader) { + var sortImages = $(table.tHead).select(".sortImage"); + $(sortImages).each(function(item) { + item.remove(); + }); - var sortImage = createElement("img", "messageSortImage", "sortImage"); - sortHeader.insertBefore(sortImage, sortHeader.firstChild); - if (sorting["ascending"]) - sortImage.src = ResourcesURL + "/title_sortdown_12x12.png"; - else - sortImage.src = ResourcesURL + "/title_sortup_12x12.png"; - } + var sortImage = createElement("img", "messageSortImage", "sortImage"); + sortHeader.insertBefore(sortImage, sortHeader.firstChild); + if (sorting["ascending"]) + sortImage.src = ResourcesURL + "/title_sortdown_12x12.png"; + else + sortImage.src = ResourcesURL + "/title_sortup_12x12.png"; + } } } } @@ -632,43 +634,43 @@ function tasksListCallback(http) { var data = http.responseText.evalJSON(true); for (var i = 0; i < data.length; i++) { - var listItem = $(document.createElement("li")); - list.appendChild(listItem); - listItem.observe("mousedown", listRowMouseDownHandler); - listItem.observe("click", onRowClick); - listItem.observe("dblclick", editDoubleClickedEvent); + var listItem = $(document.createElement("li")); + list.appendChild(listItem); + listItem.observe("mousedown", listRowMouseDownHandler); + listItem.observe("click", onRowClick); + listItem.observe("dblclick", editDoubleClickedEvent); - var calendar = escape(data[i][1]); - var cname = escape(data[i][0]); - listItem.setAttribute("id", calendar + "-" + cname); - listItem.addClassName(data[i][5]); - listItem.addClassName(data[i][6]); - listItem.calendar = calendar; - listItem.addClassName("calendarFolder" + calendar); - listItem.cname = cname; - var input = $(document.createElement("input")); - input.setAttribute("type", "checkbox"); - listItem.appendChild(input); - input.observe("click", updateTaskStatus, true); - input.setAttribute("value", "1"); - if (data[i][2] == 1) - input.setAttribute("checked", "checked"); - $(input).addClassName("checkBox"); + var calendar = escape(data[i][1]); + var cname = escape(data[i][0]); + listItem.setAttribute("id", calendar + "-" + cname); + listItem.addClassName(data[i][5]); + listItem.addClassName(data[i][6]); + listItem.calendar = calendar; + listItem.addClassName("calendarFolder" + calendar); + listItem.cname = cname; + var input = $(document.createElement("input")); + input.setAttribute("type", "checkbox"); + listItem.appendChild(input); + input.observe("click", updateTaskStatus, true); + input.setAttribute("value", "1"); + if (data[i][2] == 1) + input.setAttribute("checked", "checked"); + $(input).addClassName("checkBox"); - listItem.appendChild(document.createTextNode(data[i][3])); + listItem.appendChild(document.createTextNode(data[i][3])); } list.scrollTop = list.previousScroll; if (http.callbackData) { - var selectedNodesId = http.callbackData; - for (var i = 0; i < selectedNodesId.length; i++) { - // log(selectedNodesId[i] + " (" + i + ") is selected"); - $(selectedNodesId[i]).selectElement(); - } + var selectedNodesId = http.callbackData; + for (var i = 0; i < selectedNodesId.length; i++) { + // log(selectedNodesId[i] + " (" + i + ") is selected"); + $(selectedNodesId[i]).selectElement(); + } } else - log ("tasksListCallback: no data"); + log ("tasksListCallback: no data"); } } else @@ -690,11 +692,11 @@ function restoreCurrentDaySelection(div) { for (i = 0; i < elements.length; i++) { day = elements[i].day; if (day && day == currentDay) { - var td = $(elements[i]).getParentWithTagName("td"); - if (document.selectedDate) - document.selectedDate.deselect(); - $(td).selectElement(); - document.selectedDate = td; + var td = $(elements[i]).getParentWithTagName("td"); + if (document.selectedDate) + document.selectedDate.deselect(); + $(td).selectElement(); + document.selectedDate = td; } } } @@ -746,35 +748,35 @@ function changeCalendarDisplay(data, newView) { if (data) { var divs = $$('div.day[day='+day+']'); if (divs.length) { - // Don't reload the view if the event is present in current view + // Don't reload the view if the event is present in current view - // Deselect previous day - var selectedDivs = $$('div.day.selectedDay'); - selectedDivs.each(function(div) { - div.removeClassName('selectedDay'); - }); + // Deselect previous day + var selectedDivs = $$('div.day.selectedDay'); + selectedDivs.each(function(div) { + div.removeClassName('selectedDay'); + }); - // Select new day - divs.each(function(div) { - div.addClassName('selectedDay'); - }); + // Select new day + divs.each(function(div) { + div.addClassName('selectedDay'); + }); - // Deselect day in date selector - if (document.selectedDate) - document.selectedDate.deselect(); + // Deselect day in date selector + if (document.selectedDate) + document.selectedDate.deselect(); - // Select day in date selector - var selectedLink = $$('table#dateSelectorTable a[day='+day+']'); - if (selectedLink.length > 0) { - selectedCell = selectedLink[0].up(1); - selectedCell.selectElement(); - document.selectedDate = selectedCell; - } + // Select day in date selector + var selectedLink = $$('table#dateSelectorTable a[day='+day+']'); + if (selectedLink.length > 0) { + selectedCell = selectedLink[0].up(1); + selectedCell.selectElement(); + document.selectedDate = selectedCell; + } - // Scroll to event - scrollDayView(scrollEvent); + // Scroll to event + scrollDayView(scrollEvent); - return false; + return false; } } url += "?day=" + day; @@ -788,9 +790,9 @@ function changeCalendarDisplay(data, newView) { } document.dayDisplayAjaxRequest = triggerAjaxRequest(url, calendarDisplayCallback, - { "view": newView, - "day": day, - "scrollEvent": scrollEvent }); + { "view": newView, + "day": day, + "scrollEvent": scrollEvent }); return false; } @@ -895,11 +897,11 @@ function refreshCalendarEvents(scrollEvent) { document.refreshCalendarEventsAjaxRequest.abort(); } var url = (ApplicationBaseURL + "eventsblocks?sd=" + sd + "&ed=" + ed - + "&view=" + currentView); + + "&view=" + currentView); document.refreshCalendarEventsAjaxRequest = triggerAjaxRequest(url, refreshCalendarEventsCallback, - {"startDate": sd, "endDate": ed, - "scrollEvent": scrollEvent}); + {"startDate": sd, "endDate": ed, + "scrollEvent": scrollEvent}); } function _parseEvents(list) { @@ -909,7 +911,7 @@ function _parseEvents(list) { var event = list[i]; var cname = event[0]; var calendar = event[1]; -// log("parsed cname: " + cname + "; calendar: " + calendar); + // log("parsed cname: " + cname + "; calendar: " + calendar); var calendarDict = newCalendarEvents[calendar]; if (!calendarDict) { calendarDict = {}; @@ -934,10 +936,10 @@ function refreshCalendarEventsCallback(http) { var eventsBlocks = http.responseText.evalJSON(true); calendarEvents = _parseEvents(eventsBlocks[0]); if (currentView == "monthview") - _drawMonthCalendarEvents(eventsBlocks[2], eventsBlocks[0]); + _drawMonthCalendarEvents(eventsBlocks[2], eventsBlocks[0]); else { - _drawCalendarAllDayEvents(eventsBlocks[1], eventsBlocks[0]); - _drawCalendarEvents(eventsBlocks[2], eventsBlocks[0]); + _drawCalendarAllDayEvents(eventsBlocks[1], eventsBlocks[0]); + _drawCalendarEvents(eventsBlocks[2], eventsBlocks[0]); } } scrollDayView(http.callbackData["scrollEvent"]); @@ -947,8 +949,8 @@ function refreshCalendarEventsCallback(http) { } function newBaseEventDIV(eventRep, event, eventText) { -// cname, calendar, starts, lasts, -// startHour, endHour, title) { + // cname, calendar, starts, lasts, + // startHour, endHour, title) { var eventDiv = $(document.createElement("div")); eventDiv.cname = event[0]; eventDiv.calendar = event[1]; @@ -1002,8 +1004,8 @@ function _drawCalendarAllDayEvents(events, eventsData) { } function newAllDayEventDIV(eventRep, event) { -// cname, calendar, starts, lasts, -// startHour, endHour, title) { + // cname, calendar, starts, lasts, + // startHour, endHour, title) { var eventDiv = newBaseEventDIV(eventRep, event, event[3]); return eventDiv; @@ -1059,7 +1061,7 @@ function newMonthEventDIV(eventRep, event) { eventText = eventRep.starthour + " - " + event[3]; var eventDiv = newBaseEventDIV(eventRep, event, - eventText); + eventText); return eventDiv; } @@ -1091,32 +1093,32 @@ function calendarDisplayCallback(http) { for (var i = 0; i < days.length; i++) { days[i].observe("click", onCalendarSelectDay); days[i].observe("dblclick", onClickableCellsDblClick); - days[i].observe("selectstart", listRowMouseDownHandler); - //days[i].down(".dayHeader").observe("selectstart", listRowMouseDownHandler); - if (currentView == "monthview") - days[i].observe("scroll", onBodyClickHandler); + days[i].observe("selectstart", listRowMouseDownHandler); + //days[i].down(".dayHeader").observe("selectstart", listRowMouseDownHandler); + if (currentView == "monthview") + days[i].observe("scroll", onBodyClickHandler); } else { var headerDivs = $("calendarHeader").childNodesWithTag("div"); var headerDaysLabels - = document.getElementsByClassName("day", headerDivs[0]); + = document.getElementsByClassName("day", headerDivs[0]); var headerDays = document.getElementsByClassName("day", headerDivs[1]); for (var i = 0; i < days.length; i++) { - headerDays[i].hour = "allday"; - headerDaysLabels[i].observe("mousedown", listRowMouseDownHandler); - headerDays[i].observe("click", onCalendarSelectDay); - headerDays[i].observe("dblclick", onClickableCellsDblClick); - days[i].observe("click", onCalendarSelectDay); - var clickableCells - = document.getElementsByClassName("clickableHourCell", days[i]); - for (var j = 0; j < clickableCells.length; j++) - clickableCells[j].observe("dblclick", onClickableCellsDblClick); + headerDays[i].hour = "allday"; + headerDaysLabels[i].observe("mousedown", listRowMouseDownHandler); + headerDays[i].observe("click", onCalendarSelectDay); + headerDays[i].observe("dblclick", onClickableCellsDblClick); + days[i].observe("click", onCalendarSelectDay); + var clickableCells + = document.getElementsByClassName("clickableHourCell", days[i]); + for (var j = 0; j < clickableCells.length; j++) + clickableCells[j].observe("dblclick", onClickableCellsDblClick); } } } else log ("calendarDisplayCallback Ajax error (" - + http.readyState + "/" + http.status + ")"); + + http.readyState + "/" + http.status + ")"); } function assignCalendar(name) { @@ -1165,7 +1167,7 @@ function onEventsSelectionChange() { if (rows.length == 1) { var row = rows[0]; changeCalendarDisplay( { "day": row.day, - "scrollEvent": row.getAttribute("id") } ); + "scrollEvent": row.getAttribute("id") } ); changeDateSelectorDisplay(row.day); } } @@ -1253,10 +1255,10 @@ function refreshEvents() { titleSearch = ""; return _loadEventHref("eventslist?asc=" + sorting["ascending"] - + "&sort=" + sorting["attribute"] - + "&day=" + currentDay - + titleSearch - + "&filterpopup=" + listFilter); + + "&sort=" + sorting["attribute"] + + "&day=" + currentDay + + titleSearch + + "&filterpopup=" + listFilter); } function refreshTasks() { @@ -1344,18 +1346,18 @@ function _eventBlocksMatching(calendar, cname, recurrenceTime) { var occurences = events[cname]; if (occurences) { if (recurrenceTime) { - for (var i = 0; i < occurences.length; i++) { - var occurence = occurences[i]; - if (occurence[13] == recurrenceTime) - blocks = occurence.blocks; - } + for (var i = 0; i < occurences.length; i++) { + var occurence = occurences[i]; + if (occurence[13] == recurrenceTime) + blocks = occurence.blocks; + } } else { - blocks = []; - for (var i = 0; i < occurences.length; i++) { - var occurence = occurences[i]; - blocks = blocks.concat(occurence.blocks); - } + blocks = []; + for (var i = 0; i < occurences.length; i++) { + var occurence = occurences[i]; + blocks = blocks.concat(occurence.blocks); + } } } } @@ -1425,7 +1427,7 @@ function changeWeekCalendarDisplayOfSelectedDay(node) { for (var i = 0; i < days.length; i++) { if (days[i] == node - || headerDays[i] == node) { + || headerDays[i] == node) { headerDays[i].addClassName("selectedDay"); days[i].addClassName("selectedDay"); } @@ -1443,7 +1445,7 @@ function findMonthCalendarSelectedCell(daysContainer) { while (!found && i < daysContainer.childNodes.length) { var currentNode = daysContainer.childNodes[i]; if (currentNode.tagName == 'DIV' - && currentNode.hasClassName("selectedDay")) { + && currentNode.hasClassName("selectedDay")) { daysContainer.selectedCell = currentNode; found = true; } @@ -1478,7 +1480,7 @@ function updateTaskStatus(event) { } url = (ApplicationBaseURL + this.parentNode.calendar - + "/" + this.parentNode.cname + "/changeStatus?status=" + newStatus); + + "/" + this.parentNode.cname + "/changeStatus?status=" + newStatus); if (http) { // TODO: add parameter to signal that we are only interested in OK @@ -1510,9 +1512,9 @@ function updateCalendarStatus(event) { var folderId = nodes[i].getAttribute("id"); var elems = folderId.split(":"); if (elems.length > 1) - list.push(elems[0]); + list.push(elems[0]); else - list.push(UserLogin); + list.push(UserLogin); } } @@ -1631,15 +1633,15 @@ function getMenus() { menus["yearListMenu"] = dateMenu; menus["eventsListMenu"] = new Array(onMenuNewEventClick, "-", - onMenuNewTaskClick, - editEvent, deleteEvent, "-", - onSelectAll, "-", - null, null); + onMenuNewTaskClick, + editEvent, deleteEvent, "-", + onSelectAll, "-", + null, null); menus["calendarsMenu"] = new Array(onCalendarModify, - "-", - onCalendarNew, onCalendarRemove, - "-", null, null, "-", - null, "-", onMenuSharing); + "-", + onCalendarNew, onCalendarRemove, + "-", null, null, "-", + null, "-", onMenuSharing); menus["searchMenu"] = new Array(setSearchCriteria); var calendarsMenu = $("calendarsMenu"); @@ -1711,7 +1713,7 @@ function onCalendarModify(event) { var url = ApplicationBaseURL + calendarID + "/properties"; var windowID = sanitizeWindowName(calendarID + " properties"); var properties = window.open(url, windowID, - "width=300,height=100,resizable=0"); + "width=300,height=100,resizable=0"); properties.focus(); } @@ -1723,7 +1725,7 @@ function updateCalendarProperties(calendarID, calendarName, calendarColor) { nodeID = "/" + idParts[0] + "_" + folderName; else nodeID = "/" + folderName; -// log("nodeID: " + nodeID); + // log("nodeID: " + nodeID); var calendarNode = $(nodeID); var childNodes = calendarNode.childNodes; childNodes[childNodes.length-1].nodeValue = calendarName; @@ -1733,7 +1735,7 @@ function updateCalendarProperties(calendarID, calendarName, calendarColor) { function onCalendarNew(event) { createFolder(window.prompt(labels["Name of the Calendar"], ""), - appendCalendar); + appendCalendar); preventDefault(event); } @@ -1783,14 +1785,14 @@ function appendCalendar(folderName, folderPath) { $(li).writeAttribute("owner", owner); var checkBox = createElement("input", null, "checkBox", { checked: 1 }, - { type: "checkbox" }, li); + { type: "checkbox" }, li); li.appendChild(document.createTextNode(" ")); var colorBox = document.createElement("div"); li.appendChild(colorBox); li.appendChild(document.createTextNode(folderName - .replace("<", "<", "g") - .replace(">", ">", "g"))); + .replace("<", "<", "g") + .replace(">", ">", "g"))); colorBox.appendChild(document.createTextNode("OO")); $(colorBox).addClassName("colorBox"); @@ -1813,20 +1815,20 @@ function appendStyleElement(folderPath, color) { var styleElement = document.createElement("style"); styleElement.type = "text/css"; var selectors = [ - 'DIV.calendarFolder' + folderPath.substr(1), - 'LI.calendarFolder' + folderPath.substr(1), - 'UL#calendarList DIV.calendarFolder' + folderPath.substr(1) - ]; + 'DIV.calendarFolder' + folderPath.substr(1), + 'LI.calendarFolder' + folderPath.substr(1), + 'UL#calendarList DIV.calendarFolder' + folderPath.substr(1) + ]; var rules = [ - ' { background-color: ' + color + ' !important;' + ' color: ' + fgColor + ' !important; }', - ' { background-color: ' + color + ' !important;' + ' color: ' + fgColor + ' !important; }', - ' { color: ' + color + ' !important; }' - ]; + ' { background-color: ' + color + ' !important;' + ' color: ' + fgColor + ' !important; }', + ' { background-color: ' + color + ' !important;' + ' color: ' + fgColor + ' !important; }', + ' { color: ' + color + ' !important; }' + ]; for (var i = 0; i < rules.length; i++) if (styleElement.styleSheet && styleElement.styleSheet.addRule) - styleElement.styleSheet.addRule(selectors[i], rules[i]); // IE + styleElement.styleSheet.addRule(selectors[i], rules[i]); // IE else - styleElement.appendChild(document.createTextNode(selectors[i] + rules[i])); // Mozilla _+ Safari + styleElement.appendChild(document.createTextNode(selectors[i] + rules[i])); // Mozilla _+ Safari document.getElementsByTagName("head")[0].appendChild(styleElement); } } @@ -1856,11 +1858,11 @@ function onCalendarRemove(event) { var folderId = nodes[i].getAttribute("id"); if (owner == UserLogin) { var folderIdElements = folderId.split(":"); - deletePersonalCalendar(folderIdElements[0]); + deletePersonalCalendar(folderIdElements[0]); } else - unsubscribeFromFolder(folderId, owner, - onFolderUnsubscribeCB, folderId); + unsubscribeFromFolder(folderId, owner, + onFolderUnsubscribeCB, folderId); } } @@ -1886,19 +1888,19 @@ function deletePersonalCalendarCallback(http) { var i = 0; var done = false; while (!done && i < children.length) { - var currentFolderId = children[i].getAttribute("id").substr(1); - if (currentFolderId == http.callbackData) { - ul.removeChild(children[i]); - done = true; - } - else - i++; + var currentFolderId = children[i].getAttribute("id").substr(1); + if (currentFolderId == http.callbackData) { + ul.removeChild(children[i]); + done = true; + } + else + i++; } removeFolderRequestCount--; if (removeFolderRequestCount == 0) { - refreshEvents(); - refreshTasks(); - changeCalendarDisplay(); + refreshEvents(); + refreshTasks(); + changeCalendarDisplay(); } } } diff --git a/UI/WebServerResources/UIxAclEditor.js b/UI/WebServerResources/UIxAclEditor.js index 4f2713a52..19046a0fb 100644 --- a/UI/WebServerResources/UIxAclEditor.js +++ b/UI/WebServerResources/UIxAclEditor.js @@ -1,3 +1,5 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + /* test */ var contactSelectorAction = 'acls-contacts'; @@ -8,18 +10,18 @@ var AclEditor = { }; function addUser(userName, userID) { - var result = false; - if (!$(userID)) { - var ul = $("userList"); - ul.appendChild(nodeForUser(userName, userID)); - var url = window.location.href; - var elements = url.split("/"); - elements[elements.length-1] = ("addUserInAcls?uid=" - + userID); - triggerAjaxRequest(elements.join("/"), addUserCallback); - result = true; - } - return result; + var result = false; + if (!$(userID)) { + var ul = $("userList"); + ul.appendChild(nodeForUser(userName, userID)); + var url = window.location.href; + var elements = url.split("/"); + elements[elements.length-1] = ("addUserInAcls?uid=" + + userID); + triggerAjaxRequest(elements.join("/"), addUserCallback); + result = true; + } + return result; } function addUserCallback(http) { @@ -34,123 +36,123 @@ function setEventsOnUserNode(node) { } function nodeForUser(userName, userId) { - var node = document.createElement("li"); - node.setAttribute("id", userId); - node.setAttribute("class", ""); - setEventsOnUserNode(node); + var node = document.createElement("li"); + node.setAttribute("id", userId); + node.setAttribute("class", ""); + setEventsOnUserNode(node); - var image = document.createElement("img"); - image.setAttribute("src", ResourcesURL + "/abcard.gif"); + var image = document.createElement("img"); + image.setAttribute("src", ResourcesURL + "/abcard.gif"); - node.appendChild(image); - node.appendChild(document.createTextNode(" " + userName)); + node.appendChild(image); + node.appendChild(document.createTextNode(" " + userName)); - return node; + return node; } function saveAcls() { - var uidList = new Array(); - var users = $("userList").childNodesWithTag("li"); - for (var i = 0; i < users.length; i++) - uidList.push(users[i].getAttribute("id")); - $("userUIDS").value = uidList.join(","); - $("aclForm").submit(); + var uidList = new Array(); + var users = $("userList").childNodesWithTag("li"); + for (var i = 0; i < users.length; i++) + uidList.push(users[i].getAttribute("id")); + $("userUIDS").value = uidList.join(","); + $("aclForm").submit(); - return false; + return false; } function onUserAdd(event) { - openUserFolderSelector(null, "user"); + openUserFolderSelector(null, "user"); - preventDefault(event); + preventDefault(event); } function removeUserCallback(http) { - var node = http.callbackData; + var node = http.callbackData; if (http.readyState == 4 && http.status == 204) - node.parentNode.removeChild(node); + node.parentNode.removeChild(node); else - log("error deleting user: " + node.getAttribute("id")); + log("error deleting user: " + node.getAttribute("id")); } function onUserRemove(event) { - var userList = $("userList"); - var nodes = userList.getSelectedRows(); + var userList = $("userList"); + var nodes = userList.getSelectedRows(); - var url = window.location.href; - var elements = url.split("/"); - elements[elements.length-1] = "removeUserFromAcls?uid="; - var baseURL = elements.join("/"); + var url = window.location.href; + var elements = url.split("/"); + elements[elements.length-1] = "removeUserFromAcls?uid="; + var baseURL = elements.join("/"); - for (var i = 0; i < nodes.length; i++) { - var userId = nodes[i].getAttribute("id"); - triggerAjaxRequest(baseURL + userId, removeUserCallback, nodes[i]); - } - preventDefault(event); + for (var i = 0; i < nodes.length; i++) { + var userId = nodes[i].getAttribute("id"); + triggerAjaxRequest(baseURL + userId, removeUserCallback, nodes[i]); + } + preventDefault(event); } function subscribeToFolder(refreshCallback, refreshCallbackData) { - var result = true; - if (UserLogin != refreshCallbackData["folder"]) { - result = addUser(refreshCallbackData["folderName"], - refreshCallbackData["folder"]); - } - else - refreshCallbackData["window"].alert(clabels["You cannot subscribe to a folder that you own!"]); - return result; + var result = true; + if (UserLogin != refreshCallbackData["folder"]) { + result = addUser(refreshCallbackData["folderName"], + refreshCallbackData["folder"]); + } + else + refreshCallbackData["window"].alert(clabels["You cannot subscribe to a folder that you own!"]); + return result; } function openRightsForUserID(userID) { - var url = window.location.href; - var elements = url.split("/"); - elements[elements.length-1] = "userRights?uid=" + userID; + var url = window.location.href; + var elements = url.split("/"); + elements[elements.length-1] = "userRights?uid=" + userID; - window.open(elements.join("/"), "", - "width=" + AclEditor.userRightsWidth - + ",height=" + AclEditor.userRightsHeight - + ",resizable=0,scrollbars=0,toolbar=0," - + "location=0,directories=0,status=0,menubar=0,copyhistory=0"); + window.open(elements.join("/"), "", + "width=" + AclEditor.userRightsWidth + + ",height=" + AclEditor.userRightsHeight + + ",resizable=0,scrollbars=0,toolbar=0," + + "location=0,directories=0,status=0,menubar=0,copyhistory=0"); } function openRightsForUser(button) { var nodes = $("userList").getSelectedRows(); if (nodes.length > 0) - openRightsForUserID(nodes[0].getAttribute("id")); + openRightsForUserID(nodes[0].getAttribute("id")); return false; } function openRightsForDefaultUser(event) { - openRightsForUserID(defaultUserID); - preventDefault(event); + openRightsForUserID(defaultUserID); + preventDefault(event); } function onOpenUserRights(event) { - openRightsForUser(); - preventDefault(event); + openRightsForUser(); + preventDefault(event); } function onAclLoadHandler() { - defaultUserID = $("defaultUserID").value; - var defaultRolesBtn = $("defaultRolesBtn"); - if (defaultRolesBtn) - defaultRolesBtn.observe("click", openRightsForDefaultUser); - var ul = $("userList"); - var lis = ul.childNodesWithTag("li"); - for (var i = 0; i < lis.length; i++) - setEventsOnUserNode(lis[i]); + defaultUserID = $("defaultUserID").value; + var defaultRolesBtn = $("defaultRolesBtn"); + if (defaultRolesBtn) + defaultRolesBtn.observe("click", openRightsForDefaultUser); + var ul = $("userList"); + var lis = ul.childNodesWithTag("li"); + for (var i = 0; i < lis.length; i++) + setEventsOnUserNode(lis[i]); - var buttonArea = $("userSelectorButtons"); - if (buttonArea) { - var buttons = buttonArea.childNodesWithTag("a"); - buttons[0].observe("click", onUserAdd); - buttons[1].observe("click", onUserRemove); - } + var buttonArea = $("userSelectorButtons"); + if (buttonArea) { + var buttons = buttonArea.childNodesWithTag("a"); + buttons[0].observe("click", onUserAdd); + buttons[1].observe("click", onUserRemove); + } - AclEditor['userRightsHeight'] = window.opener.getUsersRightsWindowHeight(); - AclEditor['userRightsWidth'] = window.opener.getUsersRightsWindowWidth(); + AclEditor['userRightsHeight'] = window.opener.getUsersRightsWindowHeight(); + AclEditor['userRightsWidth'] = window.opener.getUsersRightsWindowWidth(); } FastInit.addOnLoad(onAclLoadHandler); diff --git a/UI/WebServerResources/UIxAppointmentEditor.js b/UI/WebServerResources/UIxAppointmentEditor.js index fbae48828..1b3475caf 100644 --- a/UI/WebServerResources/UIxAppointmentEditor.js +++ b/UI/WebServerResources/UIxAppointmentEditor.js @@ -1,3 +1,5 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + /* Copyright (C) 2005 SKYRIX Software AG @@ -88,8 +90,8 @@ function validateAptEditor() { start = parseInt(document.forms[0]['startTime_time_minute'].value); end = parseInt(document.forms[0]['endTime_time_minute'].value); if (start > end) { - alert(labels.validate_endbeforestart); - return false; + alert(labels.validate_endbeforestart); + return false; } } } @@ -168,7 +170,7 @@ function onComposeToUndecidedAttendees() attendees.each(function(item) { var address = item.firstChild.nodeValue.trim() + " <" + item.readAttribute("email") + ">"; addresses.push(address); - }); + }); if (window.opener) window.opener.openMailTo(addresses.join(",")); } @@ -390,11 +392,11 @@ function onMailTo(event) { function getMenus() { AppointmentEditor.attendeesMenu = new Array(onPopupAttendeesWindow, - "-", - onComposeToAllAttendees, - onComposeToUndecidedAttendees, - "-", - null); + "-", + onComposeToAllAttendees, + onComposeToUndecidedAttendees, + "-", + null); var attendeesMenu = $('attendeesMenu'); attendeesMenu.prepareVisibility = onAttendeesMenuPrepareVisibility; @@ -403,17 +405,17 @@ function getMenus() { } function onAppointmentEditorLoad() { - assignCalendar('startTime_date'); - assignCalendar('endTime_date'); + assignCalendar('startTime_date'); + assignCalendar('endTime_date'); - var widgets = {'start': {'date': $("startTime_date"), - 'hour': $("startTime_time_hour"), - 'minute': $("startTime_time_minute")}, - 'end': {'date': $("endTime_date"), - 'hour': $("endTime_time_hour"), - 'minute': $("endTime_time_minute")}}; - initTimeWidgets(widgets); - initializeAttendeesHref(); + var widgets = {'start': {'date': $("startTime_date"), + 'hour': $("startTime_time_hour"), + 'minute': $("startTime_time_minute")}, + 'end': {'date': $("endTime_date"), + 'hour': $("endTime_time_hour"), + 'minute': $("endTime_time_minute")}}; + initTimeWidgets(widgets); + initializeAttendeesHref(); } FastInit.addOnLoad(onAppointmentEditorLoad); diff --git a/UI/WebServerResources/UIxAttendeesEditor.js b/UI/WebServerResources/UIxAttendeesEditor.js index 97367bf11..f30fdd288 100644 --- a/UI/WebServerResources/UIxAttendeesEditor.js +++ b/UI/WebServerResources/UIxAttendeesEditor.js @@ -1,3 +1,5 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + var resultsDiv; var address; var awaitingFreeBusyRequests = new Array(); @@ -37,22 +39,22 @@ function onContactKeydown(event) { } } else if (event.keyCode == 0 - || event.keyCode == 8 // Backspace - || event.keyCode == 32 // Space - || event.keyCode > 47) { - this.setAttribute("modified", "1"); - this.confirmedValue = null; - this.uid = null; - this.hasfreebusy = false; - attendeesEditor.currentField = this; - if (this.value.length > 0 && !attendeesEditor.delayedSearch) { - attendeesEditor.delayedSearch = true; - setTimeout("performSearch()", attendeesEditor.delay); - } - else if (this.value.length == 0) { - if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); - } + || event.keyCode == 8 // Backspace + || event.keyCode == 32 // Space + || event.keyCode > 47) { + this.setAttribute("modified", "1"); + this.confirmedValue = null; + this.uid = null; + this.hasfreebusy = false; + attendeesEditor.currentField = this; + if (this.value.length > 0 && !attendeesEditor.delayedSearch) { + attendeesEditor.delayedSearch = true; + setTimeout("performSearch()", attendeesEditor.delay); + } + else if (this.value.length == 0) { + if (document.currentPopupMenu) + hideMenu(document.currentPopupMenu); + } } else if (event.keyCode == 13) { preventDefault(event); @@ -69,22 +71,22 @@ function onContactKeydown(event) { attendeesEditor.currentField = this; if (event.keyCode == 38) { // Up arrow if (attendeesEditor.selectedIndex > 0) { - var attendees = $('attendeesMenu').select("li"); - attendees[attendeesEditor.selectedIndex--].removeClassName("selected"); - attendees[attendeesEditor.selectedIndex].addClassName("selected"); - this.value = this.confirmedValue = attendees[attendeesEditor.selectedIndex].firstChild.nodeValue.trim(); - this.uid = attendees[attendeesEditor.selectedIndex].uid; + var attendees = $('attendeesMenu').select("li"); + attendees[attendeesEditor.selectedIndex--].removeClassName("selected"); + attendees[attendeesEditor.selectedIndex].addClassName("selected"); + this.value = this.confirmedValue = attendees[attendeesEditor.selectedIndex].firstChild.nodeValue.trim(); + this.uid = attendees[attendeesEditor.selectedIndex].uid; } } else if (event.keyCode == 40) { // Down arrow var attendees = $('attendeesMenu').select("li"); if (attendees.size() - 1 > attendeesEditor.selectedIndex) { - if (attendeesEditor.selectedIndex >= 0) - attendees[attendeesEditor.selectedIndex].removeClassName("selected"); - attendeesEditor.selectedIndex++; - attendees[attendeesEditor.selectedIndex].addClassName("selected"); - this.value = this.confirmedValue = attendees[attendeesEditor.selectedIndex].firstChild.nodeValue.trim(); - this.uid = attendees[attendeesEditor.selectedIndex].uid; + if (attendeesEditor.selectedIndex >= 0) + attendees[attendeesEditor.selectedIndex].removeClassName("selected"); + attendeesEditor.selectedIndex++; + attendees[attendeesEditor.selectedIndex].addClassName("selected"); + this.value = this.confirmedValue = attendees[attendeesEditor.selectedIndex].firstChild.nodeValue.trim(); + this.uid = attendees[attendeesEditor.selectedIndex].uid; } } } @@ -100,9 +102,9 @@ function performSearch() { } if (attendeesEditor.currentField.value.trim().length > 0) { var urlstr = ( UserFolderURL + "Contacts/contactSearch?search=" - + escape(attendeesEditor.currentField.value) ); + + escape(attendeesEditor.currentField.value) ); document.contactLookupAjaxRequest = - triggerAjaxRequest(urlstr, performSearchCallback, attendeesEditor.currentField); + triggerAjaxRequest(urlstr, performSearchCallback, attendeesEditor.currentField); } } attendeesEditor.delayedSearch = false; @@ -120,69 +122,69 @@ function performSearchCallback(http) { var data = http.responseText.evalJSON(true); if (data.length > 1) { - $(list.childNodesWithTag("li")).each(function(item) { - item.remove(); - }); + $(list.childNodesWithTag("li")).each(function(item) { + item.remove(); + }); - // Populate popup menu - for (var i = 0; i < data.length; i++) { - var contact = data[i]; - var completeEmail = contact["name"] + " <" + contact["email"] + ">"; - var node = document.createElement("li"); - list.appendChild(node); - node.uid = contact["uid"]; - node.appendChild(document.createTextNode(completeEmail)); - $(node).observe("mousedown", onAttendeeResultClick); - } + // Populate popup menu + for (var i = 0; i < data.length; i++) { + var contact = data[i]; + var completeEmail = contact["name"] + " <" + contact["email"] + ">"; + var node = document.createElement("li"); + list.appendChild(node); + node.uid = contact["uid"]; + node.appendChild(document.createTextNode(completeEmail)); + $(node).observe("mousedown", onAttendeeResultClick); + } - // Show popup menu - var offsetScroll = Element.cumulativeScrollOffset(attendeesEditor.currentField); - var offset = Element.cumulativeOffset(attendeesEditor.currentField); - var top = offset[1] - offsetScroll[1] + node.offsetHeight + 3; - var height = 'auto'; - var heightDiff = window.height() - offset[1]; - var nodeHeight = node.getHeight(); + // Show popup menu + var offsetScroll = Element.cumulativeScrollOffset(attendeesEditor.currentField); + var offset = Element.cumulativeOffset(attendeesEditor.currentField); + var top = offset[1] - offsetScroll[1] + node.offsetHeight + 3; + var height = 'auto'; + var heightDiff = window.height() - offset[1]; + var nodeHeight = node.getHeight(); - if ((data.length * nodeHeight) > heightDiff) - // Limit the size of the popup to the window height, minus 12 pixels - height = parseInt(heightDiff/nodeHeight) * nodeHeight - 12 + 'px'; + if ((data.length * nodeHeight) > heightDiff) + // Limit the size of the popup to the window height, minus 12 pixels + height = parseInt(heightDiff/nodeHeight) * nodeHeight - 12 + 'px'; - menu.setStyle({ top: top + "px", - left: offset[0] + "px", - height: height, - visibility: "visible" }); - menu.scrollTop = 0; + menu.setStyle({ top: top + "px", + left: offset[0] + "px", + height: height, + visibility: "visible" }); + menu.scrollTop = 0; - document.currentPopupMenu = menu; - $(document.body).observe("click", onBodyClickMenuHandler); + document.currentPopupMenu = menu; + $(document.body).observe("click", onBodyClickMenuHandler); } else { - if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); + if (document.currentPopupMenu) + hideMenu(document.currentPopupMenu); - if (data.length == 1) { - // Single result - var contact = data[0]; - if (contact["uid"].length > 0) - input.uid = contact["uid"]; - var completeEmail = contact["name"] + " <" + contact["email"] + ">"; - if (contact["name"].substring(0, input.value.length).toUpperCase() - == input.value.toUpperCase()) - input.value = completeEmail; - else - // The result matches email address, not user name - input.value += ' >> ' + completeEmail; - input.confirmedValue = completeEmail; - var end = input.value.length; - $(input).selectText(start, end); + if (data.length == 1) { + // Single result + var contact = data[0]; + if (contact["uid"].length > 0) + input.uid = contact["uid"]; + var completeEmail = contact["name"] + " <" + contact["email"] + ">"; + if (contact["name"].substring(0, input.value.length).toUpperCase() + == input.value.toUpperCase()) + input.value = completeEmail; + else + // The result matches email address, not user name + input.value += ' >> ' + completeEmail; + input.confirmedValue = completeEmail; + var end = input.value.length; + $(input).selectText(start, end); - attendeesEditor.selectedIndex = -1; - } + attendeesEditor.selectedIndex = -1; + } } } else if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); + hideMenu(document.currentPopupMenu); document.contactLookupAjaxRequest = null; } } @@ -271,34 +273,34 @@ function redisplayFreeBusyZone() { } function newAttendee(event) { - var table = $("freeBusyAttendees"); - var tbody = table.tBodies[0]; - var model = tbody.rows[tbody.rows.length - 1]; - var futureRow = tbody.rows[tbody.rows.length - 2]; - var newRow = model.cloneNode(true); - tbody.insertBefore(newRow, futureRow); + var table = $("freeBusyAttendees"); + var tbody = table.tBodies[0]; + var model = tbody.rows[tbody.rows.length - 1]; + var futureRow = tbody.rows[tbody.rows.length - 2]; + var newRow = model.cloneNode(true); + tbody.insertBefore(newRow, futureRow); - $(newRow).removeClassName("attendeeModel"); + $(newRow).removeClassName("attendeeModel"); - var input = $(newRow).down("input"); - input.observe("keydown", onContactKeydown); - input.observe("blur", checkAttendee); + var input = $(newRow).down("input"); + input.observe("keydown", onContactKeydown); + input.observe("blur", checkAttendee); - input.focussed = true; - input.activate(); + input.focussed = true; + input.activate(); - table = $("freeBusyData"); - tbody = table.tBodies[0]; - model = tbody.rows[tbody.rows.length - 1]; - futureRow = tbody.rows[tbody.rows.length - 2]; - newRow = model.cloneNode(true); - tbody.insertBefore(newRow, futureRow); - $(newRow).removeClassName("dataModel"); + table = $("freeBusyData"); + tbody = table.tBodies[0]; + model = tbody.rows[tbody.rows.length - 1]; + futureRow = tbody.rows[tbody.rows.length - 2]; + newRow = model.cloneNode(true); + tbody.insertBefore(newRow, futureRow); + $(newRow).removeClassName("dataModel"); - var attendeesDiv = $$('TABLE#freeBusy TD.freeBusyAttendees DIV').first(); - var dataDiv = $$('TABLE#freeBusy TD.freeBusyData DIV').first(); + var attendeesDiv = $$('TABLE#freeBusy TD.freeBusyAttendees DIV').first(); + var dataDiv = $$('TABLE#freeBusy TD.freeBusyData DIV').first(); - dataDiv.scrollTop = attendeesDiv.scrollTop; + dataDiv.scrollTop = attendeesDiv.scrollTop; } function checkAttendee() { @@ -330,7 +332,7 @@ function checkAttendee() { } if (!this.hasfreebusy) { if (this.uid && this.confirmedValue) - this.value = this.confirmedValue; + this.value = this.confirmedValue; displayFreeBusyForNode(this); this.hasfreebusy = true; } @@ -348,27 +350,27 @@ function displayFreeBusyForNode(input) { awaitingFreeBusyRequests.push(input); else { for (var i = 0; i < nodes.length; i++) { - $(nodes[i]).removeClassName("noFreeBusy"); - $(nodes[i]).innerHTML = ('' - + '' - + '' - + ''); + $(nodes[i]).removeClassName("noFreeBusy"); + $(nodes[i]).innerHTML = ('' + + '' + + '' + + ''); } if (document.contactFreeBusyAjaxRequest) { - // Abort any pending request - document.contactFreeBusyAjaxRequest.aborted = true; - document.contactFreeBusyAjaxRequest.abort(); + // Abort any pending request + document.contactFreeBusyAjaxRequest.aborted = true; + document.contactFreeBusyAjaxRequest.abort(); } var sd = $('startTime_date').valueAsShortDateString(); var ed = $('endTime_date').valueAsShortDateString(); var urlstr = ( UserFolderURL + "../" + input.uid - + "/freebusy.ifb/ajaxRead?" - + "sday=" + sd + "&eday=" + ed + "&additional=" + - additionalDays ); + + "/freebusy.ifb/ajaxRead?" + + "sday=" + sd + "&eday=" + ed + "&additional=" + + additionalDays ); document.contactFreeBusyAjaxRequest - = triggerAjaxRequest(urlstr, - updateFreeBusyDataCallback, - input); + = triggerAjaxRequest(urlstr, + updateFreeBusyDataCallback, + input); } } else { for (var i = 0; i < nodes.length; i++) { @@ -406,7 +408,7 @@ function updateFreeBusyDataCallback(http) { var nodes = $("freeBusyData").tBodies[0].rows[rowIndex].cells; for (var i = 0; i < slots.length; i++) { if (slots[i] != '0') - setSlot(nodes, i, slots[i]); + setSlot(nodes, i, slots[i]); } } document.contactFreeBusyAjaxRequest = null; @@ -427,254 +429,254 @@ function resetAllFreeBusys() { } function initializeWindowButtons() { - var okButton = $("okButton"); - var cancelButton = $("cancelButton"); + var okButton = $("okButton"); + var cancelButton = $("cancelButton"); - okButton.observe("click", onEditorOkClick, false); - cancelButton.observe("click", onEditorCancelClick, false); + okButton.observe("click", onEditorOkClick, false); + cancelButton.observe("click", onEditorCancelClick, false); - var buttons = $("freeBusyViewButtons").childNodesWithTag("a"); - for (var i = 0; i < buttons.length; i++) - buttons[i].observe("click", listRowMouseDownHandler, false); - buttons = $("freeBusyZoomButtons").childNodesWithTag("a"); - for (var i = 0; i < buttons.length; i++) - buttons[i].observe("click", listRowMouseDownHandler, false); - buttons = $("freeBusyButtons").childNodesWithTag("a"); - for (var i = 0; i < buttons.length; i++) - buttons[i].observe("click", listRowMouseDownHandler, false); + var buttons = $("freeBusyViewButtons").childNodesWithTag("a"); + for (var i = 0; i < buttons.length; i++) + buttons[i].observe("click", listRowMouseDownHandler, false); + buttons = $("freeBusyZoomButtons").childNodesWithTag("a"); + for (var i = 0; i < buttons.length; i++) + buttons[i].observe("click", listRowMouseDownHandler, false); + buttons = $("freeBusyButtons").childNodesWithTag("a"); + for (var i = 0; i < buttons.length; i++) + buttons[i].observe("click", listRowMouseDownHandler, false); } function onEditorOkClick(event) { - preventDefault(event); + preventDefault(event); - attendeesEditor.names = new Array(); - attendeesEditor.UIDs = new Array(); - attendeesEditor.emails = new Array(); - attendeesEditor.states = new Array(); + attendeesEditor.names = new Array(); + attendeesEditor.UIDs = new Array(); + attendeesEditor.emails = new Array(); + attendeesEditor.states = new Array(); - var table = $("freeBusy"); - var inputs = table.getElementsByTagName("input"); - for (var i = 0; i < inputs.length - 2; i++) { - var row = $(inputs[i]).up("tr"); - var name = extractEmailName(inputs[i].value); - var email = extractEmailAddress(inputs[i].value); - var uid = ""; - if (inputs[i].uid) - uid = inputs[i].uid; - if (!(name && name.length > 0)) - if (inputs[i].uid) - name = inputs[i].uid; - else - name = email; - var state = "needs-action"; - if (row.hasClassName("accepted")) - state = "accepted"; - else if (row.hasClassName("declined")) - state = "declined"; - var pos = attendeesEditor.emails.indexOf(email); - if (pos == -1) - pos = attendeesEditor.emails.length; - attendeesEditor.names[pos] = name; - attendeesEditor.UIDs[pos] = uid; - attendeesEditor.emails[pos] = email; - attendeesEditor.states[pos] = state; - } - parent$("attendeesNames").value = attendeesEditor.names.join(","); - parent$("attendeesUIDs").value = attendeesEditor.UIDs.join(","); - parent$("attendeesEmails").value = attendeesEditor.emails.join(","); - parent$("attendeesStates").value = attendeesEditor.states.join(","); - window.opener.refreshAttendees(); + var table = $("freeBusy"); + var inputs = table.getElementsByTagName("input"); + for (var i = 0; i < inputs.length - 2; i++) { + var row = $(inputs[i]).up("tr"); + var name = extractEmailName(inputs[i].value); + var email = extractEmailAddress(inputs[i].value); + var uid = ""; + if (inputs[i].uid) + uid = inputs[i].uid; + if (!(name && name.length > 0)) + if (inputs[i].uid) + name = inputs[i].uid; + else + name = email; + var state = "needs-action"; + if (row.hasClassName("accepted")) + state = "accepted"; + else if (row.hasClassName("declined")) + state = "declined"; + var pos = attendeesEditor.emails.indexOf(email); + if (pos == -1) + pos = attendeesEditor.emails.length; + attendeesEditor.names[pos] = name; + attendeesEditor.UIDs[pos] = uid; + attendeesEditor.emails[pos] = email; + attendeesEditor.states[pos] = state; + } + parent$("attendeesNames").value = attendeesEditor.names.join(","); + parent$("attendeesUIDs").value = attendeesEditor.UIDs.join(","); + parent$("attendeesEmails").value = attendeesEditor.emails.join(","); + parent$("attendeesStates").value = attendeesEditor.states.join(","); + window.opener.refreshAttendees(); - updateParentDateFields("startTime", "startTime"); - updateParentDateFields("endTime", "endTime"); + updateParentDateFields("startTime", "startTime"); + updateParentDateFields("endTime", "endTime"); - window.close(); + window.close(); } function onEditorCancelClick(event) { - preventDefault(event); - window.close(); + preventDefault(event); + window.close(); } function synchronizeWithParent(srcWidgetName, dstWidgetName) { - var srcDate = parent$(srcWidgetName + "_date"); - var dstDate = $(dstWidgetName + "_date"); - dstDate.value = srcDate.value; - dstDate.updateShadowValue(srcDate); + var srcDate = parent$(srcWidgetName + "_date"); + var dstDate = $(dstWidgetName + "_date"); + dstDate.value = srcDate.value; + dstDate.updateShadowValue(srcDate); - var srcHour = parent$(srcWidgetName + "_time_hour"); - var dstHour = $(dstWidgetName + "_time_hour"); - dstHour.value = srcHour.value; - dstHour.updateShadowValue(srcHour); + var srcHour = parent$(srcWidgetName + "_time_hour"); + var dstHour = $(dstWidgetName + "_time_hour"); + dstHour.value = srcHour.value; + dstHour.updateShadowValue(srcHour); - var srcMinute = parent$(srcWidgetName + "_time_minute"); - var dstMinute = $(dstWidgetName + "_time_minute"); - dstMinute.value = srcMinute.value; - dstMinute.updateShadowValue(dstMinute); + var srcMinute = parent$(srcWidgetName + "_time_minute"); + var dstMinute = $(dstWidgetName + "_time_minute"); + dstMinute.value = srcMinute.value; + dstMinute.updateShadowValue(dstMinute); } function updateParentDateFields(srcWidgetName, dstWidgetName) { - var srcDate = $(srcWidgetName + "_date"); - var dstDate = parent$(dstWidgetName + "_date"); - dstDate.value = srcDate.value; + var srcDate = $(srcWidgetName + "_date"); + var dstDate = parent$(dstWidgetName + "_date"); + dstDate.value = srcDate.value; - var srcHour = $(srcWidgetName + "_time_hour"); - var dstHour = parent$(dstWidgetName + "_time_hour"); - dstHour.value = srcHour.value; + var srcHour = $(srcWidgetName + "_time_hour"); + var dstHour = parent$(dstWidgetName + "_time_hour"); + dstHour.value = srcHour.value; - var srcMinute = $(srcWidgetName + "_time_minute"); - var dstMinute = parent$(dstWidgetName + "_time_minute"); - dstMinute.value = srcMinute.value; + var srcMinute = $(srcWidgetName + "_time_minute"); + var dstMinute = parent$(dstWidgetName + "_time_minute"); + dstMinute.value = srcMinute.value; } function onTimeWidgetChange() { - redisplayFreeBusyZone(); + redisplayFreeBusyZone(); } function onTimeDateWidgetChange() { - var table = $("freeBusyHeader"); - var rows = table.select("tr"); - for (var i = 0; i < rows.length; i++) { - for (var j = rows[i].cells.length - 1; j > -1; j--) { - rows[i].deleteCell(j); - } - } + var table = $("freeBusyHeader"); + var rows = table.select("tr"); + for (var i = 0; i < rows.length; i++) { + for (var j = rows[i].cells.length - 1; j > -1; j--) { + rows[i].deleteCell(j); + } + } - table = $("freeBusyData"); - rows = table.select("tr"); - for (var i = 0; i < rows.length; i++) { - for (var j = rows[i].cells.length - 1; j > -1; j--) { - rows[i].deleteCell(j); - } - } + table = $("freeBusyData"); + rows = table.select("tr"); + for (var i = 0; i < rows.length; i++) { + for (var j = rows[i].cells.length - 1; j > -1; j--) { + rows[i].deleteCell(j); + } + } - prepareTableHeaders(); - prepareTableRows(); - redisplayFreeBusyZone(); - resetAllFreeBusys(); + prepareTableHeaders(); + prepareTableRows(); + redisplayFreeBusyZone(); + resetAllFreeBusys(); } function prepareTableHeaders() { - var startTimeDate = $("startTime_date"); - var startDate = startTimeDate.valueAsDate(); + var startTimeDate = $("startTime_date"); + var startDate = startTimeDate.valueAsDate(); - var endTimeDate = $("endTime_date"); - var endDate = endTimeDate.valueAsDate(); - endDate.setTime(endDate.getTime() + (additionalDays * 86400000)); + var endTimeDate = $("endTime_date"); + var endDate = endTimeDate.valueAsDate(); + endDate.setTime(endDate.getTime() + (additionalDays * 86400000)); - var rows = $("freeBusyHeader").rows; - var days = startDate.daysUpTo(endDate); - for (var i = 0; i < days.length; i++) { - var header1 = document.createElement("th"); - header1.colSpan = (dayEndHour - dayStartHour) + 1; - header1.appendChild(document.createTextNode(days[i].toLocaleDateString())); - rows[0].appendChild(header1); - for (var hour = dayStartHour; hour < (dayEndHour + 1); hour++) { - var header2 = document.createElement("th"); - var text = hour + ":00"; - if (hour < 10) - text = "0" + text; - header2.appendChild(document.createTextNode(text)); - rows[1].appendChild(header2); + var rows = $("freeBusyHeader").rows; + var days = startDate.daysUpTo(endDate); + for (var i = 0; i < days.length; i++) { + var header1 = document.createElement("th"); + header1.colSpan = (dayEndHour - dayStartHour) + 1; + header1.appendChild(document.createTextNode(days[i].toLocaleDateString())); + rows[0].appendChild(header1); + for (var hour = dayStartHour; hour < (dayEndHour + 1); hour++) { + var header2 = document.createElement("th"); + var text = hour + ":00"; + if (hour < 10) + text = "0" + text; + header2.appendChild(document.createTextNode(text)); + rows[1].appendChild(header2); - var header3 = document.createElement("th"); - for (var span = 0; span < 4; span++) { - var spanElement = document.createElement("span"); - $(spanElement).addClassName("freeBusyZoneElement"); - header3.appendChild(spanElement); - } - rows[2].appendChild(header3); - } - } + var header3 = document.createElement("th"); + for (var span = 0; span < 4; span++) { + var spanElement = document.createElement("span"); + $(spanElement).addClassName("freeBusyZoneElement"); + header3.appendChild(spanElement); + } + rows[2].appendChild(header3); + } + } } function prepareTableRows() { - var startTimeDate = $("startTime_date"); - var startDate = startTimeDate.valueAsDate(); + var startTimeDate = $("startTime_date"); + var startDate = startTimeDate.valueAsDate(); - var endTimeDate = $("endTime_date"); - var endDate = endTimeDate.valueAsDate(); - endDate.setTime(endDate.getTime() + (additionalDays * 86400000)); + var endTimeDate = $("endTime_date"); + var endDate = endTimeDate.valueAsDate(); + endDate.setTime(endDate.getTime() + (additionalDays * 86400000)); - var rows = $("freeBusyData").tBodies[0].rows; - var days = startDate.daysUpTo(endDate); - var width = $('freeBusyHeader').getWidth(); - $("freeBusyData").setStyle({ width: width + 'px' }); - for (var i = 0; i < days.length; i++) - for (var rowNbr = 0; rowNbr < rows.length; rowNbr++) - for (var hour = dayStartHour; hour < (dayEndHour + 1); hour++) - rows[rowNbr].appendChild(document.createElement("td")); + var rows = $("freeBusyData").tBodies[0].rows; + var days = startDate.daysUpTo(endDate); + var width = $('freeBusyHeader').getWidth(); + $("freeBusyData").setStyle({ width: width + 'px' }); + for (var i = 0; i < days.length; i++) + for (var rowNbr = 0; rowNbr < rows.length; rowNbr++) + for (var hour = dayStartHour; hour < (dayEndHour + 1); hour++) + rows[rowNbr].appendChild(document.createElement("td")); } function prepareAttendees() { - var value = parent$("attendeesNames").value; - var tableAttendees = $("freeBusyAttendees"); - var tableData = $("freeBusyData"); - if (value.length > 0) { - attendeesEditor.names = parent$("attendeesNames").value.split(","); - attendeesEditor.UIDs = parent$("attendeesUIDs").value.split(","); - attendeesEditor.emails = parent$("attendeesEmails").value.split(","); - attendeesEditor.states = parent$("attendeesStates").value.split(","); + var value = parent$("attendeesNames").value; + var tableAttendees = $("freeBusyAttendees"); + var tableData = $("freeBusyData"); + if (value.length > 0) { + attendeesEditor.names = parent$("attendeesNames").value.split(","); + attendeesEditor.UIDs = parent$("attendeesUIDs").value.split(","); + attendeesEditor.emails = parent$("attendeesEmails").value.split(","); + attendeesEditor.states = parent$("attendeesStates").value.split(","); - var tbodyAttendees = tableAttendees.tBodies[0]; - var modelAttendee = tbodyAttendees.rows[tbodyAttendees.rows.length - 1]; - var newAttendeeRow = tbodyAttendees.rows[tbodyAttendees.rows.length - 2]; + var tbodyAttendees = tableAttendees.tBodies[0]; + var modelAttendee = tbodyAttendees.rows[tbodyAttendees.rows.length - 1]; + var newAttendeeRow = tbodyAttendees.rows[tbodyAttendees.rows.length - 2]; - var tbodyData = tableData.tBodies[0]; - var modelData = tbodyData.rows[tbodyData.rows.length - 1]; - var newDataRow = tbodyData.rows[tbodyData.rows.length - 2]; + var tbodyData = tableData.tBodies[0]; + var modelData = tbodyData.rows[tbodyData.rows.length - 1]; + var newDataRow = tbodyData.rows[tbodyData.rows.length - 2]; - for (var i = 0; i < attendeesEditor.names.length; i++) { - var row = modelAttendee.cloneNode(true); - tbodyAttendees.insertBefore(row, newAttendeeRow); - $(row).removeClassName("attendeeModel"); - $(row).addClassName(attendeesEditor.states[i]); - var input = $(row).down("input"); - var value = ""; - if (attendeesEditor.names[i].length > 0 - && attendeesEditor.names[i] != attendeesEditor.emails[i]) - value += attendeesEditor.names[i] + " "; - value += "<" + attendeesEditor.emails[i] + ">"; - input.value = value; - if (attendeesEditor.UIDs[i].length > 0) - input.uid = attendeesEditor.UIDs[i]; - input.setAttribute("name", ""); - input.setAttribute("modified", "0"); - input.observe("blur", checkAttendee); - input.observe("keydown", onContactKeydown); + for (var i = 0; i < attendeesEditor.names.length; i++) { + var row = modelAttendee.cloneNode(true); + tbodyAttendees.insertBefore(row, newAttendeeRow); + $(row).removeClassName("attendeeModel"); + $(row).addClassName(attendeesEditor.states[i]); + var input = $(row).down("input"); + var value = ""; + if (attendeesEditor.names[i].length > 0 + && attendeesEditor.names[i] != attendeesEditor.emails[i]) + value += attendeesEditor.names[i] + " "; + value += "<" + attendeesEditor.emails[i] + ">"; + input.value = value; + if (attendeesEditor.UIDs[i].length > 0) + input.uid = attendeesEditor.UIDs[i]; + input.setAttribute("name", ""); + input.setAttribute("modified", "0"); + input.observe("blur", checkAttendee); + input.observe("keydown", onContactKeydown); - row = modelData.cloneNode(true); - tbodyData.insertBefore(row, newDataRow); - $(row).removeClassName("dataModel"); + row = modelData.cloneNode(true); + tbodyData.insertBefore(row, newDataRow); + $(row).removeClassName("dataModel"); - displayFreeBusyForNode(input); - } - } - else { - attendeesEditor.names = new Array(); - attendeesEditor.UIDs = new Array(); - attendeesEditor.emails = new Array(); - //newAttendee(null); - } + displayFreeBusyForNode(input); + } + } + else { + attendeesEditor.names = new Array(); + attendeesEditor.UIDs = new Array(); + attendeesEditor.emails = new Array(); + //newAttendee(null); + } - var inputs = tableAttendees.select("input"); - inputs[inputs.length - 2].setAttribute("autocomplete", "off"); - inputs[inputs.length - 2].observe("click", newAttendee); + var inputs = tableAttendees.select("input"); + inputs[inputs.length - 2].setAttribute("autocomplete", "off"); + inputs[inputs.length - 2].observe("click", newAttendee); } function onWindowResize(event) { - var view = $('freeBusyView'); - var attendeesCell = $$('TABLE#freeBusy TD.freeBusyAttendees').first(); - var headerDiv = $$('TABLE#freeBusy TD.freeBusyHeader DIV').first(); - var attendeesDiv = $$('TABLE#freeBusy TD.freeBusyAttendees DIV').first(); - var dataDiv = $$('TABLE#freeBusy TD.freeBusyData DIV').first(); - var width = view.getWidth() - attendeesCell.getWidth(); - var height = view.getHeight() - headerDiv.getHeight(); + var view = $('freeBusyView'); + var attendeesCell = $$('TABLE#freeBusy TD.freeBusyAttendees').first(); + var headerDiv = $$('TABLE#freeBusy TD.freeBusyHeader DIV').first(); + var attendeesDiv = $$('TABLE#freeBusy TD.freeBusyAttendees DIV').first(); + var dataDiv = $$('TABLE#freeBusy TD.freeBusyData DIV').first(); + var width = view.getWidth() - attendeesCell.getWidth(); + var height = view.getHeight() - headerDiv.getHeight(); - attendeesDiv.setStyle({ height: (height - 20) + 'px' }); - headerDiv.setStyle({ width: (width - 20) + 'px' }); - dataDiv.setStyle({ width: (width - 4) + 'px', - height: (height - 2) + 'px' }); + attendeesDiv.setStyle({ height: (height - 20) + 'px' }); + headerDiv.setStyle({ width: (width - 20) + 'px' }); + dataDiv.setStyle({ width: (width - 4) + 'px', + height: (height - 2) + 'px' }); } function onScroll(event) { @@ -687,25 +689,25 @@ function onScroll(event) { } function onFreeBusyLoadHandler() { - var widgets = {'start': {'date': $("startTime_date"), - 'hour': $("startTime_time_hour"), - 'minute': $("startTime_time_minute")}, - 'end': {'date': $("endTime_date"), - 'hour': $("endTime_time_hour"), - 'minute': $("endTime_time_minute")}}; + var widgets = {'start': {'date': $("startTime_date"), + 'hour': $("startTime_time_hour"), + 'minute': $("startTime_time_minute")}, + 'end': {'date': $("endTime_date"), + 'hour': $("endTime_time_hour"), + 'minute': $("endTime_time_minute")}}; - synchronizeWithParent("startTime", "startTime"); - synchronizeWithParent("endTime", "endTime"); + synchronizeWithParent("startTime", "startTime"); + synchronizeWithParent("endTime", "endTime"); - initTimeWidgets(widgets); - initializeWindowButtons(); - prepareTableHeaders(); - prepareTableRows(); - redisplayFreeBusyZone(); - prepareAttendees(); - onWindowResize(null); - Event.observe(window, "resize", onWindowResize); - $$('TABLE#freeBusy TD.freeBusyData DIV').first().observe("scroll", onScroll); + initTimeWidgets(widgets); + initializeWindowButtons(); + prepareTableHeaders(); + prepareTableRows(); + redisplayFreeBusyZone(); + prepareAttendees(); + onWindowResize(null); + Event.observe(window, "resize", onWindowResize); + $$('TABLE#freeBusy TD.freeBusyData DIV').first().observe("scroll", onScroll); } FastInit.addOnLoad(onFreeBusyLoadHandler); @@ -713,70 +715,70 @@ FastInit.addOnLoad(onFreeBusyLoadHandler); /* Functions related to UIxTimeDateControl widget */ function initTimeWidgets(widgets) { - this.timeWidgets = widgets; + this.timeWidgets = widgets; - assignCalendar('startTime_date'); - assignCalendar('endTime_date'); + assignCalendar('startTime_date'); + assignCalendar('endTime_date'); - widgets['start']['date'].observe("change", - this.onAdjustTime, false); - widgets['start']['hour'].observe("change", - this.onAdjustTime, false); - widgets['start']['minute'].observe("change", - this.onAdjustTime, false); + widgets['start']['date'].observe("change", + this.onAdjustTime, false); + widgets['start']['hour'].observe("change", + this.onAdjustTime, false); + widgets['start']['minute'].observe("change", + this.onAdjustTime, false); - widgets['end']['date'].observe("change", - this.onAdjustTime, false); - widgets['end']['hour'].observe("change", - this.onAdjustTime, false); - widgets['end']['minute'].observe("change", - this.onAdjustTime, false); + widgets['end']['date'].observe("change", + this.onAdjustTime, false); + widgets['end']['hour'].observe("change", + this.onAdjustTime, false); + widgets['end']['minute'].observe("change", + this.onAdjustTime, false); - var allDayLabel = $("allDay"); - if (allDayLabel) { - var input = $(allDayLabel).childNodesWithTag("input")[0]; - input.observe("change", onAllDayChanged.bindAsEventListener(input)); - if (input.checked) { - for (var type in widgets) { - widgets[type]['hour'].disabled = true; - widgets[type]['minute'].disabled = true; - } - } - } + var allDayLabel = $("allDay"); + if (allDayLabel) { + var input = $(allDayLabel).childNodesWithTag("input")[0]; + input.observe("change", onAllDayChanged.bindAsEventListener(input)); + if (input.checked) { + for (var type in widgets) { + widgets[type]['hour'].disabled = true; + widgets[type]['minute'].disabled = true; + } + } + } } function onAdjustTime(event) { - var endDate = window.getEndDate(); - var startDate = window.getStartDate(); - if ($(this).readAttribute("id").startsWith("start")) { - // Start date was changed - var delta = window.getShadowStartDate().valueOf() - - startDate.valueOf(); - var newEndDate = new Date(endDate.valueOf() - delta); - window.setEndDate(newEndDate); - window.timeWidgets['end']['date'].updateShadowValue(); - window.timeWidgets['end']['hour'].updateShadowValue(); - window.timeWidgets['end']['minute'].updateShadowValue(); - window.timeWidgets['start']['date'].updateShadowValue(); - window.timeWidgets['start']['hour'].updateShadowValue(); - window.timeWidgets['start']['minute'].updateShadowValue(); - } - else { - // End date was changed - var delta = endDate.valueOf() - startDate.valueOf(); - if (delta < 0) { - alert(labels.validate_endbeforestart); - var oldEndDate = window.getShadowEndDate(); - window.setEndDate(oldEndDate); + var endDate = window.getEndDate(); + var startDate = window.getStartDate(); + if ($(this).readAttribute("id").startsWith("start")) { + // Start date was changed + var delta = window.getShadowStartDate().valueOf() - + startDate.valueOf(); + var newEndDate = new Date(endDate.valueOf() - delta); + window.setEndDate(newEndDate); + window.timeWidgets['end']['date'].updateShadowValue(); + window.timeWidgets['end']['hour'].updateShadowValue(); + window.timeWidgets['end']['minute'].updateShadowValue(); + window.timeWidgets['start']['date'].updateShadowValue(); + window.timeWidgets['start']['hour'].updateShadowValue(); + window.timeWidgets['start']['minute'].updateShadowValue(); + } + else { + // End date was changed + var delta = endDate.valueOf() - startDate.valueOf(); + if (delta < 0) { + alert(labels.validate_endbeforestart); + var oldEndDate = window.getShadowEndDate(); + window.setEndDate(oldEndDate); - window.timeWidgets['end']['date'].updateShadowValue(); - window.timeWidgets['end']['hour'].updateShadowValue(); - window.timeWidgets['end']['minute'].updateShadowValue(); - } - } + window.timeWidgets['end']['date'].updateShadowValue(); + window.timeWidgets['end']['hour'].updateShadowValue(); + window.timeWidgets['end']['minute'].updateShadowValue(); + } + } - // Specific function for the attendees editor - onTimeDateWidgetChange(); + // Specific function for the attendees editor + onTimeDateWidgetChange(); } function _getDate(which) { @@ -814,18 +816,18 @@ function getShadowEndDate() { } function _setDate(which, newDate) { - window.timeWidgets[which]['date'].setValueAsDate(newDate); - window.timeWidgets[which]['hour'].value = newDate.getHours(); - var minutes = newDate.getMinutes(); - if (minutes % 15) - minutes += (15 - minutes % 15); - window.timeWidgets[which]['minute'].value = minutes; + window.timeWidgets[which]['date'].setValueAsDate(newDate); + window.timeWidgets[which]['hour'].value = newDate.getHours(); + var minutes = newDate.getMinutes(); + if (minutes % 15) + minutes += (15 - minutes % 15); + window.timeWidgets[which]['minute'].value = minutes; } function setStartDate(newStartDate) { - this._setDate('start', newStartDate); + this._setDate('start', newStartDate); } function setEndDate(newEndDate) { - this._setDate('end', newEndDate); + this._setDate('end', newEndDate); } diff --git a/UI/WebServerResources/UIxCalUserRightsEditor.js b/UI/WebServerResources/UIxCalUserRightsEditor.js index 4fee972d7..93672b759 100644 --- a/UI/WebServerResources/UIxCalUserRightsEditor.js +++ b/UI/WebServerResources/UIxCalUserRightsEditor.js @@ -1,3 +1,5 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + function onCancelClick(event) { window.close(); } diff --git a/UI/WebServerResources/UIxCalendarProperties.js b/UI/WebServerResources/UIxCalendarProperties.js index e3cf7f23b..34dc7affb 100644 --- a/UI/WebServerResources/UIxCalendarProperties.js +++ b/UI/WebServerResources/UIxCalendarProperties.js @@ -1,3 +1,5 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + function onLoadCalendarProperties() { var colorButton = $("colorButton"); var calendarColor = $("calendarColor"); @@ -27,10 +29,10 @@ function onOKClick(event) { function onColorClick(event) { var cPicker = window.open(ApplicationBaseURL + "colorPicker", "colorPicker", - "width=250,height=200,resizable=0,scrollbars=0" - + "toolbar=0,location=0,directories=0,status=0," - + "menubar=0,copyhistory=0", "test" - ); + "width=250,height=200,resizable=0,scrollbars=0" + + "toolbar=0,location=0,directories=0,status=0," + + "menubar=0,copyhistory=0", "test" + ); cPicker.focus(); preventDefault(event); diff --git a/UI/WebServerResources/UIxColorPicker.js b/UI/WebServerResources/UIxColorPicker.js index 892635d7c..476ccf0e3 100644 --- a/UI/WebServerResources/UIxColorPicker.js +++ b/UI/WebServerResources/UIxColorPicker.js @@ -1,3 +1,5 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + function onLoadColorPicker(event) { showColorPicker(); } diff --git a/UI/WebServerResources/UIxComponentEditor.js b/UI/WebServerResources/UIxComponentEditor.js index 89a72760b..ec7b68d49 100644 --- a/UI/WebServerResources/UIxComponentEditor.js +++ b/UI/WebServerResources/UIxComponentEditor.js @@ -1,8 +1,10 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + function onPopupAttendeesWindow(event) { if (event) preventDefault(event); window.open(ApplicationBaseURL + "/editAttendees", null, - "width=803,height=573"); + "width=803,height=573"); return false; } @@ -30,14 +32,14 @@ function onPopupUrlWindow(event) { if (documentHref.childNodes.length > 0) { documentHref.childNodes[0].nodeValue = newUrl; if (newUrl.length > 0) - documentLabel.setStyle({ display: "block" }); + documentLabel.setStyle({ display: "block" }); else - documentLabel.setStyle({ display: "none" }); + documentLabel.setStyle({ display: "none" }); } else { documentHref.appendChild(document.createTextNode(newUrl)); if (newUrl.length > 0) - documentLabel.setStyle({ display: "block" }); + documentLabel.setStyle({ display: "block" }); } urlInput.value = newUrl; } @@ -124,9 +126,9 @@ function onComponentEditorLoad(event) { var menuItems = $("itemPrivacyList").childNodesWithTag("li"); for (var i = 0; i < menuItems.length; i++) - menuItems[i].observe("mousedown", - onMenuSetClassification.bindAsEventListener(menuItems[i]), - false); + menuItems[i].observe("mousedown", + onMenuSetClassification.bindAsEventListener(menuItems[i]), + false); $("repeatHref").observe("click", onPopupRecurrenceWindow); $("repeatList").observe("change", onPopupRecurrenceWindow); @@ -143,7 +145,7 @@ function onPopupRecurrenceWindow(event) { repeatHref.show(); if (event) window.open(ApplicationBaseURL + "editRecurrence", null, - "width=500,height=400"); + "width=500,height=400"); } else repeatHref.hide(); diff --git a/UI/WebServerResources/UIxContactEditor.js b/UI/WebServerResources/UIxContactEditor.js index 97d38c704..65c65ff67 100644 --- a/UI/WebServerResources/UIxContactEditor.js +++ b/UI/WebServerResources/UIxContactEditor.js @@ -1,22 +1,24 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + /* - Copyright (C) 2005 SKYRIX Software AG + Copyright (C) 2005 SKYRIX Software AG - This file is part of OpenGroupware.org. + This file is part of OpenGroupware.org. - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ var uixEmailUsr = @@ -37,21 +39,21 @@ function unescapeCallbackParameter(s) { function copyContact(type, email, uid, sn, cn, givenName, telephoneNumber, facsimileTelephoneNumber, - mobile, postalAddress, homePostalAddress, - departmentNumber, l) + mobile, postalAddress, homePostalAddress, + departmentNumber, l) { - // var type = arguments[0]; - // var email = arguments[1]; - // var uid = arguments[2]; - // var sn = arguments[3]; - // var givenName = arguments[4]; - // var telephoneNumber = arguments[5]; - // var facsimileTelephoneNumber = arguments[6]; - // var mobile = arguments[7]; - // var postalAddress = arguments[8]; - // var homePostalAddress = arguments[9]; - // var departmentNumber = arguments[10]; - // var l = arguments[11]; + // var type = arguments[0]; + // var email = arguments[1]; + // var uid = arguments[2]; + // var sn = arguments[3]; + // var givenName = arguments[4]; + // var telephoneNumber = arguments[5]; + // var facsimileTelephoneNumber = arguments[6]; + // var mobile = arguments[7]; + // var postalAddress = arguments[8]; + // var homePostalAddress = arguments[9]; + // var departmentNumber = arguments[10]; + // var l = arguments[11]; var e; e = $('cn'); e.setAttribute('value', unescapeCallbackParameter(cn)); @@ -128,8 +130,8 @@ function onFnNewValue(event) { } function onEditorCancelClick(event) { - preventDefault(event); - window.close(); + preventDefault(event); + window.close(); } function initEditorForm() { diff --git a/UI/WebServerResources/UIxContactsUserFolders.js b/UI/WebServerResources/UIxContactsUserFolders.js index 3ac54af4e..a5ac78356 100644 --- a/UI/WebServerResources/UIxContactsUserFolders.js +++ b/UI/WebServerResources/UIxContactsUserFolders.js @@ -1,100 +1,102 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + function onSearchFormSubmit() { var searchValue = $("searchValue"); var url = (UserFolderURL - + "foldersSearch?search=" + escape(searchValue.value) - + "&type=" + window.opener.userFolderType); + + "foldersSearch?search=" + escape(searchValue.value) + + "&type=" + window.opener.userFolderType); if (document.userFoldersRequest) { - document.userFoldersRequest.aborted = true; - document.userFoldersRequest.abort(); + document.userFoldersRequest.aborted = true; + document.userFoldersRequest.abort(); } document.userFoldersRequest - = triggerAjaxRequest(url, userFoldersCallback); + = triggerAjaxRequest(url, userFoldersCallback); return false; } function addLineToTree(tree, parent, line) { - var offset = 0; + var offset = 0; - var nodes = line.split(";"); - if (window.opener.userFolderType == "user" - || nodes.length > 1) { - var parentNode = nodes[0]; - var userInfos = parentNode.split(":"); - var email = userInfos[1] + " <" + userInfos[2] + ">"; - tree.add(parent, 0, email, 0, '#', userInfos[0], 'person', - '', '', - ResourcesURL + '/abcard.gif', - ResourcesURL + '/abcard.gif'); - for (var i = 1; i < nodes.length; i++) { - var folderInfos = nodes[i].split(":"); - var icon = ResourcesURL + '/'; - if (folderInfos[2] == 'Contact') - icon += 'tb-mail-addressbook-flat-16x16.png'; - else - icon += 'calendar-folder-16x16.png'; - var folderId = userInfos[0] + ":" + folderInfos[1]; - var name = folderInfos[0]; // name has the format "Folername (Firstname Lastname )" - var pos = name.lastIndexOf(' (') - if (pos != -1) - name = name.substring(0, pos); // strip the part with fullname and email - tree.add(parent + i, parent, name, 0, '#', folderId, - folderInfos[2] + '-folder', '', '', icon, icon); - } - offset = nodes.length - 1; - } -// else -// window.alert("nope:" + window.opener.userFolderType); + var nodes = line.split(";"); + if (window.opener.userFolderType == "user" + || nodes.length > 1) { + var parentNode = nodes[0]; + var userInfos = parentNode.split(":"); + var email = userInfos[1] + " <" + userInfos[2] + ">"; + tree.add(parent, 0, email, 0, '#', userInfos[0], 'person', + '', '', + ResourcesURL + '/abcard.gif', + ResourcesURL + '/abcard.gif'); + for (var i = 1; i < nodes.length; i++) { + var folderInfos = nodes[i].split(":"); + var icon = ResourcesURL + '/'; + if (folderInfos[2] == 'Contact') + icon += 'tb-mail-addressbook-flat-16x16.png'; + else + icon += 'calendar-folder-16x16.png'; + var folderId = userInfos[0] + ":" + folderInfos[1]; + var name = folderInfos[0]; // name has the format "Folername (Firstname Lastname )" + var pos = name.lastIndexOf(' (') + if (pos != -1) + name = name.substring(0, pos); // strip the part with fullname and email + tree.add(parent + i, parent, name, 0, '#', folderId, + folderInfos[2] + '-folder', '', '', icon, icon); + } + offset = nodes.length - 1; + } + // else + // window.alert("nope:" + window.opener.userFolderType); - return offset; + return offset; } function buildTree(response) { - d = new dTree("d"); - d.config.folderLlinks = true; - d.config.hideRoot = true; - d.icon.root = ResourcesURL + '/tbtv_account_17x17.gif'; - d.icon.folder = ResourcesURL + '/tbtv_leaf_corner_17x17.png'; - d.icon.folderOpen = ResourcesURL + '/tbtv_leaf_corner_17x17.png'; - d.icon.node = ResourcesURL + '/tbtv_leaf_corner_17x17.png'; - d.icon.line = ResourcesURL + '/tbtv_line_17x17.gif'; - d.icon.join = ResourcesURL + '/tbtv_junction_17x17.gif'; - d.icon.joinBottom = ResourcesURL + '/tbtv_corner_17x17.gif'; - d.icon.plus = ResourcesURL + '/tbtv_plus_17x17.gif'; - d.icon.plusBottom = ResourcesURL + '/tbtv_corner_plus_17x17.gif'; - d.icon.minus = ResourcesURL + '/tbtv_minus_17x17.gif'; - d.icon.minusBottom = ResourcesURL + '/tbtv_corner_minus_17x17.gif'; - d.icon.nlPlus = ResourcesURL + '/tbtv_corner_plus_17x17.gif'; - d.icon.nlMinus = ResourcesURL + '/tbtv_corner_minus_17x17.gif'; - d.icon.empty = ResourcesURL + '/empty.gif'; - d.add(0, -1, ''); + d = new dTree("d"); + d.config.folderLlinks = true; + d.config.hideRoot = true; + d.icon.root = ResourcesURL + '/tbtv_account_17x17.gif'; + d.icon.folder = ResourcesURL + '/tbtv_leaf_corner_17x17.png'; + d.icon.folderOpen = ResourcesURL + '/tbtv_leaf_corner_17x17.png'; + d.icon.node = ResourcesURL + '/tbtv_leaf_corner_17x17.png'; + d.icon.line = ResourcesURL + '/tbtv_line_17x17.gif'; + d.icon.join = ResourcesURL + '/tbtv_junction_17x17.gif'; + d.icon.joinBottom = ResourcesURL + '/tbtv_corner_17x17.gif'; + d.icon.plus = ResourcesURL + '/tbtv_plus_17x17.gif'; + d.icon.plusBottom = ResourcesURL + '/tbtv_corner_plus_17x17.gif'; + d.icon.minus = ResourcesURL + '/tbtv_minus_17x17.gif'; + d.icon.minusBottom = ResourcesURL + '/tbtv_corner_minus_17x17.gif'; + d.icon.nlPlus = ResourcesURL + '/tbtv_corner_plus_17x17.gif'; + d.icon.nlMinus = ResourcesURL + '/tbtv_corner_minus_17x17.gif'; + d.icon.empty = ResourcesURL + '/empty.gif'; + d.add(0, -1, ''); - var lines = response.split("\n"); - var offset = 0; - for (var i = 0; i < lines.length; i++) { - if (lines[i].length > 0) - offset += addLineToTree(d, i + 1 + offset, lines[i]); - } + var lines = response.split("\n"); + var offset = 0; + for (var i = 0; i < lines.length; i++) { + if (lines[i].length > 0) + offset += addLineToTree(d, i + 1 + offset, lines[i]); + } - return d; + return d; } function onFolderTreeItemClick(event) { - preventDefault(event); + preventDefault(event); - var topNode = $("d"); - if (topNode.selectedEntry) - topNode.selectedEntry.deselect(); - this.selectElement(); - topNode.selectedEntry = this; + var topNode = $("d"); + if (topNode.selectedEntry) + topNode.selectedEntry.deselect(); + this.selectElement(); + topNode.selectedEntry = this; - if (window.opener.userFolderType == "user") - $("addButton").disabled = false; - else { - var dataname = this.parentNode.getAttribute("dataname"); - $("addButton").disabled = (dataname.indexOf(":") == -1); - }; + if (window.opener.userFolderType == "user") + $("addButton").disabled = false; + else { + var dataname = this.parentNode.getAttribute("dataname"); + $("addButton").disabled = (dataname.indexOf(":") == -1); + }; } function userFoldersCallback(http) { @@ -121,20 +123,20 @@ function onConfirmFolderSelection(event) { var folderName; if (window.opener.userFolderType == "user") { var spans = document.getElementsByClassName("nodeName", - topNode.selectedEntry); + topNode.selectedEntry); var email = (spans[0].innerHTML - .replace("<", "<", "g") - .replace(">", ">", "g")); + .replace("<", "<", "g") + .replace(">", ">", "g")); folderName = email; } else { log("topNode.selectedEntry: " + topNode.selectedEntry.innerHTML); var spans1 = topNode.selectedEntry.childNodesWithTag("span"); var spans2 = document.getElementsByClassName("nodeName", - node.parentNode.previousSibling); + node.parentNode.previousSibling); var email = (spans2[0].innerHTML - .replace("<", "<", "g") - .replace(">", ">", "g")); + .replace("<", "<", "g") + .replace(">", ">", "g")); folderName = spans1[0].innerHTML + ' (' + email + ')'; } var data = { folderName: folderName, folder: folder, window: window }; diff --git a/UI/WebServerResources/UIxContactsUserRightsEditor.js b/UI/WebServerResources/UIxContactsUserRightsEditor.js index 6d21bdfa3..3dbe8afcb 100644 --- a/UI/WebServerResources/UIxContactsUserRightsEditor.js +++ b/UI/WebServerResources/UIxContactsUserRightsEditor.js @@ -1,5 +1,7 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + function onCancelClick(event) { - window.close(); + window.close(); } function initACLButtons() { diff --git a/UI/WebServerResources/UIxMailEditor.js b/UI/WebServerResources/UIxMailEditor.js index 61f331fa1..7126629ef 100644 --- a/UI/WebServerResources/UIxMailEditor.js +++ b/UI/WebServerResources/UIxMailEditor.js @@ -1,652 +1,654 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + var contactSelectorAction = 'mailer-contacts'; var signatureLength = 0; var attachmentCount = 0; var MailEditor = { - addressBook: null, - currentField: null, - selectedIndex: -1, - delay: 500, - delayedSearch: false + addressBook: null, + currentField: null, + selectedIndex: -1, + delay: 500, + delayedSearch: false }; function onContactAdd() { - var selector = null; - var selectorURL = '?popup=YES&selectorId=mailer-contacts'; + var selector = null; + var selectorURL = '?popup=YES&selectorId=mailer-contacts'; - if (MailEditor.addressBook && MailEditor.addressBook.open && !MailEditor.addressBook.closed) - MailEditor.addressBook.focus(); - else { - var urlstr = ApplicationBaseURL - + "../Contacts/" - + contactSelectorAction + selectorURL; - MailEditor.addressBook = window.open(urlstr, "_blank", - "width=640,height=400,resizable=1,scrollbars=0"); - MailEditor.addressBook.selector = selector; - MailEditor.addressBook.opener = self; - MailEditor.addressBook.focus(); - } + if (MailEditor.addressBook && MailEditor.addressBook.open && !MailEditor.addressBook.closed) + MailEditor.addressBook.focus(); + else { + var urlstr = ApplicationBaseURL + + "../Contacts/" + + contactSelectorAction + selectorURL; + MailEditor.addressBook = window.open(urlstr, "_blank", + "width=640,height=400,resizable=1,scrollbars=0"); + MailEditor.addressBook.selector = selector; + MailEditor.addressBook.opener = self; + MailEditor.addressBook.focus(); + } - return false; + return false; } function addContact(tag, fullContactName, contactId, contactName, contactEmail) { - if (!mailIsRecipient(contactEmail)) { - var neededOptionValue = 0; - if (tag == "cc") - neededOptionValue = 1; - else if (tag == "bcc") - neededOptionValue = 2; + if (!mailIsRecipient(contactEmail)) { + var neededOptionValue = 0; + if (tag == "cc") + neededOptionValue = 1; + else if (tag == "bcc") + neededOptionValue = 2; - var stop = false; - var counter = 0; - var currentRow = $('row_' + counter); - while (currentRow && !stop) { - var currentValue = $(currentRow.childNodesWithTag("td")[1]).childNodesWithTag("input")[0].value; - if (currentValue == neededOptionValue) { - stop = true; - insertContact($("addr_" + counter), contactName, contactEmail); - } - counter++; - currentRow = $('row_' + counter); - } + var stop = false; + var counter = 0; + var currentRow = $('row_' + counter); + while (currentRow && !stop) { + var currentValue = $(currentRow.childNodesWithTag("td")[1]).childNodesWithTag("input")[0].value; + if (currentValue == neededOptionValue) { + stop = true; + insertContact($("addr_" + counter), contactName, contactEmail); + } + counter++; + currentRow = $('row_' + counter); + } - if (!stop) { - fancyAddRow(false, ""); - $($("row_" + counter).childNodesWithTag("td")[0]).childNodesWithTag("select")[0].value - = neededOptionValue; - insertContact($("addr_" + counter), contactName, contactEmail); - onWindowResize(null); - } - } + if (!stop) { + fancyAddRow(false, ""); + $($("row_" + counter).childNodesWithTag("td")[0]).childNodesWithTag("select")[0].value + = neededOptionValue; + insertContact($("addr_" + counter), contactName, contactEmail); + onWindowResize(null); + } + } } function mailIsRecipient(mailto) { - var isRecipient = false; + var isRecipient = false; - var counter = 0; - var currentRow = $('row_' + counter); + var counter = 0; + var currentRow = $('row_' + counter); - var email = extractEmailAddress(mailto).toUpperCase(); + var email = extractEmailAddress(mailto).toUpperCase(); - while (currentRow && !isRecipient) { - var currentValue = $("addr_"+counter).value.toUpperCase(); - if (currentValue.indexOf(email) > -1) - isRecipient = true; - else - { - counter++; - currentRow = $('row_' + counter); - } - } + while (currentRow && !isRecipient) { + var currentValue = $("addr_"+counter).value.toUpperCase(); + if (currentValue.indexOf(email) > -1) + isRecipient = true; + else + { + counter++; + currentRow = $('row_' + counter); + } + } - return isRecipient; + return isRecipient; } function insertContact(inputNode, contactName, contactEmail) { - var value = '' + inputNode.value; + var value = '' + inputNode.value; - var newContact = contactName; - if (newContact.length > 0) - newContact += ' <' + contactEmail + '>'; - else - newContact = contactEmail; + var newContact = contactName; + if (newContact.length > 0) + newContact += ' <' + contactEmail + '>'; + else + newContact = contactEmail; - if (value.length > 0) - value += ", "; - value += newContact; + if (value.length > 0) + value += ", "; + value += newContact; - inputNode.value = value; + inputNode.value = value; } function toggleAttachments() { - var div = $("attachmentsArea"); - var style = "" + div.getStyle("display"); - if (style.length) - div.setStyle({ display: "" }); - else - div.setStyle({ display: "block" }); + var div = $("attachmentsArea"); + var style = "" + div.getStyle("display"); + if (style.length) + div.setStyle({ display: "" }); + else + div.setStyle({ display: "block" }); - return false; + return false; } function updateInlineAttachmentList(sender, attachments) { - var count = 0; + var count = 0; - var div = $("attachmentsArea"); - if (attachments) - count = attachments.length; + var div = $("attachmentsArea"); + if (attachments) + count = attachments.length; - if (count) { - var text = ""; - for (var i = 0; i < count; i++) { - text = text + attachments[i]; - text = text + '
'; - } + if (count) { + var text = ""; + for (var i = 0; i < count; i++) { + text = text + attachments[i]; + text = text + '
'; + } - var e = $('compose_attachments_list'); - e.innerHTML = text; - var style = "" + div.getStyle("display"); - if (!style.length) - div.setStyle({display: "block"}); - } - else - div.setStyle({display: ""}); + var e = $('compose_attachments_list'); + e.innerHTML = text; + var style = "" + div.getStyle("display"); + if (!style.length) + div.setStyle({display: "block"}); + } + else + div.setStyle({display: ""}); } /* mail editor */ function validateEditorInput(sender) { - var errortext = ""; - var field; + var errortext = ""; + var field; - field = document.pageform.subject; - if (field.value == "") - errortext = errortext + labels["error_missingsubject"] + "\n"; + field = document.pageform.subject; + if (field.value == "") + errortext = errortext + labels["error_missingsubject"] + "\n"; - if (!hasRecipients()) - errortext = errortext + labels["error_missingrecipients"] + "\n"; + if (!hasRecipients()) + errortext = errortext + labels["error_missingrecipients"] + "\n"; - if (errortext.length > 0) { - alert(labels["error_validationfailed"] + ":\n" + errortext); - return false; - } + if (errortext.length > 0) { + alert(labels["error_validationfailed"] + ":\n" + errortext); + return false; + } - return true; + return true; } function clickedEditorSend(sender) { - if (!validateEditorInput(sender)) - return false; + if (!validateEditorInput(sender)) + return false; - var input = currentAttachmentInput(); - if (input) - input.parentNode.removeChild(input); + var input = currentAttachmentInput(); + if (input) + input.parentNode.removeChild(input); - var toolbar = document.getElementById("toolbar"); - if (!document.busyAnim) - document.busyAnim = startAnimation(toolbar); + var toolbar = document.getElementById("toolbar"); + if (!document.busyAnim) + document.busyAnim = startAnimation(toolbar); - var lastRow = $("lastRow"); - lastRow.down("select").name = "popup_last"; + var lastRow = $("lastRow"); + lastRow.down("select").name = "popup_last"; - window.shouldPreserve = true; - document.pageform.action = "send"; - document.pageform.submit(); + window.shouldPreserve = true; + document.pageform.action = "send"; + document.pageform.submit(); - return false; + return false; } function currentAttachmentInput() { - var input = null; + var input = null; - var inputs = $("attachmentsArea").getElementsByTagName("input"); - var i = 0; - while (!input && i < inputs.length) - if ($(inputs[i]).hasClassName("currentAttachment")) - input = inputs[i]; - else - i++; + var inputs = $("attachmentsArea").getElementsByTagName("input"); + var i = 0; + while (!input && i < inputs.length) + if ($(inputs[i]).hasClassName("currentAttachment")) + input = inputs[i]; + else + i++; - return input; + return input; } function clickedEditorAttach(sender) { - var input = currentAttachmentInput(); - if (!input) { - var area = $("attachmentsArea"); + var input = currentAttachmentInput(); + if (!input) { + var area = $("attachmentsArea"); - if (!area.style.display) { - area.setStyle({ display: "block" }); - onWindowResize(null); - } - var inputs = area.getElementsByTagName("input"); - var attachmentName = "attachment" + attachmentCount; - var newAttachment = createElement("input", attachmentName, - "currentAttachment", null, - { type: "file", - name: attachmentName }, - area); - attachmentCount++; - newAttachment.observe("change", - onAttachmentChange.bindAsEventListener(newAttachment)); - } + if (!area.style.display) { + area.setStyle({ display: "block" }); + onWindowResize(null); + } + var inputs = area.getElementsByTagName("input"); + var attachmentName = "attachment" + attachmentCount; + var newAttachment = createElement("input", attachmentName, + "currentAttachment", null, + { type: "file", + name: attachmentName }, + area); + attachmentCount++; + newAttachment.observe("change", + onAttachmentChange.bindAsEventListener(newAttachment)); + } - return false; + return false; } function onAddAttachment() { - return clickedEditorAttach(null); + return clickedEditorAttach(null); } function onAttachmentChange(event) { - if (this.value == "") - this.parentNode.removeChild(this); - else { - this.addClassName("attachment"); - this.removeClassName("currentAttachment"); - var list = $("attachments"); - createAttachment(this, list); - clickedEditorAttach(null); - } + if (this.value == "") + this.parentNode.removeChild(this); + else { + this.addClassName("attachment"); + this.removeClassName("currentAttachment"); + var list = $("attachments"); + createAttachment(this, list); + clickedEditorAttach(null); + } } function createAttachment(node, list) { - var attachment = createElement("li", null, null, { node: node }, null, list); - createElement("img", null, null, { src: ResourcesURL + "/attachment.gif" }, - null, attachment); - attachment.observe("click", onRowClick); + var attachment = createElement("li", null, null, { node: node }, null, list); + createElement("img", null, null, { src: ResourcesURL + "/attachment.gif" }, + null, attachment); + attachment.observe("click", onRowClick); - var filename = node.value; - var separator; - if (navigator.appVersion.indexOf("Windows") > -1) - separator = "\\"; - else - separator = "/"; - var fileArray = filename.split(separator); - var attachmentName = document.createTextNode(fileArray[fileArray.length-1]); - attachment.appendChild(attachmentName); + var filename = node.value; + var separator; + if (navigator.appVersion.indexOf("Windows") > -1) + separator = "\\"; + else + separator = "/"; + var fileArray = filename.split(separator); + var attachmentName = document.createTextNode(fileArray[fileArray.length-1]); + attachment.appendChild(attachmentName); } function clickedEditorSave(sender) { - var input = currentAttachmentInput(); - if (input) - input.parentNode.removeChild(input); + var input = currentAttachmentInput(); + if (input) + input.parentNode.removeChild(input); - var lastRow = $("lastRow"); - lastRow.down("select").name = "popup_last"; + var lastRow = $("lastRow"); + lastRow.down("select").name = "popup_last"; - window.shouldPreserve = true; - document.pageform.action = "save"; - document.pageform.submit(); + window.shouldPreserve = true; + document.pageform.action = "save"; + document.pageform.submit(); - if (window.opener && window.open && !window.closed) - window.opener.refreshFolderByType('draft'); - return false; + if (window.opener && window.open && !window.closed) + window.opener.refreshFolderByType('draft'); + return false; } function onTextFocus() { - var input = currentAttachmentInput(); - if (input) - input.parentNode.removeChild(input); + var input = currentAttachmentInput(); + if (input) + input.parentNode.removeChild(input); } function onTextKeyDown(event) { - if (event.keyCode == 9) { - if (event.shiftKey) { - var nodes = $("subjectRow").childNodesWithTag("input"); - var objectInput = $(nodes[0]); - objectInput.focus(); - objectInput.selectText(0, objectInput.value.length); - preventDefault(event); - } - else { - if (!(event.shiftKey || event.metaKey || event.ctrlKey)) { - if (this.selectionStart) { // FF - var startText = this.value.substr(0, this.selectionStart); - var endText = this.value.substr(this.selectionStart); - this.value = startText + " " + endText; - } - else if (this.selectionRange) // IE - this.selectionRange.text = " "; - else { // others ? - } - preventDefault(event); - } - } - } + if (event.keyCode == 9) { + if (event.shiftKey) { + var nodes = $("subjectRow").childNodesWithTag("input"); + var objectInput = $(nodes[0]); + objectInput.focus(); + objectInput.selectText(0, objectInput.value.length); + preventDefault(event); + } + else { + if (!(event.shiftKey || event.metaKey || event.ctrlKey)) { + if (this.selectionStart) { // FF + var startText = this.value.substr(0, this.selectionStart); + var endText = this.value.substr(this.selectionStart); + this.value = startText + " " + endText; + } + else if (this.selectionRange) // IE + this.selectionRange.text = " "; + else { // others ? + } + preventDefault(event); + } + } + } } function onTextIEUpdateCursorPos(event) { - this.selectionRange = document.selection.createRange().duplicate(); + this.selectionRange = document.selection.createRange().duplicate(); } function onTextFirstFocus() { - var content = this.getValue(); - if (content.lastIndexOf("--") == 0) { - this.insertBefore(document.createTextNode("\r"), - this.lastChild); - } - if (signatureLength > 0) { - var length = this.getValue().length - signatureLength - 2; - this.setCaretTo(length); - } - Event.stopObserving(this, "focus", onTextFirstFocus); + var content = this.getValue(); + if (content.lastIndexOf("--") == 0) { + this.insertBefore(document.createTextNode("\r"), + this.lastChild); + } + if (signatureLength > 0) { + var length = this.getValue().length - signatureLength - 2; + this.setCaretTo(length); + } + Event.stopObserving(this, "focus", onTextFirstFocus); } function onTextContextMenu(event) { - event.returnValue = true; - event.cancelBubble = true; + event.returnValue = true; + event.cancelBubble = true; } function onTextMouseDown(event) { - if (event.button == 0) { - event.returnValue = false; - event.cancelBubble = false; - } + if (event.button == 0) { + event.returnValue = false; + event.cancelBubble = false; + } } /* address completion */ function onContactKeydown(event) { - if (event.ctrlKey || event.metaKey) { - this.focussed = true; - return; - } - if (event.keyCode == 9) { // Tab - if (this.confirmedValue) - this.value = this.confirmedValue; - if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); - } - else if (event.keyCode == 0 - || event.keyCode == 8 // Backspace - || event.keyCode == 32 // Space - || event.keyCode > 47) { - this.confirmedValue = null; - MailEditor.selectedIndex = -1; - MailEditor.currentField = this; - if (this.value.length > 0 && !MailEditor.delayedSearch) { - MailEditor.delayedSearch = true; - setTimeout("performSearch()", MailEditor.delay); - } - else if (this.value.length == 0) { - if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); - } - } - else if (event.keyCode == 13) { - preventDefault(event); - if (this.confirmedValue) - this.value = this.confirmedValue; - $(this).selectText(0, this.value.length); - if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); - MailEditor.selectedIndex = -1; - } - else if ($('contactsMenu').getStyle('visibility') == 'visible') { - if (event.keyCode == 38) { // Up arrow - if (MailEditor.selectedIndex > 0) { - var contacts = $('contactsMenu').select("li"); - contacts[MailEditor.selectedIndex--].removeClassName("selected"); - this.value = contacts[MailEditor.selectedIndex].firstChild.nodeValue.trim(); - contacts[MailEditor.selectedIndex].addClassName("selected"); - } - } - else if (event.keyCode == 40) { // Down arrow - var contacts = $('contactsMenu').select("li"); - if (contacts.size() - 1 > MailEditor.selectedIndex) { - if (MailEditor.selectedIndex >= 0) - contacts[MailEditor.selectedIndex].removeClassName("selected"); - MailEditor.selectedIndex++; - this.value = contacts[MailEditor.selectedIndex].firstChild.nodeValue.trim(); - contacts[MailEditor.selectedIndex].addClassName("selected"); - } - } - } + if (event.ctrlKey || event.metaKey) { + this.focussed = true; + return; + } + if (event.keyCode == 9) { // Tab + if (this.confirmedValue) + this.value = this.confirmedValue; + if (document.currentPopupMenu) + hideMenu(document.currentPopupMenu); + } + else if (event.keyCode == 0 + || event.keyCode == 8 // Backspace + || event.keyCode == 32 // Space + || event.keyCode > 47) { + this.confirmedValue = null; + MailEditor.selectedIndex = -1; + MailEditor.currentField = this; + if (this.value.length > 0 && !MailEditor.delayedSearch) { + MailEditor.delayedSearch = true; + setTimeout("performSearch()", MailEditor.delay); + } + else if (this.value.length == 0) { + if (document.currentPopupMenu) + hideMenu(document.currentPopupMenu); + } + } + else if (event.keyCode == 13) { + preventDefault(event); + if (this.confirmedValue) + this.value = this.confirmedValue; + $(this).selectText(0, this.value.length); + if (document.currentPopupMenu) + hideMenu(document.currentPopupMenu); + MailEditor.selectedIndex = -1; + } + else if ($('contactsMenu').getStyle('visibility') == 'visible') { + if (event.keyCode == 38) { // Up arrow + if (MailEditor.selectedIndex > 0) { + var contacts = $('contactsMenu').select("li"); + contacts[MailEditor.selectedIndex--].removeClassName("selected"); + this.value = contacts[MailEditor.selectedIndex].firstChild.nodeValue.trim(); + contacts[MailEditor.selectedIndex].addClassName("selected"); + } + } + else if (event.keyCode == 40) { // Down arrow + var contacts = $('contactsMenu').select("li"); + if (contacts.size() - 1 > MailEditor.selectedIndex) { + if (MailEditor.selectedIndex >= 0) + contacts[MailEditor.selectedIndex].removeClassName("selected"); + MailEditor.selectedIndex++; + this.value = contacts[MailEditor.selectedIndex].firstChild.nodeValue.trim(); + contacts[MailEditor.selectedIndex].addClassName("selected"); + } + } + } } function performSearch() { - // Perform address completion - if (MailEditor.currentField) { - if (document.contactLookupAjaxRequest) { - // Abort any pending request - document.contactLookupAjaxRequest.aborted = true; - document.contactLookupAjaxRequest.abort(); - } - if (MailEditor.currentField.value.trim().length > 0) { - var urlstr = ( UserFolderURL + "Contacts/allContactSearch?search=" - + MailEditor.currentField.value ); - document.contactLookupAjaxRequest = - triggerAjaxRequest(urlstr, performSearchCallback, MailEditor.currentField); - } - } - MailEditor.delayedSearch = false; + // Perform address completion + if (MailEditor.currentField) { + if (document.contactLookupAjaxRequest) { + // Abort any pending request + document.contactLookupAjaxRequest.aborted = true; + document.contactLookupAjaxRequest.abort(); + } + if (MailEditor.currentField.value.trim().length > 0) { + var urlstr = ( UserFolderURL + "Contacts/allContactSearch?search=" + + MailEditor.currentField.value ); + document.contactLookupAjaxRequest = + triggerAjaxRequest(urlstr, performSearchCallback, MailEditor.currentField); + } + } + MailEditor.delayedSearch = false; } function performSearchCallback(http) { - if (http.readyState == 4) { - var menu = $('contactsMenu'); - var list = menu.down("ul"); + if (http.readyState == 4) { + var menu = $('contactsMenu'); + var list = menu.down("ul"); - var input = http.callbackData; + var input = http.callbackData; - if (http.status == 200) { - var start = input.value.length; - var data = http.responseText.evalJSON(true); + if (http.status == 200) { + var start = input.value.length; + var data = http.responseText.evalJSON(true); - if (data.length > 1) { - list.select("li").each(function(item) { - item.remove(); - }); + if (data.length > 1) { + list.select("li").each(function(item) { + item.remove(); + }); - // Populate popup menu - for (var i = 0; i < data.length; i++) { - var contact = data[i]; - var completeEmail = contact["displayName"] + " <" + contact["mail"] + ">"; - var node = document.createElement("li"); - list.appendChild(node); - node.uid = contact["c_uid"]; - node.appendChild(document.createTextNode(completeEmail)); - $(node).observe("mousedown", onAddressResultClick); - } + // Populate popup menu + for (var i = 0; i < data.length; i++) { + var contact = data[i]; + var completeEmail = contact["displayName"] + " <" + contact["mail"] + ">"; + var node = document.createElement("li"); + list.appendChild(node); + node.uid = contact["c_uid"]; + node.appendChild(document.createTextNode(completeEmail)); + $(node).observe("mousedown", onAddressResultClick); + } - // Show popup menu - var offsetScroll = Element.cumulativeScrollOffset(MailEditor.currentField); - var offset = Element.cumulativeOffset(MailEditor.currentField); - var top = offset[1] - offsetScroll[1] + node.offsetHeight + 3; - var height = 'auto'; - var heightDiff = window.height() - offset[1]; - var nodeHeight = node.getHeight(); + // Show popup menu + var offsetScroll = Element.cumulativeScrollOffset(MailEditor.currentField); + var offset = Element.cumulativeOffset(MailEditor.currentField); + var top = offset[1] - offsetScroll[1] + node.offsetHeight + 3; + var height = 'auto'; + var heightDiff = window.height() - offset[1]; + var nodeHeight = node.getHeight(); - if ((data.length * nodeHeight) > heightDiff) - // Limit the size of the popup to the window height, minus 12 pixels - height = parseInt(heightDiff/nodeHeight) * nodeHeight - 12 + 'px'; + if ((data.length * nodeHeight) > heightDiff) + // Limit the size of the popup to the window height, minus 12 pixels + height = parseInt(heightDiff/nodeHeight) * nodeHeight - 12 + 'px'; - menu.setStyle({ top: top + "px", - left: offset[0] + "px", - height: height, - visibility: "visible" }); - menu.scrollTop = 0; + menu.setStyle({ top: top + "px", + left: offset[0] + "px", + height: height, + visibility: "visible" }); + menu.scrollTop = 0; - document.currentPopupMenu = menu; - $(document.body).observe("click", onBodyClickMenuHandler); - } - else { - if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); + document.currentPopupMenu = menu; + $(document.body).observe("click", onBodyClickMenuHandler); + } + else { + if (document.currentPopupMenu) + hideMenu(document.currentPopupMenu); - if (data.length == 1) { - // Single result - var contact = data[0]; - if (contact["c_uid"].length > 0) - input.uid = contact["c_uid"]; - var completeEmail = contact["displayName"] + " <" + contact["mail"] + ">"; - if (contact["displayName"].substring(0, input.value.length).toUpperCase() - == input.value.toUpperCase()) - input.value = completeEmail; - else - // The result matches email address, not user name - input.value += ' >> ' + completeEmail; - input.confirmedValue = completeEmail; + if (data.length == 1) { + // Single result + var contact = data[0]; + if (contact["c_uid"].length > 0) + input.uid = contact["c_uid"]; + var completeEmail = contact["displayName"] + " <" + contact["mail"] + ">"; + if (contact["displayName"].substring(0, input.value.length).toUpperCase() + == input.value.toUpperCase()) + input.value = completeEmail; + else + // The result matches email address, not user name + input.value += ' >> ' + completeEmail; + input.confirmedValue = completeEmail; - var end = input.value.length; - $(input).selectText(start, end); + var end = input.value.length; + $(input).selectText(start, end); - MailEditor.selectedIndex = -1; - } - } - } - else - if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); - document.contactLookupAjaxRequest = null; - } + MailEditor.selectedIndex = -1; + } + } + } + else + if (document.currentPopupMenu) + hideMenu(document.currentPopupMenu); + document.contactLookupAjaxRequest = null; + } } function onAddressResultClick(event) { - if (MailEditor.currentField) { - MailEditor.currentField.uid = this.uid; - MailEditor.currentField.value = this.firstChild.nodeValue.trim(); - MailEditor.currentField.confirmedValue = MailEditor.currentField.value; - } + if (MailEditor.currentField) { + MailEditor.currentField.uid = this.uid; + MailEditor.currentField.value = this.firstChild.nodeValue.trim(); + MailEditor.currentField.confirmedValue = MailEditor.currentField.value; + } } function initTabIndex(addressList, subjectField, msgArea) { - var i = 1; - addressList.select("input.textField").each(function (input) { - if (!input.readAttribute("readonly")) { - input.writeAttribute("tabindex", i++); - input.writeAttribute("autocomplete", "off"); - input.observe("keydown", onContactKeydown); // bind listener for address completion - } - }); - subjectField.writeAttribute("tabindex", i++); - msgArea.writeAttribute("tabindex", i); + var i = 1; + addressList.select("input.textField").each(function (input) { + if (!input.readAttribute("readonly")) { + input.writeAttribute("tabindex", i++); + input.writeAttribute("autocomplete", "off"); + input.observe("keydown", onContactKeydown); // bind listener for address completion + } + }); + subjectField.writeAttribute("tabindex", i++); + msgArea.writeAttribute("tabindex", i); } function initMailEditor() { - var list = $("attachments"); - $(list).attachMenu("attachmentsMenu"); - var elements = $(list).childNodesWithTag("li"); - for (var i = 0; i < elements.length; i++) - elements[i].observe("click", onRowClick); + var list = $("attachments"); + $(list).attachMenu("attachmentsMenu"); + var elements = $(list).childNodesWithTag("li"); + for (var i = 0; i < elements.length; i++) + elements[i].observe("click", onRowClick); - var listContent = $("attachments").childNodesWithTag("li"); - if (listContent.length > 0) - $("attachmentsArea").setStyle({ display: "block" }); + var listContent = $("attachments").childNodesWithTag("li"); + if (listContent.length > 0) + $("attachmentsArea").setStyle({ display: "block" }); - var textarea = $("text"); + var textarea = $("text"); - var textContent = textarea.getValue(); - var sigLimit = textContent.lastIndexOf("--"); - if (sigLimit > -1) - signatureLength = (textContent.length - sigLimit); - textarea.scrollTop = textarea.scrollHeight; - textarea.observe("focus", onTextFirstFocus); - textarea.observe("focus", onTextFocus); - // textarea.observe("contextmenu", onTextContextMenu); - textarea.observe("mousedown", onTextMouseDown, true); - textarea.observe("keydown", onTextKeyDown); + var textContent = textarea.getValue(); + var sigLimit = textContent.lastIndexOf("--"); + if (sigLimit > -1) + signatureLength = (textContent.length - sigLimit); + textarea.scrollTop = textarea.scrollHeight; + textarea.observe("focus", onTextFirstFocus); + textarea.observe("focus", onTextFocus); + // textarea.observe("contextmenu", onTextContextMenu); + textarea.observe("mousedown", onTextMouseDown, true); + textarea.observe("keydown", onTextKeyDown); - if (Prototype.Browser.IE) { - var ieEvents = [ "click", "select", "keyup" ]; - for (var i = 0; i < ieEvents.length; i++) - textarea.observe(ieEvents[i], onTextIEUpdateCursorPos, false); - } + if (Prototype.Browser.IE) { + var ieEvents = [ "click", "select", "keyup" ]; + for (var i = 0; i < ieEvents.length; i++) + textarea.observe(ieEvents[i], onTextIEUpdateCursorPos, false); + } - initTabIndex($("addressList"), $$("div#subjectRow input").first(), textarea); - onWindowResize(null); + initTabIndex($("addressList"), $$("div#subjectRow input").first(), textarea); + onWindowResize(null); - Event.observe(window, "resize", onWindowResize); - Event.observe(window, "beforeunload", onMailEditorClose); + Event.observe(window, "resize", onWindowResize); + Event.observe(window, "beforeunload", onMailEditorClose); - var focusField = (mailIsReply ? textarea : $("addr_0")); - focusField.focus(); + var focusField = (mailIsReply ? textarea : $("addr_0")); + focusField.focus(); } function getMenus() { - return { "attachmentsMenu": new Array(null, onRemoveAttachments, - onSelectAllAttachments, - "-", - onAddAttachment, null) }; + return { "attachmentsMenu": new Array(null, onRemoveAttachments, + onSelectAllAttachments, + "-", + onAddAttachment, null) }; } function onRemoveAttachments() { - var list = $("attachments"); - var nodes = list.getSelectedNodes(); - for (var i = nodes.length-1; i > -1; i--) { - var input = $(nodes[i]).node; - if (input) { - input.parentNode.removeChild(input); - list.removeChild(nodes[i]); - } - else { - var filename = ""; - var childNodes = nodes[i].childNodes; - for (var j = 0; j < childNodes.length; j++) { - if (childNodes[j].nodeType == 3) - filename += childNodes[j].nodeValue; - } - var url = "" + window.location; - var parts = url.split("/"); - parts[parts.length-1] = "deleteAttachment?filename=" + encodeURIComponent(filename); - url = parts.join("/"); - triggerAjaxRequest(url, attachmentDeleteCallback, - nodes[i]); - } - } + var list = $("attachments"); + var nodes = list.getSelectedNodes(); + for (var i = nodes.length-1; i > -1; i--) { + var input = $(nodes[i]).node; + if (input) { + input.parentNode.removeChild(input); + list.removeChild(nodes[i]); + } + else { + var filename = ""; + var childNodes = nodes[i].childNodes; + for (var j = 0; j < childNodes.length; j++) { + if (childNodes[j].nodeType == 3) + filename += childNodes[j].nodeValue; + } + var url = "" + window.location; + var parts = url.split("/"); + parts[parts.length-1] = "deleteAttachment?filename=" + encodeURIComponent(filename); + url = parts.join("/"); + triggerAjaxRequest(url, attachmentDeleteCallback, + nodes[i]); + } + } } function attachmentDeleteCallback(http) { - if (http.readyState == 4) { - if (isHttpStatus204(http.status)) { - var node = http.callbackData; - node.parentNode.removeChild(node); - } - else - log("attachmentDeleteCallback: an error occured: " + http.responseText); - } + if (http.readyState == 4) { + if (isHttpStatus204(http.status)) { + var node = http.callbackData; + node.parentNode.removeChild(node); + } + else + log("attachmentDeleteCallback: an error occured: " + http.responseText); + } } function onSelectAllAttachments() { - var list = $("attachments"); - var nodes = list.childNodesWithTag("li"); - for (var i = 0; i < nodes.length; i++) - nodes[i].selectElement(); + var list = $("attachments"); + var nodes = list.childNodesWithTag("li"); + for (var i = 0; i < nodes.length; i++) + nodes[i].selectElement(); } function onWindowResize(event) { - var textarea = document.pageform.text; - var rowheight = (Element.getHeight(textarea) / textarea.rows); - var headerarea = $("headerArea"); + var textarea = document.pageform.text; + var rowheight = (Element.getHeight(textarea) / textarea.rows); + var headerarea = $("headerArea"); - var attachmentsarea = $("attachmentsArea"); - var attachmentswidth = 0; - if (attachmentsarea.style.display) { - attachmentswidth = attachmentsarea.getWidth(); - // Resize of attachment list is b0rken under IE7 - // fromfield = $(document).getElementsByClassName('headerField', - // headerarea)[0]; - // $("attachments").setStyle({ height: (headerarea.getHeight() - fromfield.getHeight() - 10) + 'px' }); - } - var subjectfield = headerarea.down("div#subjectRow span.headerField"); - var subjectinput = headerarea.down("div#subjectRow input.textField"); + var attachmentsarea = $("attachmentsArea"); + var attachmentswidth = 0; + if (attachmentsarea.style.display) { + attachmentswidth = attachmentsarea.getWidth(); + // Resize of attachment list is b0rken under IE7 + // fromfield = $(document).getElementsByClassName('headerField', + // headerarea)[0]; + // $("attachments").setStyle({ height: (headerarea.getHeight() - fromfield.getHeight() - 10) + 'px' }); + } + var subjectfield = headerarea.down("div#subjectRow span.headerField"); + var subjectinput = headerarea.down("div#subjectRow input.textField"); - // Resize subject field - subjectinput.setStyle({ width: (window.width() - - $(subjectfield).getWidth() - - attachmentswidth - - 16) + 'px' }); + // Resize subject field + subjectinput.setStyle({ width: (window.width() + - $(subjectfield).getWidth() + - attachmentswidth + - 16) + 'px' }); - // Resize address fields - var addresslist = $('addressList'); - addresslist.setStyle({ width: ($(this).width() - attachmentswidth - 10) + 'px' }); + // Resize address fields + var addresslist = $('addressList'); + addresslist.setStyle({ width: ($(this).width() - attachmentswidth - 10) + 'px' }); - // Set textarea position - textarea.setStyle({ 'top': headerarea.select("hr").first().offsetTop + 'px' }); + // Set textarea position + textarea.setStyle({ 'top': headerarea.select("hr").first().offsetTop + 'px' }); - // Resize the textarea (message content) - textarea.rows = Math.round((window.height() - textarea.offsetTop) / rowheight); + // Resize the textarea (message content) + textarea.rows = Math.round((window.height() - textarea.offsetTop) / rowheight); } function onMailEditorClose(event) { - if (window.shouldPreserve) - window.shouldPreserve = false; - else { - if (window.opener && window.opener.open && !window.opener.closed) { - var url = "" + window.location; - var parts = url.split("/"); - parts[parts.length-1] = "delete"; - url = parts.join("/"); - window.opener.deleteDraft(url); - } - } + if (window.shouldPreserve) + window.shouldPreserve = false; + else { + if (window.opener && window.opener.open && !window.opener.closed) { + var url = "" + window.location; + var parts = url.split("/"); + parts[parts.length-1] = "delete"; + url = parts.join("/"); + window.opener.deleteDraft(url); + } + } - if (MailEditor.addressBook && MailEditor.addressBook.open - && !MailEditor.addressBook.closed) - MailEditor.addressBook.close(); + if (MailEditor.addressBook && MailEditor.addressBook.open + && !MailEditor.addressBook.closed) + MailEditor.addressBook.close(); - Event.stopObserving(window, "beforeunload", onMailEditorClose); + Event.stopObserving(window, "beforeunload", onMailEditorClose); } FastInit.addOnLoad(initMailEditor); diff --git a/UI/WebServerResources/UIxMailPopupView.js b/UI/WebServerResources/UIxMailPopupView.js index dd8df6fa2..9ea40ffaa 100644 --- a/UI/WebServerResources/UIxMailPopupView.js +++ b/UI/WebServerResources/UIxMailPopupView.js @@ -1,3 +1,5 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + function onPrintCurrentMessage(event) { window.print(); @@ -17,8 +19,8 @@ function onICalendarButtonClick(event) { if (window.opener && window.opener.open && !window.opener.closed && window.messageUID) { var c = window.opener; window.opener.triggerAjaxRequest(urlstr, - window.opener.ICalendarButtonCallback, - window.messageUID); + window.opener.ICalendarButtonCallback, + window.messageUID); } } else @@ -32,9 +34,9 @@ function onMenuDeleteMessage(event) { var url = ApplicationBaseURL + messageId + "/trash"; window.opener.deleteMessageWithDelay(url, - rowId, - window.opener.Mailer.currentMailbox, - messageId); + rowId, + window.opener.Mailer.currentMailbox, + messageId); } window.close(); diff --git a/UI/WebServerResources/UIxMailToSelection.js b/UI/WebServerResources/UIxMailToSelection.js index 6c968ef65..a95e7d0c8 100644 --- a/UI/WebServerResources/UIxMailToSelection.js +++ b/UI/WebServerResources/UIxMailToSelection.js @@ -1,22 +1,24 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + /* - Copyright (C) 2005 SKYRIX Software AG + Copyright (C) 2005 SKYRIX Software AG - This file is part of OpenGroupware.org. + This file is part of OpenGroupware.org. - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ /* Dependencies: @@ -109,7 +111,7 @@ function addressFieldLostFocus(sender) { for (var i = 1; i < addresses.length; i++) { var addr = addresses[i].strip(); if (addr.length > 0) - fancyAddRow(false, addr, $(sender).up("tr").down("select").value); + fancyAddRow(false, addr, $(sender).up("tr").down("select").value); } } onWindowResize(null); @@ -180,7 +182,7 @@ function hasRecipients() { count = this.getAddressCount(); - return (count > 0) + return (count > 0); } function initMailToSelection() { diff --git a/UI/WebServerResources/UIxMailUserRightsEditor.js b/UI/WebServerResources/UIxMailUserRightsEditor.js index 7f08ba5c5..bfd6e63dd 100644 --- a/UI/WebServerResources/UIxMailUserRightsEditor.js +++ b/UI/WebServerResources/UIxMailUserRightsEditor.js @@ -1,9 +1,11 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + function onCancelClick(event) { - window.close(); + window.close(); } function initACLButtons() { - $("cancelButton").observe("click", onCancelClick) + $("cancelButton").observe("click", onCancelClick); } FastInit.addOnLoad(initACLButtons); diff --git a/UI/WebServerResources/UIxMailView.js b/UI/WebServerResources/UIxMailView.js index 14f04fecf..f4a72e2b7 100644 --- a/UI/WebServerResources/UIxMailView.js +++ b/UI/WebServerResources/UIxMailView.js @@ -1,3 +1,5 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + function onPrintCurrentMessage(event) { window.print(); diff --git a/UI/WebServerResources/UIxOccurenceDialog.js b/UI/WebServerResources/UIxOccurenceDialog.js index ade34bcce..8c56377d2 100644 --- a/UI/WebServerResources/UIxOccurenceDialog.js +++ b/UI/WebServerResources/UIxOccurenceDialog.js @@ -1,3 +1,5 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + function onCancelButtonClick(event) { window.close(); } @@ -5,10 +7,10 @@ function onCancelButtonClick(event) { function onThisButtonClick(event) { if (action == 'edit') window.opener.performEventEdition(calendarFolder, componentName, - recurrenceName); + recurrenceName); else if (action == 'delete') window.opener.performEventDeletion(calendarFolder, componentName, - recurrenceName); + recurrenceName); else window.alert("Invalid action: " + action); diff --git a/UI/WebServerResources/UIxPreferences.js b/UI/WebServerResources/UIxPreferences.js index 098390beb..3d9045fc7 100644 --- a/UI/WebServerResources/UIxPreferences.js +++ b/UI/WebServerResources/UIxPreferences.js @@ -1,13 +1,15 @@ -function savePreferences(sender) { - $("mainForm").submit(); +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ - return false; +function savePreferences(sender) { + $("mainForm").submit(); + + return false; } function _setupEvents(enable) { var widgets = [ "timezone", "shortDateFormat", "longDateFormat", - "timeFormat", "weekStartDay", "dayStartTime", "dayEndTime", - "firstWeek", "messageCheck" ]; + "timeFormat", "weekStartDay", "dayStartTime", "dayEndTime", + "firstWeek", "messageCheck" ]; for (var i = 0; i < widgets.length; i++) { var widget = $(widgets[i]); if (widget) { diff --git a/UI/WebServerResources/UIxRecurrenceEditor.js b/UI/WebServerResources/UIxRecurrenceEditor.js index ebad2f50a..417e1c231 100644 --- a/UI/WebServerResources/UIxRecurrenceEditor.js +++ b/UI/WebServerResources/UIxRecurrenceEditor.js @@ -1,11 +1,13 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + var RecurrenceEditor = { types: new Array("Daily", "Weekly", "Monthly", "Yearly"), currentRepeatType: 0 -} +}; - function onRepeatTypeChange(event) { - setRepeatType(parseInt(this.value)); - } +function onRepeatTypeChange(event) { + setRepeatType(parseInt(this.value)); +} function setRepeatType(type) { var elements; @@ -16,8 +18,8 @@ function setRepeatType(type) { elements = $$("TABLE TR.recurrence" + RecurrenceEditor.types[i]); if (i != type) elements.each(function(row) { - row.hide(); - }); + row.hide(); + }); } elements = $$("TABLE TR.recurrence" + RecurrenceEditor.types[type]); elements.each(function(row) { @@ -32,8 +34,8 @@ function getSelectedDays(periodType) { var dayPrefix = periodType + "Day"; elementsArray.each(function(item) { if (isNodeSelected(item)) { - var label = "" + item.getAttribute("id"); - days.push(label.substr(dayPrefix.length)); + var label = "" + item.getAttribute("id"); + days.push(label.substr(dayPrefix.length)); } }); return days.join(","); @@ -97,14 +99,14 @@ function initializeFormValues() { else if (repeatType == 1) { // Repeat weekly $('weeklyWeeksField').value = parent$("repeat1").value; -// log ("div: " + weekDiv); -// log ("days: " + parent$("repeat2").value); + // log ("div: " + weekDiv); + // log ("days: " + parent$("repeat2").value); var days = "" + parent$("repeat2").value; if (days.length > 0) { var daysArray = days.split(","); daysArray.each(function(index) { - $("weekDay"+index).addClassName("_selected"); - }); + $("weekDay"+index).addClassName("_selected"); + }); } } else if (repeatType == 2) { @@ -117,8 +119,8 @@ function initializeFormValues() { if (days.length > 0) { var daysArray = days.split(","); daysArray.each(function(index) { - $("monthDay" + index).addClassName("_selected"); - }); + $("monthDay" + index).addClassName("_selected"); + }); } } else if (repeatType == 3) { @@ -169,12 +171,12 @@ function handleDailyRecurrence() { var v = "" + $('dailyDaysField').value; if (v.length > 0) { v = parseInt(v); -// log("v: " + v); + // log("v: " + v); if (!isNaN(v) && v > 0) { - validate = true; - showError = false; - parent$("repeat1").value = radioValue; - parent$("repeat2").value = v; + validate = true; + showError = false; + parent$("repeat1").value = radioValue; + parent$("repeat2").value = v; } } @@ -228,13 +230,13 @@ function handleMonthlyRecurrence() { if (fieldValue.length > 0) { var v = parseInt(fieldValue); if (!isNaN(v) && v > 0) { - validate = true; - showError = false; - parent$("repeat1").value = fieldValue; - parent$("repeat2").value = radioValue; - parent$("repeat3").value = $('monthlyRepeat').value; - parent$("repeat4").value = $('monthlyDay').value; - parent$("repeat5").value = getSelectedDays("month"); + validate = true; + showError = false; + parent$("repeat1").value = fieldValue; + parent$("repeat2").value = radioValue; + parent$("repeat3").value = $('monthlyRepeat').value; + parent$("repeat4").value = $('monthlyDay').value; + parent$("repeat5").value = getSelectedDays("month"); } } @@ -262,15 +264,15 @@ function handleYearlyRecurrence() { // We check if the yearlyYearsField really contains an integer var v = parseInt(fieldValue); if (!isNaN(v) && v > 0) { - validate = true; - showError = false; - parent$("repeat1").value = fieldValue; - parent$("repeat2").value = radioValue; - parent$("repeat3").value = $('yearlyDayField').value; - parent$("repeat4").value = $('yearlyMonth1').value; - parent$("repeat5").value = $('yearlyRepeat').value; - parent$("repeat6").value = $('yearlyDay').value; - parent$("repeat7").value = $('yearlyMonth2').value; + validate = true; + showError = false; + parent$("repeat1").value = fieldValue; + parent$("repeat2").value = radioValue; + parent$("repeat3").value = $('yearlyDayField').value; + parent$("repeat4").value = $('yearlyMonth1').value; + parent$("repeat5").value = $('yearlyRepeat').value; + parent$("repeat6").value = $('yearlyDay').value; + parent$("repeat7").value = $('yearlyMonth2').value; } } @@ -295,9 +297,9 @@ function handleRange() { // We check if the rangeAppointmentsField really contains an integer var v = parseInt(fieldValue); if (!isNaN(v) && v > 0) { - validate = true; - showError = false; - parent$("range2").value = fieldValue; + validate = true; + showError = false; + parent$("range2").value = fieldValue; } } diff --git a/UI/WebServerResources/UIxTaskEditor.js b/UI/WebServerResources/UIxTaskEditor.js index 6964ee79a..cbd09f99c 100644 --- a/UI/WebServerResources/UIxTaskEditor.js +++ b/UI/WebServerResources/UIxTaskEditor.js @@ -1,3 +1,5 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + var contactSelectorAction = 'calendars-contacts'; function uixEarlierDate(date1, date2) { @@ -180,112 +182,112 @@ function dueDayAsShortString() { } this._getDate = function(which) { - var date = window.timeWidgets[which]['date'].valueAsDate(); - date.setHours( window.timeWidgets[which]['hour'].value ); - date.setMinutes( window.timeWidgets[which]['minute'].value ); + var date = window.timeWidgets[which]['date'].valueAsDate(); + date.setHours( window.timeWidgets[which]['hour'].value ); + date.setMinutes( window.timeWidgets[which]['minute'].value ); - return date; + return date; }; this._getShadowDate = function(which) { - var date = window.timeWidgets[which]['date'].getAttribute("shadow-value").asDate(); - var intValue = parseInt(window.timeWidgets[which]['hour'].getAttribute("shadow-value")); - date.setHours(intValue); - intValue = parseInt(window.timeWidgets[which]['minute'].getAttribute("shadow-value")); - date.setMinutes(intValue); - // window.alert("shadow: " + date); + var date = window.timeWidgets[which]['date'].getAttribute("shadow-value").asDate(); + var intValue = parseInt(window.timeWidgets[which]['hour'].getAttribute("shadow-value")); + date.setHours(intValue); + intValue = parseInt(window.timeWidgets[which]['minute'].getAttribute("shadow-value")); + date.setMinutes(intValue); + // window.alert("shadow: " + date); - return date; + return date; }; this.getStartDate = function() { - return this._getDate('start'); + return this._getDate('start'); }; this.getDueDate = function() { - return this._getDate('due'); + return this._getDate('due'); }; this.getShadowStartDate = function() { - return this._getShadowDate('start'); + return this._getShadowDate('start'); }; this.getShadowDueDate = function() { - return this._getShadowDate('due'); + return this._getShadowDate('due'); }; this._setDate = function(which, newDate) { - window.timeWidgets[which]['date'].setValueAsDate(newDate); - window.timeWidgets[which]['hour'].value = newDate.getHours(); - var minutes = newDate.getMinutes(); - if (minutes % 15) + window.timeWidgets[which]['date'].setValueAsDate(newDate); + window.timeWidgets[which]['hour'].value = newDate.getHours(); + var minutes = newDate.getMinutes(); + if (minutes % 15) minutes += (15 - minutes % 15); - window.timeWidgets[which]['minute'].value = minutes; + window.timeWidgets[which]['minute'].value = minutes; }; this.setStartDate = function(newStartDate) { - this._setDate('start', newStartDate); + this._setDate('start', newStartDate); }; this.setDueDate = function(newDueDate) { - // window.alert(newDueDate); - this._setDate('due', newDueDate); + // window.alert(newDueDate); + this._setDate('due', newDueDate); }; this.onAdjustTime = function(event) { - onAdjustDueTime(event); + onAdjustDueTime(event); }; this.onAdjustDueTime = function(event) { if (!window.timeWidgets['due']['date'].disabled) { - var dateDelta = (window.getStartDate().valueOf() - - window.getShadowStartDate().valueOf()); - var newDueDate = new Date(window.getDueDate().valueOf() + dateDelta); - window.setDueDate(newDueDate); - } - window.timeWidgets['start']['date'].updateShadowValue(); - window.timeWidgets['start']['hour'].updateShadowValue(); - window.timeWidgets['start']['minute'].updateShadowValue(); + var dateDelta = (window.getStartDate().valueOf() + - window.getShadowStartDate().valueOf()); + var newDueDate = new Date(window.getDueDate().valueOf() + dateDelta); + window.setDueDate(newDueDate); + } + window.timeWidgets['start']['date'].updateShadowValue(); + window.timeWidgets['start']['hour'].updateShadowValue(); + window.timeWidgets['start']['minute'].updateShadowValue(); }; this.initTimeWidgets = function (widgets) { - this.timeWidgets = widgets; + this.timeWidgets = widgets; - widgets['start']['date'].observe("change", this.onAdjustDueTime, false); - widgets['start']['hour'].observe("change", this.onAdjustDueTime, false); - widgets['start']['minute'].observe("change", this.onAdjustDueTime, false); + widgets['start']['date'].observe("change", this.onAdjustDueTime, false); + widgets['start']['hour'].observe("change", this.onAdjustDueTime, false); + widgets['start']['minute'].observe("change", this.onAdjustDueTime, false); }; function onStatusListChange(event) { - var value = $("statusList").value; - var statusTimeDate = $("statusTime_date"); - var statusPercent = $("statusPercent"); + var value = $("statusList").value; + var statusTimeDate = $("statusTime_date"); + var statusPercent = $("statusPercent"); - if (value == "WONoSelectionString") { - statusTimeDate.disabled = true; - statusPercent.disabled = true; - statusPercent.value = ""; - } - else if (value == "0") { - statusTimeDate.disabled = true; - statusPercent.disabled = false; - } - else if (value == "1") { - statusTimeDate.disabled = true; - statusPercent.disabled = false; - } - else if (value == "2") { - statusTimeDate.disabled = false; - statusPercent.disabled = false; - statusPercent.value = "100"; - } - else if (value == "3") { - statusTimeDate.disabled = true; - statusPercent.disabled = true; - } - else { - statusTimeDate.disabled = true; - } + if (value == "WONoSelectionString") { + statusTimeDate.disabled = true; + statusPercent.disabled = true; + statusPercent.value = ""; + } + else if (value == "0") { + statusTimeDate.disabled = true; + statusPercent.disabled = false; + } + else if (value == "1") { + statusTimeDate.disabled = true; + statusPercent.disabled = false; + } + else if (value == "2") { + statusTimeDate.disabled = false; + statusPercent.disabled = false; + statusPercent.value = "100"; + } + else if (value == "3") { + statusTimeDate.disabled = true; + statusPercent.disabled = true; + } + else { + statusTimeDate.disabled = true; + } } function initializeStatusLine() { @@ -294,17 +296,17 @@ function initializeStatusLine() { } function onTaskEditorLoad() { - assignCalendar('startTime_date'); - assignCalendar('dueTime_date'); - assignCalendar('statusTime_date'); + assignCalendar('startTime_date'); + assignCalendar('dueTime_date'); + assignCalendar('statusTime_date'); - var widgets = {'start': {'date': $("startTime_date"), - 'hour': $("startTime_time_hour"), - 'minute': $("startTime_time_minute")}, - 'due': {'date': $("dueTime_date"), - 'hour': $("dueTime_time_hour"), - 'minute': $("dueTime_time_minute")}}; - initTimeWidgets(widgets); + var widgets = {'start': {'date': $("startTime_date"), + 'hour': $("startTime_time_hour"), + 'minute': $("startTime_time_minute")}, + 'due': {'date': $("dueTime_date"), + 'hour': $("dueTime_time_hour"), + 'minute': $("dueTime_time_minute")}}; + initTimeWidgets(widgets); initializeStatusLine(); } diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index 0cd6b9be3..92a27d037 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -1,3 +1,5 @@ +/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */ + /* Copyright (C) 2005 SKYRIX Software AG @@ -49,13 +51,13 @@ function getAllScopeElements(scope) { for (var i = 0; i < scope.childNodes.length; i++) if (typeof(scope.childNodes[i]) == "object" - && scope.childNodes[i].tagName - && scope.childNodes[i].tagName != '') + && scope.childNodes[i].tagName + && scope.childNodes[i].tagName != '') { - elements.push(scope.childNodes[i]); - var childElements = getAllElements(scope.childNodes[i]); - if (childElements.length > 0) - elements.push(childElements); + elements.push(scope.childNodes[i]); + var childElements = getAllElements(scope.childNodes[i]); + if (childElements.length > 0) + elements.push(childElements); } return elements; @@ -74,15 +76,15 @@ function getAllElements(scope) { { elements = getAllScopeElements(scope); if (scope == document) - allDocumentElements = elements; + allDocumentElements = elements; } return elements; } function createElement(tagName, id, classes, - attributes, htmlAttributes, - parentNode) { + attributes, htmlAttributes, + parentNode) { var newElement = $(document.createElement(tagName)); if (id) newElement.setAttribute("id", id); @@ -91,7 +93,7 @@ function createElement(tagName, id, classes, newElement.addClassName(classes); else for (var i = 0; i < classes.length; i++) - newElement.addClassName(classes[i]); + newElement.addClassName(classes[i]); } if (attributes) for (var i in attributes) @@ -123,7 +125,7 @@ function URLForFolderID(folderID) { if (folderInfos.length > 1) { url = UserFolderURL + "../" + folderInfos[0]; if (!(folderInfos[0].endsWith('/') - || folderInfos[1].startsWith('/'))) + || folderInfos[1].startsWith('/'))) url += '/'; url += folderInfos[1]; } @@ -200,7 +202,7 @@ function openUserFolderSelector(callback, type) { urlstr += '/'; urlstr += ("../../" + UserLogin + "/Contacts/userFolders"); var w = window.open(urlstr, "_blank", - "width=322,height=250,resizable=1,scrollbars=0,location=0"); + "width=322,height=250,resizable=1,scrollbars=0,location=0"); w.opener = window; window.userFolderCallback = callback; window.userFolderType = type; @@ -215,7 +217,7 @@ function openContactWindow(url, wId) { } var w = window.open(url, wId, - "width=450,height=600,resizable=0,location=0"); + "width=450,height=600,resizable=0,location=0"); w.focus(); return w; @@ -234,9 +236,9 @@ function openMailComposeWindow(url, wId) { parentWindow = window.opener; var w = parentWindow.open(url, wId, - "width=680,height=520,resizable=1,scrollbars=1,toolbar=0," - + "location=0,directories=0,status=0,menubar=0" - + ",copyhistory=0"); + "width=680,height=520,resizable=1,scrollbars=1,toolbar=0," + + "location=0,directories=0,status=0,menubar=0" + + ",copyhistory=0"); w.focus(); @@ -257,8 +259,8 @@ function openMailTo(senderMailTo) { if (mailto.length > 0) openMailComposeWindow(ApplicationBaseURL - + "../Mail/compose?mailto=" + mailto - + ((subject.length > 0)?"?subject="+subject:"")); + + "../Mail/compose?mailto=" + mailto + + ((subject.length > 0)?"?subject="+subject:"")); return false; /* stop following the link */ } @@ -267,10 +269,10 @@ function deleteDraft(url) { /* this is called by UIxMailEditor with window.opener */ new Ajax.Request(url, { method: 'post', - onFailure: function(transport) { - log("draftDeleteCallback: problem during ajax request: " + transport.status); + onFailure: function(transport) { + log("draftDeleteCallback: problem during ajax request: " + transport.status); } - }); + }); } function createHTTPClient() { @@ -301,9 +303,9 @@ function appendDifferentiator(url) { function onAjaxRequestStateChange(http) { try { if (http.readyState == 4 - && activeAjaxRequests > 0) { + && activeAjaxRequests > 0) { if (!http.aborted) - http.callback(http); + http.callback(http); activeAjaxRequests--; checkAjaxRequestsState(); http.onreadystatechange = Prototype.emptyFunction; @@ -337,8 +339,8 @@ function getContrastingTextColor(bgColor) { // Consider all colors with less than 56% brightness as dark colors and // use white as the foreground color, otherwise use black. return ((brightness < 144) - ? "white" - : "black"); + ? "white" + : "black"); } function triggerAjaxRequest(url, callback, userdata, content, headers) { @@ -354,21 +356,21 @@ function triggerAjaxRequest(url, callback, userdata, content, headers) { http.callback = callback; http.callbackData = userdata; http.onreadystatechange = function() { onAjaxRequestStateChange(http) }; -// = function() { -// // log ("state changed (" + http.readyState + "): " + url); -// }; + // = function() { + // // log ("state changed (" + http.readyState + "): " + url); + // }; var hasContentLength = false; if (headers) { for (var i in headers) { - if (i.toLowerCase() == "content-length") - hasContentLength = true; - http.setRequestHeader(i, headers[i]); + if (i.toLowerCase() == "content-length") + hasContentLength = true; + http.setRequestHeader(i, headers[i]); } } if (!hasContentLength) { var cLength = "0"; if (content) - cLength = "" + content.length; + cLength = "" + content.length; http.setRequestHeader("Content-Length", "" + cLength); } http.send(content ? content : ""); @@ -384,7 +386,7 @@ function startAnimation(parent, nextNode) { var anim = $("progressIndicator"); if (!anim) { anim = createElement("img", "progressIndicator", null, - {src: ResourcesURL + "/busy.gif"}); + {src: ResourcesURL + "/busy.gif"}); anim.setStyle({ visibility: "hidden" }); if (nextNode) parent.insertBefore(anim, nextNode); @@ -405,7 +407,7 @@ function checkAjaxRequestsState() { startAnimation(toolbar); } else if (!activeAjaxRequests - && progressImage) + && progressImage) progressImage.parentNode.removeChild(progressImage); } @@ -422,7 +424,7 @@ function isSafari() { function isHttpStatus204(status) { return (status == 204 || // Firefox - (isSafari() && typeof(status) == 'undefined') || // Safari + (isSafari() && typeof(status) == 'undefined') || // Safari status == 1223); // IE } @@ -517,7 +519,7 @@ function acceptMultiSelect(node) { var attribute = node.getAttribute('multiselect'); if (attribute && attribute.length > 0) { log("node '" + node.getAttribute("id") - + "' is still using old-stylemultiselect!"); + + "' is still using old-stylemultiselect!"); response = (attribute.toLowerCase() == 'yes'); } else @@ -543,8 +545,8 @@ function onRowClick(event) { var items = list.childNodesWithTag("li"); for (var i = 0; i < items.length; i++) { if (items[i] == node) { - rowIndex = i; - break; + rowIndex = i; + break; } } } @@ -554,14 +556,14 @@ function onRowClick(event) { if (initialSelection.length > 0 && initialSelection.indexOf(node) >= 0 && (!isSafari() && !Event.isLeftClick(event) || - isSafari() && event.ctrlKey == 1)) // Event.isLeftClick is not supported in Safari + isSafari() && event.ctrlKey == 1)) // Event.isLeftClick is not supported in Safari // Ignore non primary-click (ie right-click) inside current selection return true; if ((event.shiftKey == 1 || event.metaKey == 1) && (lastClickedRow >= 0) && (acceptMultiSelect(node.parentNode) - || acceptMultiSelect(node.parentNode.parentNode))) { + || acceptMultiSelect(node.parentNode.parentNode))) { if (event.shiftKey) { $(node.parentNode).selectRange(lastClickedRow, rowIndex); } else if (isNodeSelected(node)) { @@ -579,7 +581,7 @@ function onRowClick(event) { // Selection has changed; fire mousedown event var parentNode = node.parentNode; if (parentNode.tagName == 'TBODY') - parentNode = parentNode.parentNode; + parentNode = parentNode.parentNode; parentNode.fire("mousedown"); } } @@ -612,12 +614,12 @@ function popupMenu(event, menuId, target) { var menuTop = Event.pointerY(event) + deltaY; var menuLeft = Event.pointerX(event) + deltaX; var heightDiff = (window.height() - - (menuTop + popup.offsetHeight)); + - (menuTop + popup.offsetHeight)); if (heightDiff < 0) menuTop += heightDiff; var leftDiff = (window.width() - - (menuLeft + popup.offsetWidth)); + - (menuLeft + popup.offsetWidth)); if (leftDiff < 0) menuLeft -= popup.offsetWidth; @@ -625,8 +627,8 @@ function popupMenu(event, menuId, target) { popup.prepareVisibility(); popup.setStyle({ top: menuTop + "px", - left: menuLeft + "px", - visibility: "visible" }); + left: menuLeft + "px", + visibility: "visible" }); document.currentPopupMenu = popup; @@ -643,7 +645,7 @@ function getParentMenu(node) { var menure = new RegExp("(^|\s+)menu(\s+|$)", "i"); while (menuNode == null - && currentNode) + && currentNode) if (menure.test(currentNode.className)) menuNode = currentNode; else @@ -781,13 +783,13 @@ function backtrace() { while (func) { if (func.name) - { - str += " " + func.name; - if (this) + { + str += " " + func.name; + if (this) str += " (" + this + ")"; - } + } else - str += "[anonymous]\n"; + str += "[anonymous]\n"; str += "\n"; func = func.caller; @@ -812,18 +814,18 @@ function popupSubmenu(event) { submenuNode.prepareVisibility(); var menuTop = (parentNode.offsetTop - 1 - + this.offsetTop); + + this.offsetTop); if (window.height() - < (menuTop + submenuNode.offsetHeight)) + < (menuTop + submenuNode.offsetHeight)) if (submenuNode.offsetHeight < window.height()) - menuTop = window.height() - submenuNode.offsetHeight; + menuTop = window.height() - submenuNode.offsetHeight; else - menuTop = 0; + menuTop = 0; var menuLeft = (parentNode.offsetLeft + parentNode.offsetWidth - 3); if (window.width() - < (menuLeft + submenuNode.offsetWidth)) + < (menuLeft + submenuNode.offsetWidth)) menuLeft = parentNode.offsetLeft - submenuNode.offsetWidth + 3; this.mouseInside = true; @@ -834,8 +836,8 @@ function popupSubmenu(event) { parentNode.observe("mouseover", onMouseEnteredParentMenu); $(this).addClassName("submenu-selected"); submenuNode.setStyle({ top: menuTop + "px", - left: menuLeft + "px", - visibility: "visible" }); + left: menuLeft + "px", + visibility: "visible" }); preventDefault(event); } } @@ -872,8 +874,8 @@ function popupSearchMenu(event) { var popup = $(menuId); offset = Position.positionedOffset(this); popup.setStyle({ top: this.offsetHeight + "px", - left: (offset[0] + 3) + "px", - visibility: "visible" }); + left: (offset[0] + 3) + "px", + visibility: "visible" }); document.currentPopupMenu = popup; $(document.body).observe("click", onBodyClickMenuHandler); @@ -979,7 +981,7 @@ function onSearchFormSubmit(event) { if (searchValue.value != searchValue.ghostPhrase && (searchValue.value != searchValue.lastSearch - || searchValue.value.strip().length > 0)) { + || searchValue.value.strip().length > 0)) { search["criteria"] = searchCriteria.value; search["value"] = searchValue.value; searchValue.lastSearch = searchValue.value; @@ -999,13 +1001,13 @@ function initCriteria() { searchValue.ghostPhrase = firstOption.innerHTML; searchValue.lastSearch = ""; if (searchValue.value == '') { - searchValue.value = firstOption.innerHTML; - searchValue.setAttribute("modified", ""); - searchValue.setStyle({ color: "#aaa" }); + searchValue.value = firstOption.innerHTML; + searchValue.setAttribute("modified", ""); + searchValue.setStyle({ color: "#aaa" }); } // Set the checkmark to the first option if (searchOptions.chosenNode) - searchOptions.chosenNode.removeClassName("_chosen"); + searchOptions.chosenNode.removeClassName("_chosen"); firstOption.addClassName("_chosen"); searchOptions.chosenNode = firstOption; } @@ -1026,8 +1028,8 @@ function popupToolbarMenu(node, menuId) { var offset = $(node).cumulativeOffset(); var top = offset.top + node.offsetHeight; popup.setStyle({ top: top + "px", - left: offset.left + "px", - visibility: "visible" }); + left: offset.left + "px", + visibility: "visible" }); document.currentPopupMenu = popup; $(document.body).observe("mouseup", onBodyClickMenuHandler); @@ -1039,7 +1041,7 @@ function folderSubscriptionCallback(http) { if (http.readyState == 4) { if (isHttpStatus204(http.status)) { if (http.callbackData) - http.callbackData["method"](http.callbackData["data"]); + http.callbackData["method"](http.callbackData["data"]); } else window.alert(clabels["Unable to subscribe to that folder!"]); @@ -1055,7 +1057,7 @@ function subscribeToFolder(refreshCallback, refreshCallbackData) { var folderPath = folderData[1]; if (username != UserLogin) { var url = (UserFolderURL + "../" + username - + folderPath + "/subscribe"); + + folderPath + "/subscribe"); if (document.subscriptionAjaxRequest) { document.subscriptionAjaxRequest.aborted = true; document.subscriptionAjaxRequest.abort(); @@ -1063,8 +1065,8 @@ function subscribeToFolder(refreshCallback, refreshCallbackData) { var rfCbData = { method: refreshCallback, data: refreshCallbackData }; document.subscriptionAjaxRequest = triggerAjaxRequest(url, - folderSubscriptionCallback, - rfCbData); + folderSubscriptionCallback, + rfCbData); } else refreshCallbackData["window"].alert(clabels["You cannot subscribe to a folder that you own!"]); @@ -1075,7 +1077,7 @@ function folderUnsubscriptionCallback(http) { removeFolderRequestCount--; if (isHttpStatus204(http.status)) { if (http.callbackData) - http.callbackData["method"](http.callbackData["data"]); + http.callbackData["method"](http.callbackData["data"]); } else window.alert(clabels["Unable to unsubscribe from that folder!"]); @@ -1083,10 +1085,10 @@ function folderUnsubscriptionCallback(http) { } function unsubscribeFromFolder(folder, owner, refreshCallback, - refreshCallbackData) { + refreshCallbackData) { if (document.body.hasClassName("popup")) { window.opener.unsubscribeFromFolder(folder, refreshCallback, - refreshCallbackData); + refreshCallbackData); } else { if (owner.startsWith('/')) @@ -1137,10 +1139,10 @@ function getListIndexForFolder(items, owner, folderName) { if (currentOwner == owner) { previousOwner = currentOwner; if (currentFolderName > folderName) - break; + break; } else if (previousOwner || - (currentOwner != UserLogin && currentOwner > owner)) + (currentOwner != UserLogin && currentOwner > owner)) break; else if (currentOwner == "nobody") break; @@ -1164,12 +1166,12 @@ function initTabs() { var firstTab = null; var nodes = $(list[0]).childNodesWithTag("li"); for (var i = 0; i < nodes.length; i++) { - var currentNode = $(nodes[i]); - if (!firstTab) - firstTab = currentNode; - currentNode.observe("mousedown", onTabMouseDown); - currentNode.observe("click", onTabClick); - //$(currentNode.getAttribute("target")).hide(); + var currentNode = $(nodes[i]); + if (!firstTab) + firstTab = currentNode; + currentNode.observe("mousedown", onTabMouseDown); + currentNode.observe("click", onTabClick); + //$(currentNode.getAttribute("target")).hide(); } firstTab.addClassName("first"); @@ -1189,7 +1191,7 @@ function initMenus() { for (var menuID in menus) { var menuDIV = $(menuID); if (menuDIV) - initMenu(menuDIV, menus[menuID]); + initMenu(menuDIV, menus[menuID]); } } } @@ -1202,18 +1204,18 @@ function initMenu(menuDIV, callbacks) { var callback = callbacks[j]; if (callback) { if (typeof(callback) == "string") { - if (callback == "-") - node.addClassName("separator"); - else { - node.submenu = callback; - node.addClassName("submenu"); - node.observe("mouseover", popupSubmenu); - } + if (callback == "-") + node.addClassName("separator"); + else { + node.submenu = callback; + node.addClassName("submenu"); + node.observe("mouseover", popupSubmenu); + } } else { - node.observe("mouseup", onBodyClickMenuHandler); - node.menuCallback = callback; - node.observe("click", onMenuClickHandler); + node.observe("mouseup", onBodyClickMenuHandler); + node.menuCallback = callback; + node.observe("click", onMenuClickHandler); } } else @@ -1254,7 +1256,7 @@ function getTopWindow() { var currentWindow = window; while (!topWindow) { if (currentWindow.document.body.hasClassName("popup") - && currentWindow.opener) + && currentWindow.opener) currentWindow = currentWindow.opener; else topWindow = currentWindow; @@ -1349,9 +1351,9 @@ function indexColor(number) { var index = 0; while (currentValue) { if (currentValue & 1) - colorTable[index]++; + colorTable[index]++; if (index == 3) - index = 0; + index = 0; currentValue >>= 1; index++; } @@ -1410,8 +1412,8 @@ function onLoadHandler(event) { function onBodyClickContextMenu(event) { if (!(event.target - && (event.target.tagName == "INPUT" - || event.target.tagName == "TEXTAREA"))) + && (event.target.tagName == "INPUT" + || event.target.tagName == "TEXTAREA"))) preventDefault(event); } @@ -1431,7 +1433,7 @@ function onLinkBannerClick() { function onPreferencesClick(event) { var urlstr = UserFolderURL + "preferences"; var w = window.open(urlstr, "_blank", - "width=430,height=250,resizable=0,scrollbars=0,location=0"); + "width=430,height=250,resizable=0,scrollbars=0,location=0"); w.opener = window; w.focus(); @@ -1445,8 +1447,8 @@ function configureLinkBanner() { for (var i = 0; i < moduleLinks.length; i++) { var link = $(moduleLinks[i] + "BannerLink"); if (link) { - link.observe("mousedown", listRowMouseDownHandler); - link.observe("click", onLinkBannerClick); + link.observe("mousedown", listRowMouseDownHandler); + link.observe("click", onLinkBannerClick); } } link = $("preferencesBannerLink"); @@ -1472,9 +1474,9 @@ function createFolder(name, okCB, notOkCB) { var url = ApplicationBaseURL + "/createFolder?name=" + name; document.newFolderAjaxRequest = triggerAjaxRequest(url, createFolderCallback, - {name: name, - okCB: okCB, - notOkCB: notOkCB}); + {name: name, + okCB: okCB, + notOkCB: notOkCB}); } } @@ -1483,13 +1485,13 @@ function createFolderCallback(http) { var data = http.callbackData; if (http.status == 201) { if (data.okCB) - data.okCB(data.name, "/" + http.responseText, UserLogin); + data.okCB(data.name, "/" + http.responseText, UserLogin); } else { if (data.notOkCB) - data.notOkCB(name); + data.notOkCB(name); else - log("ajax problem:" + http.status); + log("ajax problem:" + http.status); } } }