function cl_lowlight(sender) {
sender.className = "tableview";
}
+
+/* edit field */
+
+function cl_stripActionInURL(url) {
+ if (url[url.length - 1] != '/') {
+ var i;
+
+ i = url.lastIndexOf("/");
+ if (i != -1) url = url.substring(0, i);
+ }
+ if (url[url.length - 1] != '/') // ensure trailing slash
+ url = url + "/";
+ return url;
+}
+
+function cl_saveFieldValue(sender, keyName) {
+ var http = createHTTPClient();
+
+ if (http) {
+ var tableRow = sender.parentNode.parentNode;
+ var recordID = tableRow.id;
+ var url = window.location.href;
+ var content;
+
+ url = cl_stripActionInURL(url);
+ url = url + recordID + "/patchOneField";
+ // TODO: confuses SOPE?!: url = url + "?jsonly=1"
+
+ // TODO: need to use XML!
+ content = keyName + "\n" + sender.value;
+
+ http.open("POST", url, false);
+ http.send(content);
+ if (http.status != 200) {
+ // TODO: localize, improve error message
+ alert("Store Failed: " + http.statusText);
+ }
+ else {
+ return true;
+ }
+ }
+ else {
+ // TODO: we should disable the functionality now
+ }
+ return false;
+}
+
+var currentEditField = null;
+var currentEditDiv = null;
+var oldFieldValue = null;
+var currentKeyName = null;
+
+function cl_findEditField(sender) {
+ var f;
+
+ f = sender.parentNode.getElementsByTagName("input");
+ return (f.length > 0) ? f[0] : null;
+}
+
+function cl_showEditField(sender, e, keyName) {
+ var inputField;
+
+ if (currentEditDiv != null)
+ cl_findEditField(currentEditField);
+
+ e.stopPropagation();
+
+ currentKeyName = keyName;
+ currentEditDiv = sender;
+ currentEditField = cl_findEditField(sender);
+ oldFieldValue = unescapeHTML(sender.innerHTML);
+
+ inputField = cl_findEditField(sender);
+ inputField.value = oldFieldValue;
+ sender.style.display = "none";
+ inputField.style.display = "inline";
+
+ inputField.focus();
+ inputField.select();
+
+ return true;
+}
+
+function cl_finishEditField(sender) {
+ // this might trigger onblur!
+
+ if (sender != currentEditField && sender != null)
+ return;
+
+ currentEditField.style.display = "none";
+ currentEditDiv.style.display = "inline";
+ currentEditField = null;
+ currentEditDiv = null;
+ currentKeyName = null;
+ oldFieldValue = null;
+}
+
+function cl_editFieldKeyPress(sender, e) {
+ if (e.keyCode == 27) { /* escape, cancel editing */
+ cl_finishEditField(null);
+ return false;
+ }
+ if (e.keyCode == 13) { /* save using XMLHttpRequest */
+ if (cl_saveFieldValue(sender, currentKeyName)) {
+ // copy new value to div
+ currentEditDiv.innerHTML = escapeHTML(sender.value);
+ cl_finishEditField(null);
+ }
+ else {
+ // alert blurs!: alert("field save failed!"); // TODO: localize
+ // TODO: do we have beep or something?
+ }
+ return false;
+ }
+
+ // TODO: we could support "tab" for jumping to the next field
+ return true;
+}
var:queryDictionary="queryParameters"
-->
+<style>
+span.cl_inline {
+ width: 100%;
+}
+input.cl_inlinefield {
+ font-size: 8pt;
+ border-width: 1px;
+ border-color: black;
+ display: none;
+ width: 95%;
+}
+</style>
+
<script language="JavaScript" rsrc:src="mailercontacts.js">
</script>
<!-- actual table contents -->
<var:foreach list="contactInfos" item="contact">
- <tr class="tableview" var:id="contact.cName"
+ <tr class="tableview"
+ var:id="contact.cName"
onclick="openContact(this, this.id)"
onmouseover="cl_highlight(this)"
onmouseout="cl_lowlight(this)"
style="cursor: pointer;"
>
<td><var:string value="contact.sn" /><entity name="nbsp"/></td>
+
<td>
- <var:string value="contact.givenname" />
+ <span class="cl_inline"
+ onclick="cl_showEditField(this, event, 'givenName')"
+ ><var:string value="contact.givenname" /></span>
+
+ <input type="text" class="cl_inlinefield"
+ autocomplete="off"
+ onkeypress="cl_editFieldKeyPress(this, event)"
+ onclick="event.stopPropagation(); return true"
+ onblur="cl_finishEditField(this)"
+ />
<entity name="nbsp"/>
</td>
+
<td><var:string value="contact.mail" /><entity name="nbsp"/></td>
<td>
<var:string value="contact.telephonenumber" />