running = true;
requestField = this;
requestField.setAttribute("modified", "1");
+ if (searchField) {
+ searchField.confirmedValue = null;
+ searchField.uid = null;
+ }
setTimeout("triggerRequest()", delay);
}
else if (this.confirmedValue) {
function updateResults(http) {
if (http.readyState == 4) {
+ var menu = $('attendeesMenu');
+ var list = menu.down("ul");
+
+ searchField = http.callbackData;
+ searchField.hasfreebusy = false;
+
if (http.status == 200) {
- var searchField = http.callbackData;
var start = searchField.value.length;
- var text = http.responseText.split(":");
- if (text[0].length > 0)
- searchField.uid = text[0];
- else
- searchField.uid = null;
- searchField.hasfreebusy = false;
- var completeEmail = text[1] + " <" + text[2] + ">";
- if (text[1].substring(0, searchField.value.length).toUpperCase()
- == searchField.value.toUpperCase())
- searchField.value = completeEmail;
- else {
- searchField.value += ' >> ' + completeEmail;
+ var data = http.responseText.evalJSON(true);
+ if (data.length > 1) {
+ $(list.childNodesWithTag("li")).each(function(item) {
+ item.remove();
+ });
+
+ // Populate popup menu
+ for (var i = 0; i < data.length; i++) {
+ var contact = data[i];
+ var completeEmail = contact["name"] + " <" + contact["email"] + ">";
+ var node = document.createElement("li");
+ list.appendChild(node);
+ node.uid = contact["uid"];
+ node.appendChild(document.createTextNode(completeEmail));
+ $(node).observe("mousedown", onAttendeeResultClick);
+ }
+
+ // Show popup menu
+ var offset;
+ if (isSafari())
+ offset = Position.positionedOffset(searchField);
+ else
+ offset = Position.cumulativeOffset(searchField);
+ var top = offset[1] + node.offsetHeight + 3;
+ var height = 'auto';
+ if (data.length > 5) {
+ height = 5 * node.getHeight() + 'px';
+ }
+ menu.setStyle({ top: top + "px",
+ left: offset[0] + "px",
+ height: height,
+ visibility: "visible" });
+ menu.scrollTop = 0;
+
+ document.currentPopupMenu = menu;
+ $(document.body).observe("click", onBodyClickMenuHandler);
}
- searchField.confirmedValue = completeEmail;
- if (searchField.focussed) {
- var end = searchField.value.length;
- $(searchField).selectText(start, end);
+ else {
+ if (document.currentPopupMenu)
+ hideMenu(document.currentPopupMenu);
+
+ if (data.length == 1) {
+ var contact = data[0];
+ if (contact["uid"].length > 0)
+ searchField.uid = contact["uid"];
+ else
+ searchField.uid = null;
+ var completeEmail = contact["name"] + " <" + contact["email"] + ">";
+ if (contact["name"].substring(0, searchField.value.length).toUpperCase()
+ == searchField.value.toUpperCase())
+ searchField.value = completeEmail;
+ else {
+ searchField.value += ' >> ' + completeEmail;
+ }
+ searchField.confirmedValue = completeEmail;
+ if (searchField.focussed) {
+ var end = searchField.value.length;
+ $(searchField).selectText(start, end);
+ }
+ else
+ searchField.value = contact["name"];
+ }
}
- else
- searchField.value = text[1];
}
+ else
+ if (document.currentPopupMenu)
+ hideMenu(document.currentPopupMenu);
running = false;
document.contactLookupAjaxRequest = null;
}
}
+function onAttendeeResultClick(event) {
+ if (searchField) {
+ searchField.uid = this.uid;
+ searchField.value = this.firstChild.nodeValue.trim();
+ searchField.confirmedValue = searchField.value;
+ searchField.blur(); // triggers checkAttendee function call
+ }
+}
+
function UIDLookupCallback(http) {
if (http.readyState == 4) {
if (http.status == 200) {
var input = $(newRow.cells[0]).childNodesWithTag("input")[0];
input.setAttribute("autocomplete", "off");
- Event.observe(input, "blur", checkAttendee.bindAsEventListener(input));
Event.observe(input, "keydown", onContactKeydown.bindAsEventListener(input));
+ Event.observe(input, "blur", checkAttendee.bindAsEventListener(input));
input.focussed = true;
input.activate();
}
function checkAttendee() {
+ if (document.currentPopupMenu && !this.confirmedValue) {
+ // Hack for IE7; blur event is triggered on input field when
+ // selecting a menu item
+ var visible = $(document.currentPopupMenu).getStyle('visibility') != 'hidden';
+ if (visible)
+ return;
+ }
this.focussed = false;
var th = this.parentNode.parentNode;
var tbody = th.parentNode;
initializeFreebusys();
}
-addEvent(window, 'load', onFreeBusyLoadHandler);
+document.observe("dom:loaded", onFreeBusyLoadHandler);
document.currentPopupMenu = popup;
- Event.observe(document.body, "click", onBodyClickMenuHandler);
+ $(document.body).observe("click", onBodyClickMenuHandler);
preventDefault(event);
}
function onBodyClickMenuHandler(event) {
hideMenu(document.currentPopupMenu);
- Event.stopObserving(document.body, "click", onBodyClickMenuHandler);
+ document.body.stopObserving("click", onBodyClickMenuHandler);
if (event)
preventDefault(event);
}
menuNode.setStyle({ visibility: "hidden" });
- // menuNode.hide();
if (menuNode.parentMenuItem) {
- Event.stopObserving(menuNode.parentMenuItem, "mouseover",
- onMouseEnteredSubmenu);
- Event.stopObserving(menuNode, "mouseover", onMouseEnteredSubmenu);
- Event.stopObserving(menuNode.parentMenuItem, "mouseout", onMouseLeftSubmenu);
- Event.stopObserving(menuNode, "mouseout", onMouseLeftSubmenu);
- Event.stopObserving(menuNode.parentMenu, "mouseover",
- onMouseEnteredParentMenu);
+ 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 = null;
}
- if (document.createEvent) { // Safari & Mozilla
- var onhideEvent;
- if (isSafari())
- onhideEvent = document.createEvent("UIEvents");
- else
- 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 logConsole = $("logConsole");
if (logConsole) {
logConsole.highlighted = false;
- Event.observe(logConsole, "dblclick", onLogDblClick, false);
- logConsole.innerHTML = "";
+ logConsole.observe("dblclick", onLogDblClick, false);
+ logConsole.update();
Event.observe(window, "keydown", onBodyKeyDown);
}
}
menuLeft = parentNode.offsetLeft - submenuNode.offsetWidth + 3;
this.mouseInside = true;
- Event.observe(this, "mouseover",
- onMouseEnteredSubmenu.bindAsEventListener(this));
- Event.observe(submenuNode, "mouseover",
- onMouseEnteredSubmenu.bindAsEventListener(submenuNode));
- Event.observe(this, "mouseout", onMouseLeftSubmenu.bindAsEventListener(this));
- Event.observe(submenuNode, "mouseout",
- onMouseLeftSubmenu.bindAsEventListener(submenuNode));
- Event.observe(parentNode, "mouseover",
- onMouseEnteredParentMenu.bindAsEventListener(parentNode));
+ 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" });
document.currentPopupMenu = popup;
- Event.observe(document.body, "click", onBodyClickMenuHandler);
+ $(document.body).observe("click", onBodyClickMenuHandler);
}
}
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
visibility: "visible" });
document.currentPopupMenu = popup;
- Event.observe(document.body, "click", onBodyClickMenuHandler);
+ $(document.body).observe("click", onBodyClickMenuHandler);
}
/* contact selector */
if (currentNode.tagName == 'LI') {
if (!firstTab)
firstTab = i;
- Event.observe(currentNode, "mousedown",
- onTabMouseDown.bindAsEventListener(currentNode));
- Event.observe(currentNode, "click",
- onTabClick.bindAsEventListener(currentNode));
+ $(currentNode).observe("mousedown", onTabMouseDown);
+ $(currentNode).observe("click", onTabClick);
//$(currentNode.getAttribute("target")).hide();
}
}
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.bindAsEventListener(node),
- false);
+ node.observe("mousedown", listRowMouseDownHandler, false);
var callback = callbacks[j];
if (callback) {
if (typeof(callback) == "string") {
else {
node.submenu = callback;
node.addClassName("submenu");
- Event.observe(node, "mouseover",
- popupSubmenu.bindAsEventListener(node));
+ node.observe("mouseover", popupSubmenu);
}
}
else {
- Event.observe(node, "mouseup",
- onBodyClickMenuHandler);
- Event.observe(node, "click",
- $(callback).bindAsEventListener(node));
+ node.observe("mouseup", onBodyClickMenuHandler);
+ node.observe("click", callback);
}
}
else
var progressImage = $("progressIndicator");
if (progressImage)
progressImage.parentNode.removeChild(progressImage);
- Event.observe(document.body, "contextmenu", onBodyClickContextMenu);
+ $(document.body).observe("contextmenu", onBodyClickContextMenu);
}
function onBodyClickContextMenu(event) {
var headers = $(table).getElementsByClassName("sortableTableHeader");
for (var i = 0; i < headers.length; i++) {
var header = headers[i];
- Event.observe(header, "click", onHeaderClick.bindAsEventListener(header))
- }
+ $(header).observe("click", onHeaderClick);
+ }
}
function onLinkBannerClick() {
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);
+ $(anchors[i]).observe("mousedown", listRowMouseDownHandler);
+ $(anchors[i]).observe("click", onLinkBannerClick);
}
- Event.observe(anchors[4], "mousedown", listRowMouseDownHandler);
- Event.observe(anchors[4], "click", onPreferencesClick);
+ $(anchors[4]).observe("mousedown", listRowMouseDownHandler);
+ $(anchors[4]).observe("click", onPreferencesClick);
if (anchors.length > 5)
- Event.observe(anchors[5], "click", toggleLogConsole);
+ $(anchors[5]).observe("click", toggleLogConsole);
}
}
safetyNet.parentNode.removeChild(safetyNet);
}
-addEvent(window, 'load', onLoadHandler);
+document.observe("dom:loaded", onLoadHandler);
function parent$(element) {
return this.opener.document.getElementById(element);