From a5ef8abddbd8143106d91ea3719932c11a946d06 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 13 Nov 2006 18:46:00 +0000 Subject: [PATCH] Monotone-Parent: 4d5e83e68c9e02af7b7d7a38ef3b127962a84549 Monotone-Revision: 3e152eeda68e8af354608976f5301f766ec154be Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-11-13T18:46:00 Monotone-Branch: ca.inverse.sogo --- .../SchedulerUI/UIxFreeBusyUserSelector.wox | 8 +- .../UIxFreeBusyUserSelectorTable.wox | 11 +-- .../UIxFreeBusyUserSelector.js | 85 ++++++++++++++----- 3 files changed, 68 insertions(+), 36 deletions(-) diff --git a/UI/Templates/SchedulerUI/UIxFreeBusyUserSelector.wox b/UI/Templates/SchedulerUI/UIxFreeBusyUserSelector.wox index 24a0ee4f7..ad7589c98 100644 --- a/UI/Templates/SchedulerUI/UIxFreeBusyUserSelector.wox +++ b/UI/Templates/SchedulerUI/UIxFreeBusyUserSelector.wox @@ -7,6 +7,9 @@ xmlns:rsrc="OGo:url" xmlns:label="OGo:label"> + - diff --git a/UI/Templates/SchedulerUI/UIxFreeBusyUserSelectorTable.wox b/UI/Templates/SchedulerUI/UIxFreeBusyUserSelectorTable.wox index b20e946b8..f1e60c01b 100644 --- a/UI/Templates/SchedulerUI/UIxFreeBusyUserSelectorTable.wox +++ b/UI/Templates/SchedulerUI/UIxFreeBusyUserSelectorTable.wox @@ -39,9 +39,7 @@ > 47) { - log ("keycode: " + event.keyCode); running = true; - requestField = node; + requestField = this; setTimeout("triggerRequest()", delay); - } else if (node.confirmedValue) { - log ("keycode: " + event.keyCode); + } + else if (this.confirmedValue) { if (event.keyCode == 13) { - node.value = node.confirmedValue; - node.setSelectionRange(node.value.length, node.value.length); + this.setSelectionRange(this.value.length, this.value.length); } } } @@ -38,8 +53,7 @@ function triggerRequest() { requestField); } -function updateResults(http) -{ +function updateResults(http) { if (http.readyState == 4) { if (http.status == 200) { var searchField = http.callbackData; @@ -57,8 +71,12 @@ function updateResults(http) searchField.value += ' >> ' + text[1]; } searchField.confirmedValue = text[1]; - var end = searchField.value.length; - searchField.setSelectionRange(start, end); + if (searchField.focussed) { + var end = searchField.value.length; + searchField.setSelectionRange(start, end); + } + else + searchField.value = text[1]; } running = false; document.contactLookupAjaxRequest = null; @@ -140,27 +158,36 @@ function redisplayFreeBusyZone() } } -function newAttendee(node) +function newAttendee(event) { var table = $("attendeesView").childNodesWithTag("div")[0].childNodesWithTag("table")[0]; - var tbody = table.childNodesWithTag("tbody")[0]; + var tbody = table.tBodies[0]; var model = tbody.rows[tbody.rows.length - 1]; var newAttendeeRow = tbody.rows[tbody.rows.length - 2] var newRow = model.cloneNode(true); + var input = newRow.cells[0].childNodesWithTag("input")[0]; + input.setAttribute("autocomplete", "off"); newRow.setAttribute("class", ""); tbody.insertBefore(newRow, newAttendeeRow); - newRow.childNodesWithTag("td")[0].childNodesWithTag("input")[0].focus(); + input.serial = "pouet"; + input.addEventListener("blur", checkAttendee, false); + input.addEventListener("keydown", onContactKeydown, false); + input.focus(); + input.focussed = true; } -function checkAttendee(node) +function checkAttendee() { - var th = node.parentNode.parentNode; + this.focussed = false; + var th = this.parentNode.parentNode; var tbody = th.parentNode; - if (node.value.trim().length == 0) + if (this.value.trim().length == 0) tbody.removeChild(th); - else if (!node.hasfreebusy) { - displayFreeBusyForNode(node); - node.hasfreebusy = true; + else if (!this.hasfreebusy) { + if (this.confirmedValue) + this.value = this.confirmedValue; + displayFreeBusyForNode(this); + this.hasfreebusy = true; } resetAttendeesValue(); } @@ -246,16 +273,22 @@ function resetAttendeesValue() currentInput.setAttribute("uid", null); } uids.push(currentInput.uid); + currentInput.setAttribute("autocomplete", "off"); + currentInput.addEventListener("keydown", onContactKeydown, false); + currentInput.addEventListener("blur", checkAttendee, false); } var input = $(freeBusySelectorId); input.value = uids.join(","); + inputs[inputs.length - 2].setAttribute("autocomplete", "off"); + inputs[inputs.length - 2].addEventListener("click", newAttendee, false); } -function initializeFreeBusyUserSelector(selectorId) +function initializeFreeBusyUserSelector() { - freeBusySelectorId = selectorId; resetAttendeesValue(); resetAllFreeBusys(); + disableAnchor($('FBStartTimeReplica_date').parentNode.childNodesWithTag('a')[0]); + disableAnchor($('FBEndTimeReplica_date').parentNode.childNodesWithTag('a')[0]); } function resetAllFreeBusys() @@ -332,3 +365,9 @@ function onTimeWidgetChange() { setTimeout("redisplayFreeBusyZone();", 1000); } + +function onFreeBusyLoadHandler() { + initializeFreeBusyUserSelector(); +} + +window.addEventListener("load", onFreeBusyLoadHandler, false);