2 Copyright (C) 2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21 /* JavaScript code for SOGo MailerUI contacts */
23 function openContact(sender, addruid) {
26 w = window.open(addruid + "/tb.edit", 'SOGo_addr_' + addruid,
27 'width=540,height=340,resizable=1,scrollbars=1,toolbar=0,' +
28 'location=0,directories=0,status=0,menubar=0,copyhistory=0');
33 function cl_highlight(sender) {
34 sender.className = "tableview_highlight";
36 function cl_lowlight(sender) {
37 sender.className = "tableview";
42 function cl_saveFieldValue(sender, keyName) {
43 var http = createHTTPClient();
46 var tableRow = sender.parentNode.parentNode;
47 var recordID = tableRow.id;
48 var url = window.location.href;
51 url = ml_stripActionInURL(url);
52 url = url + recordID + "/patchOneField";
53 // TODO: confuses SOPE?!: url = url + "?jsonly=1"
55 // TODO: need to use XML!
56 content = keyName + "\n" + sender.value;
58 http.open("POST", url, false);
60 if (http.status != 200) {
61 // TODO: localize, improve error message
62 alert("Store Failed: " + http.statusText);
69 // TODO: we should disable the functionality now
74 var currentEditField = null;
75 var currentEditDiv = null;
76 var oldFieldValue = null;
77 var currentKeyName = null;
79 function cl_findEditField(sender) {
82 f = sender.parentNode.getElementsByTagName("input");
83 return (f.length > 0) ? f[0] : null;
86 function cl_showEditField(sender, e, keyName) {
89 if (currentEditDiv != null)
90 cl_findEditField(currentEditField);
94 currentKeyName = keyName;
95 currentEditDiv = sender;
96 currentEditField = cl_findEditField(sender);
97 oldFieldValue = unescapeHTML(sender.innerHTML);
99 inputField = cl_findEditField(sender);
100 inputField.value = oldFieldValue;
101 sender.style.display = "none";
102 inputField.style.display = "inline";
110 function cl_finishEditField(sender) {
111 // this might trigger onblur!
113 if (sender != currentEditField && sender != null)
116 currentEditField.style.display = "none";
117 currentEditDiv.style.display = "inline";
118 currentEditField = null;
119 currentEditDiv = null;
120 currentKeyName = null;
121 oldFieldValue = null;
124 function cl_editFieldKeyPress(sender, e) {
125 if (e.keyCode == 27) { /* escape, cancel editing */
126 cl_finishEditField(null);
129 if (e.keyCode == 13) { /* save using XMLHttpRequest */
130 if (cl_saveFieldValue(sender, currentKeyName)) {
131 // copy new value to div
132 currentEditDiv.innerHTML = escapeHTML(sender.value);
133 cl_finishEditField(null);
136 // alert blurs!: alert("field save failed!"); // TODO: localize
137 // TODO: do we have beep or something?
142 // TODO: we could support "tab" for jumping to the next field