Monotone-Parent: d2bec7005b1132e0cdbaba9d59a590f4f9b95b6b

Monotone-Revision: 7cc3351f7b4c30b2183e351afaf429ade9f6ab9b

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