sogo/UI/WebServerResources/UIxContactEditor.js
Wolfgang Sourdeau 6ea3d67888 Monotone-Parent: 30024333fa104bcd0ddc578e486dad24227bbd3c
Monotone-Revision: 14ff365d11c0291a1eee9188cca51f506f40b9bc

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2006-09-26T18:44:42
Monotone-Branch: ca.inverse.sogo
2006-09-26 18:44:42 +00:00

143 lines
4 KiB
JavaScript

/*
Copyright (C) 2005 SKYRIX Software AG
This file is part of OpenGroupware.org.
OGo is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with OGo; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
var displayNameChanged = false;
function unescapeCallbackParameter(s) {
if(!s || s.length == 0)
return s;
s = s.replace(/'/g, "'");
s = s.replace(/"/g, '"');
return s;
}
function copyContact(type, email, uid, sn,
cn, givenName, telephoneNumber, facsimileTelephoneNumber,
mobile, postalAddress, homePostalAddress,
departmentNumber, l)
{
// var type = arguments[0];
// var email = arguments[1];
// var uid = arguments[2];
// var sn = arguments[3];
// var givenName = arguments[4];
// var telephoneNumber = arguments[5];
// var facsimileTelephoneNumber = arguments[6];
// var mobile = arguments[7];
// var postalAddress = arguments[8];
// var homePostalAddress = arguments[9];
// var departmentNumber = arguments[10];
// var l = arguments[11];
var e;
e = $('cn');
e.setAttribute('value', unescapeCallbackParameter(cn));
e = $('email');
e.setAttribute('value', email);
e = $('sn');
e.setAttribute('value', unescapeCallbackParameter(sn));
e = $('givenName');
e.setAttribute('value', unescapeCallbackParameter(givenName));
e = $('telephoneNumber');
e.setAttribute('value', telephoneNumber);
e = $('facsimileTelephoneNumber');
e.setAttribute('value', facsimileTelephoneNumber);
e = $('mobile');
e.setAttribute('value', mobile);
e = $('postalAddress');
e.setAttribute('value', unescapeCallbackParameter(postalAddress));
e = $('homePostalAddress');
e.setAttribute('value', unescapeCallbackParameter(homePostalAddress));
e = $('departmentNumber');
e.setAttribute('value', unescapeCallbackParameter(departmentNumber));
e = $('l');
e.setAttribute('value', unescapeCallbackParameter(l));
};
function validateContactEditor() {
var e;
e = $('workMail');
if (e.value.length == 0)
return true;
if (uixEmailRegex.test(e.value) != true)
return confirm(labels.invalidemailwarn);
e = $('homeMail');
if (e.value.length == 0)
return true;
if (uixEmailRegex.test(e.value) != true)
return confirm(labels.invalidemailwarn);
return true;
}
function submitContact(thisForm) {
var action = $('jsaction');
action.setAttribute("name", "save:method");
action.setAttribute("value", "save");
if (validateContactEditor()) {
thisForm.submit();
if (window.opener.refreshContacts)
window.opener.setTimeout("refreshContacts(\""+ window.contactId +"\");", 200);
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;
}