2009-07-19 18:41:42 +02:00
|
|
|
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2008-08-28 16:48:45 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
/*
|
2008-08-28 16:48:45 +02:00
|
|
|
Copyright (C) 2005 SKYRIX Software AG
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
This file is part of OpenGroupware.org.
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
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.
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
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.
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
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.
|
2006-06-15 21:34:10 +02:00
|
|
|
*/
|
|
|
|
|
2006-10-04 00:06:00 +02:00
|
|
|
var uixEmailUsr =
|
|
|
|
"([a-zA-Z0-9][a-zA-Z0-9_.-]*|\"([^\\\\\x80-\xff\015\012\"]|\\\\[^\x80-\xff])+\")";
|
|
|
|
var uixEmailDomain =
|
|
|
|
"([a-zA-Z0-9][a-zA-Z0-9._-]*\\.)*[a-zA-Z0-9][a-zA-Z0-9._-]*\\.[a-zA-Z]{2,5}";
|
|
|
|
var uixEmailRegex = new RegExp("^"+uixEmailUsr+"\@"+uixEmailDomain+"$");
|
|
|
|
|
2006-09-26 20:44:42 +02:00
|
|
|
var displayNameChanged = false;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
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,
|
2008-08-28 16:48:45 +02:00
|
|
|
mobile, postalAddress, homePostalAddress,
|
|
|
|
departmentNumber, l)
|
2006-06-15 21:34:10 +02:00
|
|
|
{
|
2008-08-28 16:48:45 +02:00
|
|
|
// 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];
|
2006-06-15 21:34:10 +02:00
|
|
|
var e;
|
2006-09-19 15:51:03 +02:00
|
|
|
e = $('cn');
|
2006-06-15 21:34:10 +02:00
|
|
|
e.setAttribute('value', unescapeCallbackParameter(cn));
|
2006-09-19 15:51:03 +02:00
|
|
|
e = $('email');
|
2006-06-15 21:34:10 +02:00
|
|
|
e.setAttribute('value', email);
|
2006-09-19 15:51:03 +02:00
|
|
|
e = $('sn');
|
2006-06-15 21:34:10 +02:00
|
|
|
e.setAttribute('value', unescapeCallbackParameter(sn));
|
2006-09-19 15:51:03 +02:00
|
|
|
e = $('givenName');
|
2006-06-15 21:34:10 +02:00
|
|
|
e.setAttribute('value', unescapeCallbackParameter(givenName));
|
2006-09-19 15:51:03 +02:00
|
|
|
e = $('telephoneNumber');
|
2006-06-15 21:34:10 +02:00
|
|
|
e.setAttribute('value', telephoneNumber);
|
2006-09-19 15:51:03 +02:00
|
|
|
e = $('facsimileTelephoneNumber');
|
2006-06-15 21:34:10 +02:00
|
|
|
e.setAttribute('value', facsimileTelephoneNumber);
|
2006-09-19 15:51:03 +02:00
|
|
|
e = $('mobile');
|
2006-06-15 21:34:10 +02:00
|
|
|
e.setAttribute('value', mobile);
|
2006-09-19 15:51:03 +02:00
|
|
|
e = $('postalAddress');
|
2006-06-15 21:34:10 +02:00
|
|
|
e.setAttribute('value', unescapeCallbackParameter(postalAddress));
|
2006-09-19 15:51:03 +02:00
|
|
|
e = $('homePostalAddress');
|
2006-06-15 21:34:10 +02:00
|
|
|
e.setAttribute('value', unescapeCallbackParameter(homePostalAddress));
|
2006-09-19 15:51:03 +02:00
|
|
|
e = $('departmentNumber');
|
2006-06-15 21:34:10 +02:00
|
|
|
e.setAttribute('value', unescapeCallbackParameter(departmentNumber));
|
2006-09-19 15:51:03 +02:00
|
|
|
e = $('l');
|
2006-06-15 21:34:10 +02:00
|
|
|
e.setAttribute('value', unescapeCallbackParameter(l));
|
|
|
|
};
|
|
|
|
|
|
|
|
function validateContactEditor() {
|
2009-09-22 22:36:28 +02:00
|
|
|
var rc = true;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2009-09-22 22:36:28 +02:00
|
|
|
var e = $('workMail');
|
|
|
|
if (e.value.length > 0
|
|
|
|
&& !uixEmailRegex.test(e.value))
|
|
|
|
{
|
|
|
|
alert(getLabel ("invalidemailwarn"));
|
|
|
|
rc = false;
|
|
|
|
}
|
2006-09-19 15:51:03 +02:00
|
|
|
|
|
|
|
e = $('homeMail');
|
2009-09-22 22:36:28 +02:00
|
|
|
if (e.value.length > 0
|
|
|
|
&& !uixEmailRegex.test(e.value))
|
|
|
|
{
|
|
|
|
alert(getLabel ("invalidemailwarn"));
|
|
|
|
rc = false;
|
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2009-09-22 22:36:28 +02:00
|
|
|
return rc;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
2006-09-16 00:27:59 +02:00
|
|
|
|
2006-09-26 20:44:42 +02:00
|
|
|
function showCoords(node) {
|
|
|
|
node = $("givenName");
|
|
|
|
window.alert("x: " + node.cascadeLeftOffset()
|
|
|
|
+ ";y: " + node.cascadeTopOffset()
|
2007-10-18 19:18:48 +02:00
|
|
|
+ ";width: " + window.width()
|
|
|
|
+ ";height: " + window.height());
|
2006-09-26 20:44:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2008-03-07 23:10:03 +01:00
|
|
|
function onEditorCancelClick(event) {
|
2008-08-28 16:48:45 +02:00
|
|
|
preventDefault(event);
|
|
|
|
window.close();
|
2008-03-07 23:10:03 +01:00
|
|
|
}
|
|
|
|
|
2006-10-12 18:42:59 +02:00
|
|
|
function initEditorForm() {
|
2006-09-26 20:44:42 +02:00
|
|
|
displayNameChanged = ($("fn").value.length > 0);
|
|
|
|
$("fn").onkeydown = onFnKeyDown;
|
|
|
|
$("sn").onkeyup = onFnNewValue;
|
|
|
|
$("givenName").onkeyup = onFnNewValue;
|
2008-03-07 23:10:03 +01:00
|
|
|
|
|
|
|
$("cancelButton").observe("click", onEditorCancelClick);
|
2006-09-26 20:44:42 +02:00
|
|
|
}
|
2007-10-18 23:54:24 +02:00
|
|
|
|
2009-03-12 22:09:14 +01:00
|
|
|
document.observe("dom:loaded", initEditorForm);
|