diff --git a/ChangeLog b/ChangeLog index 85e165104..1154539aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2006-09-26 Wolfgang Sourdeau + * UI/WebServerResources/UIxContactEditor.js: imitate the + Thunderbird address book by completing the display name with the + content of the first and last name fields, until the display name + is modified manually. + * UI/WebServerResources/generic.js: added a "trim" method to the String class. diff --git a/UI/WebServerResources/UIxContactEditor.js b/UI/WebServerResources/UIxContactEditor.js index 4a57b779f..16d85571f 100644 --- a/UI/WebServerResources/UIxContactEditor.js +++ b/UI/WebServerResources/UIxContactEditor.js @@ -19,6 +19,7 @@ 02111-1307, USA. */ +var displayNameChanged = false; function unescapeCallbackParameter(s) { if(!s || s.length == 0) @@ -100,3 +101,42 @@ function submitContact(thisForm) { window.close(); } } + +function showCoords(node) { + node = $("givenName"); + window.alert("x: " + node.cascadeLeftOffset() + + ";y: " + node.cascadeTopOffset() + + ";width: " + window.innerWidth + + ";height: " + window.innerHeight); +} + +function onFnKeyDown() { + var fn = $("fn"); + fn.onkeydown = null; + displayNameChanged = true; + + return true; +} + +function onFnNewValue(event) { + if (!displayNameChanged) { + var sn = $("sn").value.trim(); + var givenName = $("givenName").value.trim(); + + var fullName = givenName; + if (fullName && sn) + fullName += ' '; + fullName += sn; + + $("fn").value = fullName; + } + + return true; +} + +function initEditorForm() { + displayNameChanged = ($("fn").value.length > 0); + $("fn").onkeydown = onFnKeyDown; + $("sn").onkeyup = onFnNewValue; + $("givenName").onkeyup = onFnNewValue; +}