var queryParameters;
-var activeAjaxRequests = 0;
var menus = new Array();
var search = {};
var sorting = {};
+var lastClickedRow = -1;
+
var weekStartIsMonday = true;
// logArea = null;
var userDefaults = null;
var userSettings = null;
+// Ajax requests counts
+var activeAjaxRequests = 0;
+var removeFolderRequestCount = 0;
+
/* a W3C compliant document.all */
function getAllScopeElements(scope) {
var elements = new Array();
function createElement(tagName, id, classes, attributes, htmlAttributes,
parentNode) {
- var newElement = $(document.createElement(tagName));
- if (id)
- newElement.setAttribute("id", id);
- if (classes) {
- if (typeof(classes) == "string")
- newElement.addClassName(classes);
- else
- for (var i = 0; i < classes.length; i++)
- newElement.addClassName(classes[i]);
- }
- if (attributes)
- for (var i in attributes)
- newElement[i] = attributes[i];
- if (htmlAttributes)
- for (var i in htmlAttributes)
- newElement.setAttribute(i, htmlAttributes[i]);
- if (parentNode)
- parentNode.appendChild(newElement);
+ var newElement = $(document.createElement(tagName));
+ if (id)
+ newElement.setAttribute("id", id);
+ if (classes) {
+ if (typeof(classes) == "string")
+ newElement.addClassName(classes);
+ else
+ for (var i = 0; i < classes.length; i++)
+ newElement.addClassName(classes[i]);
+ }
+ if (attributes)
+ for (var i in attributes)
+ newElement[i] = attributes[i];
+ if (htmlAttributes)
+ for (var i in htmlAttributes)
+ newElement.setAttribute(i, htmlAttributes[i]);
+ if (parentNode)
+ parentNode.appendChild(newElement);
- return $(newElement);
+ return $(newElement);
}
function ml_stripActionInURL(url) {
}
function URLForFolderID(folderID) {
- var folderInfos = folderID.split(":");
- var url;
- if (folderInfos.length > 1) {
- url = UserFolderURL + "../" + folderInfos[0];
- if (!folderInfos[1].startsWith('/'))
- url += '/';
- url += folderInfos[1];
- }
- else
- url = ApplicationBaseURL + folderInfos[0];
+ var folderInfos = folderID.split(":");
+ var url;
+ if (folderInfos.length > 1) {
+ url = UserFolderURL + "../" + folderInfos[0];
+ if (!(folderInfos[0].endsWith('/')
+ || folderInfos[1].startsWith('/')))
+ url += '/';
+ url += folderInfos[1];
+ }
+ else
+ url = ApplicationBaseURL + folderInfos[0];
- if (url[url.length-1] == '/')
- url = url.substr(0, url.length-1);
+ if (url[url.length-1] == '/')
+ url = url.substr(0, url.length-1);
- return url;
+ return url;
}
function extractEmailAddress(mailTo) {
function extractEmailName(mailTo) {
var emailName = "";
- var tmpMailTo = mailTo.replace("<", "<");
- tmpMailTo = tmpMailTo.replace(">", ">");
+ var tmpMailTo = mailTo.replace("<", "<");
+ tmpMailTo = tmpMailTo.replace(">", ">");
- var emailNamere = /([ ]+)?(.+)\ </;
- if (emailNamere.test(tmpMailTo)) {
- emailNamere.exec(tmpMailTo);
- emailName = RegExp.$2;
- }
+ var emailNamere = /([ ]+)?(.+)\ </;
+ if (emailNamere.test(tmpMailTo)) {
+ emailNamere.exec(tmpMailTo);
+ emailName = RegExp.$2;
+ }
- return emailName;
+ return emailName;
}
function sanitizeMailTo(dirtyMailTo) {
- var emailName = extractEmailName(dirtyMailTo);
- var email = "" + extractEmailAddress(dirtyMailTo);
+ var emailName = extractEmailName(dirtyMailTo);
+ var email = "" + extractEmailAddress(dirtyMailTo);
- var mailto = "";
- if (emailName && emailName.length > 0)
- mailto = emailName + ' <' + email + '>';
- else
- mailto = email;
+ var mailto = "";
+ if (emailName && emailName.length > 0)
+ mailto = emailName + ' <' + email + '>';
+ else
+ mailto = email;
- return mailto;
+ return mailto;
}
function openUserFolderSelector(callback, type) {
- var urlstr = ApplicationBaseURL;
- if (! urlstr.endsWith('/'))
- urlstr += '/';
- urlstr += ("../../" + UserLogin + "/Contacts/userFolders");
- var w = window.open(urlstr, "_blank",
- "width=322,height=250,resizable=1,scrollbars=0");
- w.opener = window;
- window.userFolderCallback = callback;
- window.userFolderType = type;
- w.focus();
+ var urlstr = ApplicationBaseURL;
+ if (! urlstr.endsWith('/'))
+ urlstr += '/';
+ urlstr += ("../../" + UserLogin + "/Contacts/userFolders");
+ var w = window.open(urlstr, "_blank",
+ "width=322,height=250,resizable=1,scrollbars=0,location=0");
+ w.opener = window;
+ window.userFolderCallback = callback;
+ window.userFolderType = type;
+ w.focus();
}
function openContactWindow(url, wId) {
- if (!wId)
- wId = "" + (new Date().getTime());
+ if (typeof wId == "undefined")
+ wId = "_blank";
+ else {
+ var r = new RegExp("[\.\/-]", "g");
+ wId = wId.replace(r, "_");
+ }
+
var w = window.open(url, wId,
- "width=450,height=600,resizable=0");
+ "width=450,height=600,resizable=0,location=0");
w.focus();
return w;
}
function openMailComposeWindow(url, wId) {
- if (!wId)
- wId = "" + (new Date().getTime());
- var w = window.open(url, wId,
+ var parentWindow = this;
+
+ if (typeof wId == "undefined")
+ wId = "_blank";
+ else {
+ var r = new RegExp("[\.\/-]", "g");
+ wId = wId.replace(r, "_");
+ }
+
+ if (document.body.hasClassName("popup"))
+ parentWindow = window.opener;
+
+ var w = parentWindow.open(url, wId,
"width=680,height=520,resizable=1,scrollbars=1,toolbar=0,"
+ "location=0,directories=0,status=0,menubar=0"
+ ",copyhistory=0");
+
w.focus();
return w;
}
function openMailTo(senderMailTo) {
- var mailto = sanitizeMailTo(senderMailTo);
- if (mailto.length > 0)
- openMailComposeWindow(ApplicationBaseURL
- + "/../Mail/compose?mailto=" + mailto);
+ var mailto = sanitizeMailTo(senderMailTo);
+
+ if (mailto.length > 0)
+ openMailComposeWindow(ApplicationBaseURL
+ + "../Mail/compose?mailto=" + mailto);
return false; /* stop following the link */
}
return url_nocache;
}
-function triggerAjaxRequest(url, callback, userdata) {
+function triggerAjaxRequest(url, callback, userdata, content, headers) {
var http = createHTTPClient();
activeAjaxRequests += 1;
- document.animTimer = setTimeout("checkAjaxRequestsState();", 200);
+ document.animTimer = setTimeout("checkAjaxRequestsState();", 50);
//url = appendDifferentiator(url);
if (http) {
http.url = url;
http.onreadystatechange
= function() {
- //log ("state changed (" + http.readyState + "): " + url);
- try {
- if (http.readyState == 4
- && activeAjaxRequests > 0) {
- if (!http.aborted) {
- http.callbackData = userdata;
- callback(http);
- }
- activeAjaxRequests -= 1;
- checkAjaxRequestsState();
- }
- }
- catch( e ) {
- activeAjaxRequests -= 1;
- checkAjaxRequestsState();
- log("AJAX Request, Caught Exception: " + e.name);
- log(e.message);
- log(backtrace());
- }
- };
- http.send(null);
+// log ("state changed (" + http.readyState + "): " + url);
+ try {
+ if (http.readyState == 4
+ && activeAjaxRequests > 0) {
+ if (!http.aborted) {
+ if (userdata)
+ http.callbackData = userdata;
+ callback(http);
+ }
+ activeAjaxRequests -= 1;
+ checkAjaxRequestsState();
+ }
+ }
+ catch( e ) {
+ activeAjaxRequests -= 1;
+ checkAjaxRequestsState();
+ log("AJAX Request, Caught Exception: " + e.name);
+ log(e.message);
+ log(backtrace());
+ }
+ };
+ if (headers) {
+ for (var i in headers)
+ http.setRequestHeader(i, headers[i]);
+ }
+ http.send(content);
}
else {
log("triggerAjaxRequest: error creating HTTP Client!");
}
function startAnimation(parent, nextNode) {
- var anim = document.createElement("img");
+ var anim = $("progressIndicator");
+ if (anim) return anim;
+
+ anim = document.createElement("img");
anim = $(anim);
anim.id = "progressIndicator";
anim.src = ResourcesURL + "/busy.gif";
}
}
+function isSafari3() {
+ return (navigator.appVersion.indexOf("Version") > -1);
+}
+
function isSafari() {
//var agt = navigator.userAgent.toLowerCase();
//var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
function preventDefault(event) {
if (event.preventDefault)
event.preventDefault(); // W3C DOM
-
- event.returnValue = false; // IE
+ else
+ event.returnValue = false; // IE
}
function resetSelection(win) {
function parseQueryString() {
var queryArray, queryDict
- var key, value, s, idx;
+ var key, value, s, idx;
queryDict.length = 0;
queryDict = new Array();
return s;
}
-function getQueryParaArray(s) {
- if (s.charAt(0) == "?") s = s.substr(1, s.length - 1);
- return s.split("&");
-}
-
-function getQueryParaValue(s, name) {
- var t;
-
- t = getQueryParaArray(s);
- for (var i = 0; i < t.length; i++) {
- var s = t[i];
-
- if (s.indexOf(name) != 0)
- continue;
-
- s = s.substr(name.length, s.length - name.length);
- return decodeURIComponent(s);
- }
- return null;
-}
-
-/* opener callback */
-
-function triggerOpenerCallback() {
- /* this code has some issue if the folder has no proper trailing slash! */
- if (window.opener && !window.opener.closed) {
- var t, cburl;
-
- t = getQueryParaValue(window.location.search, "openerurl=");
- cburl = window.opener.location.href;
- if (cburl[cburl.length - 1] != "/") {
- cburl = cburl.substr(0, cburl.lastIndexOf("/") + 1);
- }
- cburl = cburl + t;
- window.opener.location.href = cburl;
- }
-}
-
/* selection mechanism */
function deselectAll(parent) {
}
function acceptMultiSelect(node) {
- var response = false;
- var attribute = node.getAttribute('multiselect');
- if (attribute) {
- log("node '" + node.getAttribute("id")
- + "' is still using old-stylemultiselect!");
- response = (attribute.toLowerCase() == 'yes');
- }
- else
- response = node.multiselect;
+ var response = false;
+ var attribute = node.getAttribute('multiselect');
+ if (attribute && attribute.length > 0) {
+ log("node '" + node.getAttribute("id")
+ + "' is still using old-stylemultiselect!");
+ response = (attribute.toLowerCase() == 'yes');
+ }
+ else
+ response = node.multiselect;
- return response;
+ return response;
}
function onRowClick(event) {
var node = getTarget(event);
+ var rowIndex = null;
- if (node.tagName == 'TD')
- node = node.parentNode;
- var startSelection = $(node.parentNode).getSelectedNodes();
- if (event.shiftKey == 1
+ if (node.tagName == 'TD') {
+ node = node.parentNode; // select TR
+ rowIndex = node.rowIndex - $(node).up('table').down('thead').getElementsByTagName('tr').length;
+ }
+ else if (node.tagName == 'LI') {
+ // Find index of clicked row
+ var list = node.parentNode;
+ var items = list.childNodesWithTag("li");
+ for (var i = 0; i < items.length; i++) {
+ if (items[i] == node) {
+ rowIndex = i;
+ break;
+ }
+ }
+ }
+
+ var initialSelection = $(node.parentNode).getSelectedNodes();
+ if (initialSelection.length > 0
+ && initialSelection.indexOf(node) >= 0
+ && !Event.isLeftClick(event))
+ // Ignore non primary-click (ie right-click) inside current selection
+ return true;
+
+ if ((event.shiftKey == 1 || event.ctrlKey == 1)
+ && (lastClickedRow >= 0)
&& (acceptMultiSelect(node.parentNode)
|| acceptMultiSelect(node.parentNode.parentNode))) {
- if (isNodeSelected(node) == true) {
+ if (event.shiftKey)
+ $(node.parentNode).selectRange(lastClickedRow, rowIndex);
+ else if (isNodeSelected(node) == true) {
$(node).deselect();
} else {
$(node).select();
}
+ // At this point, should empty content of 3-pane view
} else {
+ // Single line selection
$(node.parentNode).deselectAll();
$(node).select();
- }
-
- if (startSelection != $(node.parentNode).getSelectedNodes()) {
- var parentNode = node.parentNode;
- if (parentNode.tagName == 'TBODY')
- parentNode = parentNode.parentNode;
- //log("onRowClick: parentNode = " + parentNode.tagName);
- // parentNode is UL or TABLE
- if (document.createEvent) {
- var onSelectionChangeEvent;
- if (isSafari())
- onSelectionChangeEvent = document.createEvent("UIEvents");
- else
- onSelectionChangeEvent = document.createEvent("Events");
- onSelectionChangeEvent.initEvent("mousedown", true, true);
- parentNode.dispatchEvent(onSelectionChangeEvent);
- }
- else if (document.createEventObject) {
- parentNode.fireEvent("onmousedown");
+
+ if (initialSelection != $(node.parentNode).getSelectedNodes()) {
+ // Selection has changed; fire mousedown event
+ var parentNode = node.parentNode;
+ if (parentNode.tagName == 'TBODY')
+ parentNode = parentNode.parentNode;
+ parentNode.fire("mousedown");
}
}
-
+ lastClickedRow = rowIndex;
+
return true;
}
// var acceptClick = false;
function popupMenu(event, menuId, target) {
- document.menuTarget = target;
+ document.menuTarget = target;
- if (document.currentPopupMenu)
- hideMenu(document.currentPopupMenu);
+ if (document.currentPopupMenu)
+ hideMenu(document.currentPopupMenu);
- var popup = $(menuId);
- var menuTop = Event.pointerY(event);
- var menuLeft = Event.pointerX(event);
- var heightDiff = (window.innerHeight
- - (menuTop + popup.offsetHeight));
- if (heightDiff < 0)
- menuTop += heightDiff;
-
- var leftDiff = (window.innerWidth
- - (menuLeft + popup.offsetWidth));
- if (leftDiff < 0)
- menuLeft -= popup.offsetWidth;
+ var popup = $(menuId);
- popup.setStyle({ top: menuTop + "px",
- left: menuLeft + "px",
- visibility: "visible" });
+ var deltaX = 0;
+ var deltaY = 0;
- document.currentPopupMenu = popup;
+ var pageContent = $("pageContent");
+ if (popup.parentNode.tagName != "BODY") {
+ var offset = pageContent.cascadeLeftOffset();
+ deltaX = -($(popup.parentNode).cascadeLeftOffset() - offset);
+ offset = pageContent.cascadeTopOffset();
+ deltaY = -($(popup.parentNode).cascadeTopOffset() - offset);
+ }
- Event.observe(document.body, "click", onBodyClickMenuHandler);
+ var menuTop = Event.pointerY(event) + deltaY;
+ var menuLeft = Event.pointerX(event) + deltaX;
+ var heightDiff = (window.height()
+ - (menuTop + popup.offsetHeight));
+ if (heightDiff < 0)
+ menuTop += heightDiff;
+
+ var leftDiff = (window.width()
+ - (menuLeft + popup.offsetWidth));
+ if (leftDiff < 0)
+ menuLeft -= popup.offsetWidth;
+
+ if (popup.prepareVisibility)
+ popup.prepareVisibility();
+
+ popup.setStyle({ top: menuTop + "px",
+ left: menuLeft + "px",
+ visibility: "visible" });
+
+ document.currentPopupMenu = popup;
- preventDefault(event);
+ $(document.body).observe("click", onBodyClickMenuHandler);
+
+ preventDefault(event);
}
function getParentMenu(node) {
}
function onBodyClickMenuHandler(event) {
- document.body.menuTarget = null;
- hideMenu(document.currentPopupMenu);
- Event.stopObserving(document.body, "click", onBodyClickMenuHandler);
+ hideMenu(document.currentPopupMenu);
+ document.body.stopObserving("click", onBodyClickMenuHandler);
- preventDefault(event);
+ if (event)
+ preventDefault(event);
}
-function hideMenu(menuNode) { //log ("hideMenu");
+function hideMenu(menuNode) {
var onHide;
if (menuNode.submenu) {
}
menuNode.setStyle({ visibility: "hidden" });
- // menuNode.hide();
if (menuNode.parentMenuItem) {
- menuNode.parentMenuItem.setAttribute('class', 'submenu');
+ menuNode.parentMenuItem.stopObserving("mouseover",onMouseEnteredSubmenu);
+ menuNode.stopObserving("mouseover", onMouseEnteredSubmenu);
+ menuNode.parentMenuItem.stopObserving("mouseout", onMouseLeftSubmenu);
+ menuNode.stopObserving("mouseout", onMouseLeftSubmenu);
+ menuNode.parentMenu.stopObserving("mouseover", onMouseEnteredParentMenu);
+ $(menuNode.parentMenuItem).removeClassName("submenu-selected");
+ menuNode.parentMenuItem.mouseInside = false;
menuNode.parentMenuItem = null;
- menuNode.parentMenu.setAttribute('onmousemove', null);
menuNode.parentMenu.submenuItem = null;
menuNode.parentMenu.submenu = null;
menuNode.parentMenu = null;
}
- if (document.createEvent) {
- var onhideEvent;
- if (isSafari())
- onhideEvent = document.createEvent("UIEvents");
- else // Mozilla
- onhideEvent = document.createEvent("Events");
- onhideEvent.initEvent("mousedown", false, true);
- menuNode.dispatchEvent(onhideEvent);
- }
- else if (document.createEventObject) { // IE
- menuNode.fireEvent("onmousedown");
- }
+ $(menuNode).fire("mousedown");
}
function onMenuEntryClick(event) {
var node = event.target;
id = getParentMenu(node).menuTarget;
-// log("clicked " + id + "/" + id.tagName);
return false;
}
}
function initLogConsole() {
- var logConsole = $("logConsole");
- if (logConsole) {
- logConsole.highlighted = false;
- Event.observe(logConsole, "dblclick", onLogDblClick, false);
- logConsole.innerHTML = "";
- Event.observe(window, "keydown", onBodyKeyDown);
- }
+ var logConsole = $("logConsole");
+ if (logConsole) {
+ logConsole.highlighted = false;
+ logConsole.observe("dblclick", onLogDblClick, false);
+ logConsole.update();
+ Event.observe(window, "keydown", onBodyKeyDown);
+ }
}
function onBodyKeyDown(event) {
- if (event.keyCode == 27) {
- toggleLogConsole();
- preventDefault(event);
- }
+ if (event.keyCode == 27) {
+ toggleLogConsole();
+ preventDefault(event);
+ }
}
function onLogDblClick(event) {
logConsole.setStyle({ display: '' });
}
if (event)
- preventDefault(event);
+ preventDefault(event);
}
function log(message) {
}
var logConsole = logWindow.document.getElementById("logConsole");
if (logConsole) {
- logConsole.highlighted = !logConsole.highlighted;
- var logMessage = message.replace("<", "<", "g");
- logMessage = logMessage.replace(" ", " ", "g");
- logMessage = logMessage.replace("\r\n", "<br />\n", "g");
- logMessage = logMessage.replace("\n", "<br />\n", "g");
- logMessage += '<br />' + "\n";
- if (logConsole.highlighted)
- logMessage = '<div class="highlighted">' + logMessage + '</div>';
- logConsole.innerHTML += logMessage;
+ logConsole.highlighted = !logConsole.highlighted;
+ if (message == '\c') {
+ logConsole.innerHTML = "";
+ return;
+ }
+ var logMessage = message.replace("<", "<", "g");
+ logMessage = logMessage.replace(" ", " ", "g");
+ logMessage = logMessage.replace("\r\n", "<br />\n", "g");
+ logMessage = logMessage.replace("\n", "<br />\n", "g");
+ logMessage += '<br />' + "\n";
+ if (logConsole.highlighted)
+ logMessage = '<div class="highlighted">' + logMessage + '</div>';
+ logConsole.innerHTML += logMessage;
}
}
function backtrace() {
- var func = backtrace.caller;
- var str = "backtrace:\n";
+ var func = backtrace.caller;
+ var str = "backtrace:\n";
- while (func)
- {
+ while (func)
+ {
if (func.name)
- {
- str += " " + func.name;
- if (this)
+ {
+ str += " " + func.name;
+ if (this)
str += " (" + this + ")";
- }
+ }
else
- str += "[anonymous]\n";
+ str += "[anonymous]\n";
str += "\n";
func = func.caller;
- }
- str += "--\n";
-
- return str;
-}
-
-function dropDownSubmenu(event) {
- var node = this;
- if (this.submenu && this.submenu != "") {
- log ("submenu: " + this.submenu);
- var submenuNode = $(this.submenu);
- var parentNode = getParentMenu(node);
- if (parentNode.submenu)
- hideMenu(parentNode.submenu);
- submenuNode.parentMenuItem = node;
- submenuNode.parentMenu = parentNode;
- parentNode.submenuItem = node;
- parentNode.submenu = submenuNode;
-
- var menuTop = (node.offsetTop - 2);
-
- var heightDiff = (window.innerHeight
- - (menuTop + submenuNode.offsetHeight));
- if (heightDiff < 0)
- menuTop += heightDiff;
-
- var menuLeft = parentNode.offsetWidth - 3;
- if (window.innerWidth
- < (menuLeft + submenuNode.offsetWidth
- + parentNode.cascadeLeftOffset()))
- menuLeft = - submenuNode.offsetWidth + 3;
-
- parentNode.setAttribute('onmousemove', 'checkDropDown(event);');
- node.setAttribute('class', 'submenu-selected');
- submenuNode.setStyle({ top: menuTop + "px",
- left: menuLeft + "px",
- visibility: "visible" });
- }
-}
-
-function checkDropDown(event) {
- var parentMenu = getParentMenu(event.target);
- var submenuItem = parentMenu.submenuItem;
- if (submenuItem) {
- var menuX = event.clientX - parentMenu.cascadeLeftOffset();
- var menuY = event.clientY - parentMenu.cascadeTopOffset();
- var itemX = submenuItem.offsetLeft;
- var itemY = submenuItem.offsetTop - 75;
-
- if (menuX >= itemX
- && menuX < itemX + submenuItem.offsetWidth
- && (menuY < itemY
- || menuY > (itemY + submenuItem.offsetHeight))) {
- hideMenu(parentMenu.submenu);
- parentMenu.submenu = null;
- parentMenu.submenuItem = null;
- parentMenu.setAttribute('onmousemove', null);
}
+ str += "--\n";
+
+ return str;
+}
+
+function popupSubmenu(event) {
+ if (this.submenu && this.submenu != "") {
+ var submenuNode = $(this.submenu);
+ var parentNode = getParentMenu(this);
+ if (parentNode.submenu)
+ hideMenu(parentNode.submenu);
+ submenuNode.parentMenuItem = this;
+ submenuNode.parentMenu = parentNode;
+ parentNode.submenuItem = this;
+ parentNode.submenu = submenuNode;
+
+ if (submenuNode.prepareVisibility)
+ submenuNode.prepareVisibility();
+
+ var menuTop = (parentNode.offsetTop - 1
+ + this.offsetTop);
+
+ if (window.height()
+ < (menuTop + submenuNode.offsetHeight))
+ if (submenuNode.offsetHeight < window.height())
+ menuTop = window.height() - submenuNode.offsetHeight;
+ else
+ menuTop = 0;
+
+ var menuLeft = (parentNode.offsetLeft + parentNode.offsetWidth - 3);
+ if (window.width()
+ < (menuLeft + submenuNode.offsetWidth))
+ menuLeft = parentNode.offsetLeft - submenuNode.offsetWidth + 3;
+
+ this.mouseInside = true;
+ this.observe("mouseover", onMouseEnteredSubmenu);
+ submenuNode.observe("mouseover", onMouseEnteredSubmenu);
+ this.observe("mouseout", onMouseLeftSubmenu);
+ submenuNode.observe("mouseout", onMouseLeftSubmenu);
+ parentNode.observe("mouseover", onMouseEnteredParentMenu);
+ $(this).addClassName("submenu-selected");
+ submenuNode.setStyle({ top: menuTop + "px",
+ left: menuLeft + "px",
+ visibility: "visible" });
+ preventDefault(event);
}
}
+function onMouseEnteredParentMenu(event) {
+ if (this.submenuItem && !this.submenuItem.mouseInside)
+ hideMenu(this.submenu);
+}
+
+function onMouseEnteredSubmenu(event) {
+ $(this).mouseInside = true;
+}
+
+function onMouseLeftSubmenu(event) {
+ $(this).mouseInside = false;
+}
+
/* search field */
function popupSearchMenu(event) {
var menuId = this.getAttribute("menuid");
var popup = $(menuId);
offset = Position.positionedOffset(this);
popup.setStyle({ top: this.offsetHeight + "px",
- left: (offset[0] + 3) + "px",
- visibility: "visible" });
+ left: (offset[0] + 3) + "px",
+ visibility: "visible" });
document.currentPopupMenu = popup;
- Event.observe(document.body, "click", onBodyClickMenuHandler);
+ $(document.body).observe("click", onBodyClickMenuHandler);
}
}
var searchValue = $("searchValue");
var searchCriteria = $("searchCriteria");
- searchValue.setAttribute("ghost-phrase", this.innerHTML);
+ searchValue.ghostPhrase = this.innerHTML;
searchCriteria.value = this.getAttribute('id');
+
+ if (this.parentNode.chosenNode)
+ this.parentNode.chosenNode.removeClassName("_chosen");
+ this.addClassName("_chosen");
+ this.parentNode.chosenNode = this;
}
function checkSearchValue(event) {
- var form = event.target;
var searchValue = $("searchValue");
- var ghostPhrase = searchValue.getAttribute('ghost-phrase');
- if (searchValue.value == ghostPhrase)
+ if (searchValue.value == searchValue.ghostPhrase)
searchValue.value = "";
}
-function onSearchChange() {
- log ("onSearchChange()...");
-}
-
function configureSearchField() {
- var searchValue = $("searchValue");
+ var searchValue = $("searchValue");
+ var searchOptions = $("searchOptions");
- if (!searchValue) return;
+ if (!searchValue) return;
- Event.observe(searchValue, "mousedown",
- onSearchMouseDown.bindAsEventListener(searchValue));
- Event.observe(searchValue, "click",
- popupSearchMenu.bindAsEventListener(searchValue));
- Event.observe(searchValue, "blur",
- onSearchBlur.bindAsEventListener(searchValue));
- Event.observe(searchValue, "focus",
- onSearchFocus.bindAsEventListener(searchValue));
- Event.observe(searchValue, "keydown",
- onSearchKeyDown.bindAsEventListener(searchValue));
+ searchValue.observe("click", popupSearchMenu);
+ searchValue.observe("blur", onSearchBlur);
+ searchValue.observe("focus", onSearchFocus);
+ searchValue.observe("keydown", onSearchKeyDown);
+ searchValue.observe("mousedown", onSearchMouseDown);
+
+ if (!searchOptions) return;
+
+ // Set the checkmark to the first option
+ var firstOption = searchOptions.down('li');
+ firstOption.addClassName("_chosen");
+ searchOptions.chosenNode = firstOption;
}
function onSearchMouseDown(event) {
- var superNode = this.parentNode.parentNode.parentNode;
- relX = (Event.pointerX(event) - superNode.offsetLeft - this.offsetLeft);
- relY = (Event.pointerY(event) - superNode.offsetTop - this.offsetTop);
+ var superNode = this.parentNode.parentNode.parentNode;
+ relX = (Event.pointerX(event) - superNode.offsetLeft - this.offsetLeft);
+ relY = (Event.pointerY(event) - superNode.offsetTop - this.offsetTop);
- if (relY < 24) {
- event.cancelBubble = true;
- event.returnValue = false;
- }
+ if (relY < 24) {
+ event.cancelBubble = true;
+ event.returnValue = false;
+ }
}
function onSearchFocus() {
- ghostPhrase = this.getAttribute("ghost-phrase");
+ ghostPhrase = this.ghostPhrase;
if (this.value == ghostPhrase) {
this.value = "";
this.setAttribute("modified", "");
}
function onSearchBlur(event) {
- var ghostPhrase = this.getAttribute("ghost-phrase");
- //log ("search blur: '" + this.value + "'");
- if (!this.value) {
+ if (!this.value) {
this.setAttribute("modified", "");
this.setStyle({ color: "#aaa" });
- this.value = ghostPhrase;
- refreshCurrentFolder();
- } else if (this.value == ghostPhrase) {
+ this.value = this.ghostPhrase;
+ search["value"] = "";
+ if (searchValue.lastSearch != "") {
+ searchValue.lastSearch = "";
+ refreshCurrentFolder();
+ }
+ } else if (this.value == this.ghostPhrase) {
this.setAttribute("modified", "");
this.setStyle({ color: "#aaa" });
} else {
if (this.timer)
clearTimeout(this.timer);
- this.timer = setTimeout("onSearchFormSubmit()", 1000);
+ if (event.keyCode == 13) {
+ onSearchFormSubmit();
+ preventDefault(event);
+ }
+ else
+ this.timer = setTimeout("onSearchFormSubmit()", 1000);
}
function onSearchFormSubmit(event) {
- var searchValue = $("searchValue");
- var searchCriteria = $("searchCriteria");
- var ghostPhrase = searchValue.getAttribute('ghost-phrase');
-
- if (searchValue.value == ghostPhrase) return;
-
- search["criteria"] = searchCriteria.value;
- search["value"] = searchValue.value;
-
- refreshCurrentFolder();
+ var searchValue = $("searchValue");
+ var searchCriteria = $("searchCriteria");
+
+ if (searchValue.value != searchValue.ghostPhrase
+ && searchValue.value != searchValue.lastSearch) {
+ search["criteria"] = searchCriteria.value;
+ search["value"] = searchValue.value;
+ searchValue.lastSearch = searchValue.value;
+ refreshCurrentFolder();
+ }
}
function initCriteria() {
var searchCriteria = $("searchCriteria");
var searchValue = $("searchValue");
- if (!searchValue) return;
-
- var searchOptions = $("searchOptions").childNodesWithTag("li");
- if (searchOptions.length > 0) {
- var firstChild = searchOptions[0];
- searchCriteria.value = $(firstChild).getAttribute('id');
- searchValue.setAttribute('ghost-phrase', firstChild.innerHTML);
- if (searchValue.value == '') {
- searchValue.value = firstChild.innerHTML;
- searchValue.setAttribute("modified", "");
- searchValue.setStyle({ color: "#aaa" });
+ if (searchValue) {
+ var searchOptions = $("searchOptions").childNodesWithTag("li");
+ if (searchOptions.length > 0) {
+ var firstChild = searchOptions[0];
+ searchCriteria.value = $(firstChild).getAttribute('id');
+ searchValue.ghostPhrase = firstChild.innerHTML;
+ searchValue.lastSearch = "";
+ if (searchValue.value == '') {
+ searchValue.value = firstChild.innerHTML;
+ searchValue.setAttribute("modified", "");
+ searchValue.setStyle({ color: "#aaa" });
+ }
}
}
}
/* toolbar buttons */
function popupToolbarMenu(node, menuId) {
- if (document.currentPopupMenu)
- hideMenu(document.currentPopupMenu);
+ if (document.currentPopupMenu)
+ hideMenu(document.currentPopupMenu);
- var popup = $(menuId);
- var top = ($(node).getStyle('top') || 0) + node.offsetHeight - 2;
- popup.setStyle({ top: top + "px",
- left: $(node).cascadeLeftOffset() + "px",
- visibility: "visible" });
+ var popup = $(menuId);
+ var top = ($(node).getStyle('top') || 0) + node.offsetHeight - 2;
+ popup.setStyle({ top: top + "px",
+ left: $(node).cascadeLeftOffset() + "px",
+ visibility: "visible" });
- document.currentPopupMenu = popup;
- Event.observe(document.body, "click", onBodyClickMenuHandler);
+ document.currentPopupMenu = popup;
+ $(document.body).observe("click", onBodyClickMenuHandler);
}
/* contact selector */
function folderSubscriptionCallback(http) {
- if (http.readyState == 4) {
- if (isHttpStatus204(http.status)) {
- if (http.callbackData)
- http.callbackData["method"](http.callbackData["data"]);
- }
- else
- window.alert(clabels["Unable to subscribe to that folder!"].decodeEntities());
- document.subscriptionAjaxRequest = null;
- }
- else
- log ("folderSubscriptionCallback Ajax error");
+ if (http.readyState == 4) {
+ if (isHttpStatus204(http.status)) {
+ if (http.callbackData)
+ http.callbackData["method"](http.callbackData["data"]);
+ }
+ else
+ window.alert(clabels["Unable to subscribe to that folder!"]);
+ document.subscriptionAjaxRequest = null;
+ }
+ else
+ log ("folderSubscriptionCallback Ajax error");
}
function subscribeToFolder(refreshCallback, refreshCallbackData) {
- var folderData = refreshCallbackData["folder"].split(":");
- var username = folderData[0];
- var folderPath = folderData[1];
- if (username != UserLogin) {
- var url = (UserFolderURL + "../" + username
- + folderPath + "/subscribe");
- if (document.subscriptionAjaxRequest) {
- document.subscriptionAjaxRequest.aborted = true;
- document.subscriptionAjaxRequest.abort();
- }
- var rfCbData = { method: refreshCallback, data: refreshCallbackData };
- document.subscriptionAjaxRequest = triggerAjaxRequest(url,
- folderSubscriptionCallback,
- rfCbData);
- }
- else
- refreshCallbackData["window"].alert(clabels["You cannot subscribe to a folder that you own!"]
- .decodeEntities());
+ var folderData = refreshCallbackData["folder"].split(":");
+ var username = folderData[0];
+ var folderPath = folderData[1];
+ if (username != UserLogin) {
+ var url = (UserFolderURL + "../" + username
+ + folderPath + "/subscribe");
+ if (document.subscriptionAjaxRequest) {
+ document.subscriptionAjaxRequest.aborted = true;
+ document.subscriptionAjaxRequest.abort();
+ }
+
+ var rfCbData = { method: refreshCallback, data: refreshCallbackData };
+ document.subscriptionAjaxRequest = triggerAjaxRequest(url,
+ folderSubscriptionCallback,
+ rfCbData);
+ }
+ else
+ refreshCallbackData["window"].alert(clabels["You cannot subscribe to a folder that you own!"]);
}
function folderUnsubscriptionCallback(http) {
- if (http.readyState == 4) {
- if (isHttpStatus204(http.status)) {
- if (http.callbackData)
- http.callbackData["method"](http.callbackData["data"]);
- }
- else
- window.alert(clabels["Unable to unsubscribe from that folder!"].decodeEntities());
- document.unsubscriptionAjaxRequest = null;
- }
+ if (http.readyState == 4) {
+ removeFolderRequestCount--;
+ if (isHttpStatus204(http.status)) {
+ if (http.callbackData)
+ http.callbackData["method"](http.callbackData["data"]);
+ }
+ else
+ window.alert(clabels["Unable to unsubscribe from that folder!"]);
+ }
}
function unsubscribeFromFolder(folder, refreshCallback, refreshCallbackData) {
- if (document.body.hasClassName("popup")) {
- window.opener.unsubscribeFromFolder(folder, refreshCallback,
- refreshCallbackData);
- }
- else {
- var folderData = folder.split(":");
- var username = folderData[0];
- var folderPath = folderData[1];
- if (username != UserLogin) {
- var url = (UserFolderURL + "../" + username
- + "/" + folderPath + "/unsubscribe");
- if (document.unsubscriptionAjaxRequest) {
- document.unsubscriptionAjaxRequest.aborted = true;
- document.unsubscriptionAjaxRequest.abort();
- }
- var rfCbData = { method: refreshCallback, data: refreshCallbackData };
- document.unsubscriptionAjaxRequest
- = triggerAjaxRequest(url, folderUnsubscriptionCallback,
- rfCbData);
- }
- else
- window.alert(clabels["You cannot unsubscribe from a folder that you own!"].decodeEntities());
- }
+ if (document.body.hasClassName("popup")) {
+ window.opener.unsubscribeFromFolder(folder, refreshCallback,
+ refreshCallbackData);
+ }
+ else {
+ var folderData = folder.split("_");
+ var username = folderData[0];
+ var folderPath = folderData[1];
+ if (username.startsWith('/'))
+ username = username.substring(1);
+ if (username != UserLogin) {
+ var url = (ApplicationBaseURL + folder + "/unsubscribe");
+ removeFolderRequestCount++;
+ var rfCbData = { method: refreshCallback, data: refreshCallbackData };
+ triggerAjaxRequest(url, folderUnsubscriptionCallback, rfCbData);
+ }
+ else
+ window.alert(clabels["You cannot unsubscribe from a folder that you own!"]);
+ }
+}
+
+function accessToSubscribedFolder(serverFolder) {
+ var folder;
+
+ var parts = serverFolder.split(":");
+ if (parts.length > 1) {
+ var paths = parts[1].split("/");
+ folder = "/" + parts[0] + "_" + paths[2];
+ }
+ else
+ folder = serverFolder;
+
+ return folder;
+}
+
+function getSubscribedFolderOwner(serverFolder) {
+ var owner;
+
+ var parts = serverFolder.split(":");
+ if (parts.length > 1) {
+ owner = parts[0];
+ }
+
+ return owner;
+}
+
+function getListIndexForFolder(items, owner, folderName) {
+ var i;
+ var previousOwner = null;
+
+ for (var i = 0; i < items.length; i++) {
+ var currentFolderName = items[i].lastChild.nodeValue.strip();
+ var currentOwner = items[i].readAttribute('owner');
+ if (currentOwner == owner) {
+ previousOwner = currentOwner;
+ if (currentFolderName > folderName)
+ break;
+ }
+ else if (previousOwner ||
+ (currentOwner != UserLogin && currentOwner > owner))
+ break;
+ else if (currentOwner == "nobody")
+ break;
+ }
+
+ return i;
}
function listRowMouseDownHandler(event) {
- preventDefault(event);
+ preventDefault(event);
+ //Event.stop(event);
}
/* tabs */
firstTab = null;
for (var i = 0; i < nodes.length; i++) {
- var currentNode = nodes[i];
- if (currentNode.tagName == 'LI') {
- if (!firstTab)
- firstTab = i;
- Event.observe(currentNode, "mousedown",
- onTabMouseDown.bindAsEventListener(currentNode));
- Event.observe(currentNode, "click",
- onTabClick.bindAsEventListener(currentNode));
- //$(currentNode.getAttribute("target")).hide();
- }
+ var currentNode = nodes[i];
+ if (currentNode.tagName == 'LI') {
+ if (!firstTab)
+ firstTab = i;
+ $(currentNode).observe("mousedown", onTabMouseDown);
+ $(currentNode).observe("click", onTabClick);
+ //$(currentNode.getAttribute("target")).hide();
+ }
}
nodes[firstTab].addClassName("first");
}
function initMenus() {
- var menus = getMenus();
- if (menus) {
- for (var menuID in menus) {
- var menuDIV = $(menuID);
- if (menuDIV)
- initMenu(menuDIV, menus[menuID]);
- }
- }
+ var menus = getMenus();
+ if (menus) {
+ for (var menuID in menus) {
+ var menuDIV = $(menuID);
+ if (menuDIV)
+ initMenu(menuDIV, menus[menuID]);
+ }
+ }
}
function initMenu(menuDIV, callbacks) {
- var lis = $(menuDIV.childNodesWithTag("ul")[0]).childNodesWithTag("li");
- for (var j = 0; j < lis.length; j++) {
- var node = $(lis[j]);
- Event.observe(node, "mousedown", listRowMouseDownHandler, false);
- var callback = callbacks[j];
- if (callback) {
- if (typeof(callback) == "string") {
- if (callback == "-")
- node.addClassName("separator");
- else {
- node.submenu = callback;
- node.addClassName("submenu");
- Event.observe(node, "mouseover", dropDownSubmenu);
- }
- }
- else
- Event.observe(node, "mouseup",
- $(callback).bindAsEventListener(node));
+ var lis = $(menuDIV.down("ul")).childNodesWithTag("li");
+ for (var j = 0; j < lis.length; j++) {
+ var node = $(lis[j]);
+ node.observe("mousedown", listRowMouseDownHandler, false);
+ var callback = callbacks[j];
+ if (callback) {
+ if (typeof(callback) == "string") {
+ if (callback == "-")
+ node.addClassName("separator");
+ else {
+ node.submenu = callback;
+ node.addClassName("submenu");
+ node.observe("mouseover", popupSubmenu);
+ }
}
- else
- node.addClassName("disabled");
- }
+ else {
+ node.observe("mouseup", onBodyClickMenuHandler);
+ node.observe("click", callback);
+ }
+ }
+ else
+ node.addClassName("disabled");
+ }
}
function onTabMouseDown(event) {
}
function getUsersRightsWindowHeight() {
- return usersRightsWindowHeight;
+ return usersRightsWindowHeight;
}
function getUsersRightsWindowWidth() {
- return usersRightsWindowWidth;
+ return usersRightsWindowWidth;
}
function getTopWindow() {
- var topWindow = null;
- var currentWindow = window;
- while (!topWindow) {
- if (currentWindow.document.body.hasClassName("popup")
- && currentWindow.opener)
- currentWindow = currentWindow.opener;
- else
- topWindow = currentWindow;
- }
+ var topWindow = null;
+ var currentWindow = window;
+ while (!topWindow) {
+ if (currentWindow.document.body.hasClassName("popup")
+ && currentWindow.opener)
+ currentWindow = currentWindow.opener;
+ else
+ topWindow = currentWindow;
+ }
- return topWindow;
+ return topWindow;
}
function onTabClick(event) {
var currentValue = number;
var index = 0;
while (currentValue) {
- if (currentValue & 1)
- colorTable[index]++;
- if (index == 3)
- index = 0;
- currentValue >>= 1;
- index++;
+ if (currentValue & 1)
+ colorTable[index]++;
+ if (index == 3)
+ index = 0;
+ currentValue >>= 1;
+ index++;
}
color = ("#"
}
function loadPreferences() {
- var url = UserFolderURL + "jsonDefaults";
- var http = createHTTPClient();
- http.open("GET", url, false);
- http.send("");
- if (http.status == 200)
+ var url = UserFolderURL + "jsonDefaults";
+ var http = createHTTPClient();
+ http.open("GET", url, false);
+ http.send("");
+ if (http.status == 200) {
+ if (http.responseText.length > 0)
userDefaults = http.responseText.evalJSON(true);
+ else
+ userDefaults = {};
+ }
- url = UserFolderURL + "jsonSettings";
- http.open("GET", url, false);
- http.send("");
- if (http.status == 200)
+ url = UserFolderURL + "jsonSettings";
+ http.open("GET", url, false);
+ http.send("");
+ if (http.status == 200) {
+ if (http.responseText.length > 0)
userSettings = http.responseText.evalJSON(true);
+ else
+ userSettings = {};
+ }
}
function onLoadHandler(event) {
- if (!document.body.hasClassName("loginPage")) {
- loadPreferences();
- }
- queryParameters = parseQueryParameters('' + window.location);
- if (!$(document.body).hasClassName("popup")) {
- initLogConsole();
- }
- initCriteria();
- configureSearchField();
- initMenus();
- initTabs();
- configureDragHandles();
- configureSortableTableHeaders();
- configureLinkBanner();
- var progressImage = $("progressIndicator");
- if (progressImage)
- progressImage.parentNode.removeChild(progressImage);
- Event.observe(document.body, "contextmenu", onBodyClickContextMenu);
+ if (typeof UserLogin != "undefined")
+ loadPreferences();
+ queryParameters = parseQueryParameters('' + window.location);
+ if (!$(document.body).hasClassName("popup")) {
+ initLogConsole();
+ }
+ initCriteria();
+ configureSearchField();
+ initMenus();
+ initTabs();
+ configureDragHandles();
+ configureLinkBanner();
+ var progressImage = $("progressIndicator");
+ if (progressImage)
+ progressImage.parentNode.removeChild(progressImage);
+ $(document.body).observe("contextmenu", onBodyClickContextMenu);
}
function onBodyClickContextMenu(event) {
- preventDefault(event);
+ preventDefault(event);
}
-function configureSortableTableHeaders() {
- var headers = document.getElementsByClassName("sortableTableHeader");
- for (var i = 0; i < headers.length; i++) {
- var header = headers[i];
- var anchor = $(header).childNodesWithTag("a")[0];
- if (anchor)
- Event.observe(anchor, "click",
- onHeaderClick.bindAsEventListener(anchor));
- }
+function configureSortableTableHeaders(table) {
+ var headers = $(table).getElementsByClassName("sortableTableHeader");
+ for (var i = 0; i < headers.length; i++) {
+ var header = headers[i];
+ $(header).observe("click", onHeaderClick);
+ }
}
function onLinkBannerClick() {
}
function onPreferencesClick(event) {
- var urlstr = UserFolderURL + "preferences";
- var w = window.open(urlstr, "User Preferences",
- "width=430,height=250,resizable=0,scrollbars=0");
- w.opener = window;
- w.focus();
+ var urlstr = UserFolderURL + "preferences";
+ var w = window.open(urlstr, "_blank",
+ "width=430,height=250,resizable=0,scrollbars=0,location=0");
+ w.opener = window;
+ w.focus();
- preventDefault(event);
+ preventDefault(event);
}
function configureLinkBanner() {
var linkBanner = $("linkBanner");
if (linkBanner) {
- var anchors = linkBanner.childNodesWithTag("a");
- for (var i = 1; i < 3; i++) {
- Event.observe(anchors[i], "mousedown", listRowMouseDownHandler);
- Event.observe(anchors[i], "click", onLinkBannerClick);
+ var moduleLinks = [ "calendar", "contacts", "mail" ];
+ for (var i = 0; i < moduleLinks.length; i++) {
+ var link = $(moduleLinks[i] + "BannerLink");
+ if (link) {
+ link.observe("mousedown", listRowMouseDownHandler);
+ link.observe("click", onLinkBannerClick);
+ }
+ }
+ link = $("preferencesBannerLink");
+ if (link) {
+ link.observe("mousedown", listRowMouseDownHandler);
+ link.observe("click", onPreferencesClick);
+ }
+ link = $("consoleBannerLink");
+ if (link) {
+ link.observe("mousedown", listRowMouseDownHandler);
+ link.observe("click", toggleLogConsole);
}
- Event.observe(anchors[4], "mousedown", listRowMouseDownHandler);
- Event.observe(anchors[4], "click", onPreferencesClick);
- if (anchors.length > 5)
- Event.observe(anchors[5], "click", toggleLogConsole);
}
}
-addEvent(window, 'load', onLoadHandler);
+/* folder creation */
+function createFolder(name, okCB, notOkCB) {
+ if (name) {
+ if (document.newFolderAjaxRequest) {
+ document.newFolderAjaxRequest.aborted = true;
+ document.newFolderAjaxRequest.abort();
+ }
+ var url = ApplicationBaseURL + "/createFolder?name=" + name;
+ document.newFolderAjaxRequest
+ = triggerAjaxRequest(url, createFolderCallback,
+ {name: name,
+ okCB: okCB,
+ notOkCB: notOkCB});
+ }
+}
+
+function createFolderCallback(http) {
+ if (http.readyState == 4) {
+ var data = http.callbackData;
+ if (http.status == 201) {
+ if (data.okCB)
+ data.okCB(data.name, "/" + http.responseText, UserLogin);
+ }
+ else {
+ if (data.notOkCB)
+ data.notOkCB(name);
+ else
+ log("ajax problem:" + http.status);
+ }
+ }
+}
+
+function onFinalLoadHandler(event) {
+ var safetyNet = $("javascriptSafetyNet");
+ if (safetyNet)
+ safetyNet.parentNode.removeChild(safetyNet);
+}
+
+FastInit.addOnLoad(onLoadHandler);
function parent$(element) {
- return this.opener.document.getElementById(element);
+ return this.opener.document.getElementById(element);
}
/* stubs */
}
function onHeaderClick(event) {
- window.alert("generic headerClick");
+ window.alert("generic headerClick");
}