var activeAjaxRequests = 0;
var menus = new Array();
+var search = {};
+var sorting = {};
var weekStartIsMonday = true;
// logArea = null;
var allDocumentElements = null;
+var userDefaults = null;
+var userSettings = null;
+
/* 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);
+
+ return $(newElement);
+}
+
function ml_stripActionInURL(url) {
if (url[url.length - 1] != '/') {
var i;
var url;
if (folderInfos.length > 1) {
url = UserFolderURL + "../" + folderInfos[0];
- if (folderInfos[1][0] != '/')
+ if (!folderInfos[1].startsWith('/'))
url += '/';
url += folderInfos[1];
}
function openUserFolderSelector(callback, type) {
var urlstr = ApplicationBaseURL;
- if (urlstr[urlstr.length-1] != '/')
+ if (! urlstr.endsWith('/'))
urlstr += '/';
urlstr += ("../../" + UserLogin + "/Contacts/userFolders");
- var w = window.open(urlstr, "User Selector",
+ var w = window.open(urlstr, "_blank",
"width=322,height=250,resizable=1,scrollbars=0");
w.opener = window;
- w.userFolderCallback = callback;
- w.userFolderType = type;
+ window.userFolderCallback = callback;
+ window.userFolderType = type;
w.focus();
}
-function openMailComposeWindow(url) {
- var w = window.open(url, null,
+function openContactWindow(url, wId) {
+ if (!wId)
+ wId = "" + (new Date().getTime());
+ var w = window.open(url, wId,
+ "width=450,height=600,resizable=0");
+ w.focus();
+
+ return w;
+}
+
+function openMailComposeWindow(url, wId) {
+ if (!wId)
+ wId = "" + (new Date().getTime());
+ var w = window.open(url, wId,
"width=680,height=520,resizable=1,scrollbars=1,toolbar=0,"
+ "location=0,directories=0,status=0,menubar=0"
+ ",copyhistory=0");
// http://developer.apple.com/internet/webcontent/xmlhttpreq.html
if (typeof XMLHttpRequest != "undefined")
return new XMLHttpRequest();
-
+
try { return new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e) { }
try { return new ActiveXObject("Microsoft.XMLHTTP"); }
return http;
}
+function startAnimation(parent, nextNode) {
+ var anim = document.createElement("img");
+ anim = $(anim);
+ anim.id = "progressIndicator";
+ anim.src = ResourcesURL + "/busy.gif";
+ anim.setStyle({ visibility: "hidden" });
+ if (nextNode)
+ parent.insertBefore(anim, nextNode);
+ else
+ parent.appendChild(anim);
+ anim.setStyle({ visibility: "visible" });
+
+ return anim;
+}
+
function checkAjaxRequestsState() {
var toolbar = document.getElementById("toolbar");
if (toolbar) {
if (activeAjaxRequests > 0
&& !document.busyAnim) {
- var anim = document.createElement("img");
- anim = $(anim);
- document.busyAnim = anim;
- anim.id = "progressIndicator";
- anim.src = ResourcesURL + "/busy.gif";
- anim.setStyle({ visibility: "hidden" });
- toolbar.appendChild(anim);
- anim.setStyle({ visibility: "visible" });
+ document.busyAnim = startAnimation(toolbar);
}
else if (activeAjaxRequests == 0
&& document.busyAnim
document.menuTarget = target;
if (document.currentPopupMenu)
- hideMenu(event, document.currentPopupMenu);
+ hideMenu(document.currentPopupMenu);
var popup = $(menuId);
- var menuTop = event.pageY;
- var menuLeft = event.pageX;
+ var menuTop = Event.pointerY(event);
+ var menuLeft = Event.pointerX(event);
var heightDiff = (window.innerHeight
- (menuTop + popup.offsetHeight));
if (heightDiff < 0)
visibility: "visible" });
document.currentPopupMenu = popup;
+
Event.observe(document.body, "click", onBodyClickMenuHandler);
preventDefault(event);
function onBodyClickMenuHandler(event) {
document.body.menuTarget = null;
- hideMenu(event, document.currentPopupMenu);
+ hideMenu(document.currentPopupMenu);
Event.stopObserving(document.body, "click", onBodyClickMenuHandler);
preventDefault(event);
}
-function hideMenu(event, menuNode) {
+function hideMenu(menuNode) { //log ("hideMenu");
var onHide;
-// log('hiding menu "' + menuNode.getAttribute('id') + '"');
if (menuNode.submenu) {
- hideMenu(event, menuNode.submenu);
+ hideMenu(menuNode.submenu);
menuNode.submenu = null;
}
menuNode.parentMenu = null;
}
- if (document.initEvent) {
- var onhideEvent = document.createEvent("UIEvents");
- onhideEvent.initEvent("hideMenu", false, true);
+ 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) {
- // TODO: add support for IE
+ else if (document.createEventObject) { // IE
+ menuNode.fireEvent("onmousedown");
}
}
var submenuNode = $(this.submenu);
var parentNode = getParentMenu(node);
if (parentNode.submenu)
- hideMenu(event, parentNode.submenu);
+ hideMenu(parentNode.submenu);
submenuNode.parentMenuItem = node;
submenuNode.parentMenu = parentNode;
parentNode.submenuItem = node;
&& menuX < itemX + submenuItem.offsetWidth
&& (menuY < itemY
|| menuY > (itemY + submenuItem.offsetHeight))) {
- hideMenu(event, parentMenu.submenu);
+ hideMenu(parentMenu.submenu);
parentMenu.submenu = null;
parentMenu.submenuItem = null;
parentMenu.setAttribute('onmousemove', null);
/* search field */
function popupSearchMenu(event) {
- var node = getTarget(event);
-
var menuId = this.getAttribute("menuid");
- relX = event.pageX - node.cascadeLeftOffset();
- relY = event.pageY - node.cascadeTopOffset();
+ var offset = Position.cumulativeOffset(this);
+
+ relX = Event.pointerX(event) - offset[0];
+ relY = Event.pointerY(event) - offset[1];
if (event.button == 0
&& relX < 24) {
event.returnValue = false;
if (document.currentPopupMenu)
- hideMenu(event, document.currentPopupMenu);
+ hideMenu(document.currentPopupMenu);
- var popup = document.getElementById(menuId);
- popup.setStyle({ top: node.offsetHeight + "px",
- left: (node.offsetLeft + 3) + "px",
+ var popup = $(menuId);
+ offset = Position.positionedOffset(this);
+ popup.setStyle({ top: this.offsetHeight + "px",
+ left: (offset[0] + 3) + "px",
visibility: "visible" });
document.currentPopupMenu = popup;
}
function setSearchCriteria(event) {
- searchValue = $("searchValue");
- searchCriteria = $("searchCriteria");
+ var searchValue = $("searchValue");
+ var searchCriteria = $("searchCriteria");
searchValue.setAttribute("ghost-phrase", this.innerHTML);
-// searchCriteria = this.getAttribute('id');
+ searchCriteria.value = this.getAttribute('id');
}
function checkSearchValue(event) {
log ("onSearchChange()...");
}
+function configureSearchField() {
+ var searchValue = $("searchValue");
+
+ 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));
+}
+
function onSearchMouseDown(event) {
var superNode = this.parentNode.parentNode.parentNode;
- relX = (event.pageX - superNode.offsetLeft - this.offsetLeft);
- relY = (event.pageY - superNode.offsetTop - this.offsetTop);
+ relX = (Event.pointerX(event) - superNode.offsetLeft - this.offsetLeft);
+ relY = (Event.pointerY(event) - superNode.offsetTop - this.offsetTop);
if (relY < 24) {
event.cancelBubble = true;
}
function onSearchBlur(event) {
- var ghostPhrase = this.getAttribute("ghost-phrase");
-// log ("search blur: '" + this.value + "'");
- if (!this.value) {
+ var ghostPhrase = this.getAttribute("ghost-phrase");
+ //log ("search blur: '" + this.value + "'");
+ if (!this.value) {
this.setAttribute("modified", "");
this.setStyle({ color: "#aaa" });
this.value = ghostPhrase;
+ refreshCurrentFolder();
} else if (this.value == ghostPhrase) {
this.setAttribute("modified", "");
this.setStyle({ color: "#aaa" });
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();
+}
+
function initCriteria() {
var searchCriteria = $("searchCriteria");
var searchValue = $("searchValue");
- var firstOption;
- var searchOptions = $("searchOptions");
- if (searchOptions) {
- var firstOption;
- $A(searchOptions.childNodes).each(function (item) {
- if (item.tagName == 'LI') {
- firstOption = item;
- }
- });
- searchCriteria.value = firstOption.getAttribute('id');
- searchValue.setAttribute('ghost-phrase', firstOption.innerHTML);
+ 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 = firstOption.innerHTML;
+ searchValue.value = firstChild.innerHTML;
searchValue.setAttribute("modified", "");
searchValue.setStyle({ color: "#aaa" });
}
}
/* toolbar buttons */
-function popupToolbarMenu(event, menuId) {
- var toolbar = $("toolbar");
- var node = getTarget(event);
- if (node.tagName != 'A')
- node = node.getParentWithTagName("a");
- node = node.childNodesWithTag("span")[0];
-
- if (event.button == 0) {
- event.cancelBubble = true;
- event.returnValue = false;
-
- if (document.currentPopupMenu)
- hideMenu(event, document.currentPopupMenu);
-
- var popup = document.getElementById(menuId);
- var top = node.offsetTop + node.offsetHeight - 2;
- popup.setStyle({ top: top + "px",
- left: node.cascadeLeftOffset() + "px",
- visibility: "visible" });
-
- document.currentPopupMenu = popup;
- Event.observe(document.body, "click", onBodyClickMenuHandler);
- }
+function popupToolbarMenu(node, menuId) {
+ 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" });
+
+ document.currentPopupMenu = popup;
+ Event.observe(document.body, "click", onBodyClickMenuHandler);
}
/* contact selector */
function folderSubscriptionCallback(http) {
if (http.readyState == 4) {
- if (http.status == 204) {
+ if (isHttpStatus204(http.status)) {
if (http.callbackData)
http.callbackData["method"](http.callbackData["data"]);
}
else
- window.alert(labels["Unable to subscribe to that folder!"].decodeEntities());
+ window.alert(clabels["Unable to subscribe to that folder!"].decodeEntities());
document.subscriptionAjaxRequest = null;
}
else
- log ("ajax fuckage");
+ log ("folderSubscriptionCallback Ajax error");
}
function subscribeToFolder(refreshCallback, refreshCallbackData) {
rfCbData);
}
else
- window.alert(labels["You cannot subscribe to a folder that you own!"]
+ refreshCallbackData["window"].alert(clabels["You cannot subscribe to a folder that you own!"]
.decodeEntities());
}
function folderUnsubscriptionCallback(http) {
if (http.readyState == 4) {
- if (http.status == 204) {
+ if (isHttpStatus204(http.status)) {
if (http.callbackData)
http.callbackData["method"](http.callbackData["data"]);
}
else
- window.alert(labels["Unable to unsubscribe from that folder!"].decodeEntities());
+ window.alert(clabels["Unable to unsubscribe from that folder!"].decodeEntities());
document.unsubscriptionAjaxRequest = null;
}
}
rfCbData);
}
else
- window.alert(labels["You cannot unsubscribe from a folder that you own!"].decodeEntities());
+ window.alert(clabels["You cannot unsubscribe from a folder that you own!"].decodeEntities());
}
}
function listRowMouseDownHandler(event) {
- preventDefault(event);
+ preventDefault(event);
}
/* tabs */
function initMenu(menuDIV, callbacks) {
var lis = $(menuDIV.childNodesWithTag("ul")[0]).childNodesWithTag("li");
for (var j = 0; j < lis.length; j++) {
- var node = lis[j];
+ var node = $(lis[j]);
Event.observe(node, "mousedown", listRowMouseDownHandler, false);
var callback = callbacks[j];
if (callback) {
return color;
}
+function loadPreferences() {
+ var url = UserFolderURL + "jsonDefaults";
+ var http = createHTTPClient();
+ http.open("GET", url, false);
+ http.send("");
+ if (http.status == 200)
+ userDefaults = http.responseText.evalJSON(true);
+
+ url = UserFolderURL + "jsonSettings";
+ http.open("GET", url, false);
+ http.send("");
+ if (http.status == 200)
+ userSettings = http.responseText.evalJSON(true);
+}
+
function onLoadHandler(event) {
- queryParameters = parseQueryParameters('' + window.location);
- if (!$(document.body).hasClassName("popup")) {
- initLogConsole();
- initCriteria();
- }
- initMenus();
- initTabs();
- configureDragHandles();
- configureSortableTableHeaders();
- configureLinkBanner();
- var progressImage = $("progressIndicator");
- if (progressImage)
- progressImage.parentNode.removeChild(progressImage);
- Event.observe(document.body, "contextmenu", onBodyClickContextMenu);
+ 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);
}
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));
- }
+ 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 onLinkBannerClick() {
w.opener = window;
w.focus();
- event.preventDefault();
+ preventDefault(event);
}
function configureLinkBanner() {
var linkBanner = $("linkBanner");
if (linkBanner) {
var anchors = linkBanner.childNodesWithTag("a");
- for (var i = 0; i < 2; i++) {
+ for (var i = 1; i < 3; i++) {
Event.observe(anchors[i], "mousedown", listRowMouseDownHandler);
Event.observe(anchors[i], "click", onLinkBannerClick);
}
- Event.observe(anchors[3], "mousedown", listRowMouseDownHandler);
- Event.observe(anchors[3], "click", onPreferencesClick);
- if (anchors.length > 4)
- Event.observe(anchors[4], "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);
+function parent$(element) {
+ return this.opener.document.getElementById(element);
+}
+
/* stubs */
+function refreshCurrentFolder() {
+}
+
function configureDragHandles() {
}
function onHeaderClick(event) {
window.alert("generic headerClick");
}
-
-function parent$(element) {
- return this.opener.document.getElementById(element);
-}