2010-03-02 20:57:30 +01:00
|
|
|
var filters = [];
|
2010-08-06 17:34:05 +02:00
|
|
|
var mailAccounts = null;
|
|
|
|
var dialogs = {};
|
2008-08-28 16:48:45 +02:00
|
|
|
|
2007-06-19 19:59:59 +02:00
|
|
|
function savePreferences(sender) {
|
2014-07-16 20:08:39 +02:00
|
|
|
var sendForm = true;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
var sigList = $("signaturePlacementList");
|
|
|
|
if (sigList)
|
|
|
|
sigList.disabled = false;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
if ($("appointmentsWhiteListWrapper"))
|
|
|
|
serializeAppointmentsWhiteList();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
if ($("calendarCategoriesListWrapper"))
|
|
|
|
serializeCalendarCategories();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
if ($("contactsCategoriesListWrapper"))
|
|
|
|
serializeContactsCategories();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
if ($("mailLabelsListWrapper"))
|
|
|
|
serializeMailLabels();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
if (typeof mailCustomFromEnabled !== "undefined" && !emailRE.test($("email").value)) {
|
|
|
|
showAlertDialog(_("Please specify a valid sender address."));
|
|
|
|
sendForm = false;
|
2014-04-04 21:04:37 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
if ($("replyTo")) {
|
|
|
|
var replyTo = $("replyTo").value;
|
|
|
|
if (!replyTo.blank() && !emailRE.test(replyTo)) {
|
|
|
|
showAlertDialog(_("Please specify a valid reply-to address."));
|
|
|
|
sendForm = false;
|
|
|
|
}
|
2009-10-09 22:30:42 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
if ($("dayStartTime")) {
|
|
|
|
var start = $("dayStartTime");
|
|
|
|
var selectedStart = parseInt(start.options[start.selectedIndex].value);
|
|
|
|
var end = $("dayEndTime");
|
|
|
|
var selectedEnd = parseInt(end.options[end.selectedIndex].value);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
if (selectedStart >= selectedEnd) {
|
|
|
|
showAlertDialog (_("Day start time must be prior to day end time."));
|
|
|
|
sendForm = false;
|
|
|
|
}
|
2010-03-02 20:57:30 +01:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
if ($("enableVacation") && $("enableVacation").checked) {
|
|
|
|
if ($("autoReplyText").value.strip().length == 0 || $("autoReplyEmailAddresses").value.strip().length == 0) {
|
|
|
|
showAlertDialog(_("Please specify your message and your email addresses for which you want to enable auto reply."));
|
|
|
|
sendForm = false;
|
2014-02-28 22:39:27 +01:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
if ($("autoReplyText").value.strip().endsWith('\n.')) {
|
|
|
|
showAlertDialog(_("Your vacation message must not end with a single dot on a line."));
|
|
|
|
sendForm = false;
|
2014-04-04 21:04:37 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
if ($("enableVacationEndDate") && $("enableVacationEndDate").checked) {
|
|
|
|
var e = $("vacationEndDate_date");
|
|
|
|
var endDate = e.inputAsDate();
|
|
|
|
var now = new Date();
|
|
|
|
if (isNaN(endDate.getTime()) || endDate.getTime() < now.getTime()) {
|
|
|
|
showAlertDialog(_("End date of your auto reply must be in the future."));
|
|
|
|
sendForm = false;
|
|
|
|
}
|
2014-02-28 22:39:27 +01:00
|
|
|
}
|
2014-07-16 20:08:39 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
if ($("enableForward") && $("enableForward").checked) {
|
|
|
|
var addresses = $("forwardAddress").value.split(",");
|
|
|
|
for (var i = 0; i < addresses.length && sendForm; i++)
|
|
|
|
if (!emailRE.test(addresses[i].strip())) {
|
|
|
|
showAlertDialog(_("Please specify an address to which you want to forward your messages."));
|
|
|
|
sendForm = false;
|
|
|
|
}
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
if (typeof sieveCapabilities != "undefined") {
|
|
|
|
var jsonFilters = prototypeIfyFilters();
|
|
|
|
$("sieveFilters").setValue(Object.toJSON(jsonFilters));
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
if (sendForm) {
|
|
|
|
saveMailAccounts();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
triggerAjaxRequest($("mainForm").readAttribute("action"), function (http) {
|
2014-07-16 20:26:30 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
var response = http.responseText.evalJSON(true);
|
|
|
|
if (http.status == 503) {
|
|
|
|
showAlertDialog(_(response.textStatus));
|
|
|
|
}
|
|
|
|
else if (http.status == 200) {
|
|
|
|
if (response.hasChanged == 1) {
|
|
|
|
window.opener.location.reload();
|
|
|
|
window.close();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
window.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
showAlertDialog(_(response.textStatus));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-07-30 16:31:25 +02:00
|
|
|
null,
|
|
|
|
Form.serialize($("mainForm")), // excludes the file input
|
|
|
|
{ "Content-type": "application/x-www-form-urlencoded"}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
2007-06-19 19:59:59 +02:00
|
|
|
}
|
2008-07-25 20:44:31 +02:00
|
|
|
|
2010-03-02 20:57:30 +01:00
|
|
|
function prototypeIfyFilters() {
|
|
|
|
var newFilters = $([]);
|
|
|
|
for (var i = 0; i < filters.length; i++) {
|
|
|
|
var filter = filters[i];
|
|
|
|
var newFilter = $({});
|
|
|
|
newFilter.name = filter.name;
|
|
|
|
newFilter.match = filter.match;
|
|
|
|
newFilter.active = filter.active;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-04-06 17:41:08 +02:00
|
|
|
if (filter.rules) {
|
|
|
|
newFilter.rules = $([]);
|
|
|
|
for (var j = 0; j < filter.rules.length; j++) {
|
|
|
|
newFilter.rules.push($(filter.rules[j]));
|
|
|
|
}
|
2010-03-02 20:57:30 +01:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-01-30 20:51:38 +01:00
|
|
|
if (filter.actions) {
|
|
|
|
newFilter.actions = $([]);
|
|
|
|
for (var j = 0; j < filter.actions.length; j++) {
|
|
|
|
newFilter.actions.push($(filter.actions[j]));
|
|
|
|
}
|
2010-03-02 20:57:30 +01:00
|
|
|
}
|
|
|
|
newFilters.push(newFilter);
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-03-02 20:57:30 +01:00
|
|
|
return newFilters;
|
|
|
|
}
|
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
function _setupEvents() {
|
2010-03-25 21:17:50 +01:00
|
|
|
var widgets = [ "timezone", "shortDateFormat", "longDateFormat",
|
2014-07-16 20:26:30 +02:00
|
|
|
"timeFormat", "weekStartDay", "dayStartTime", "dayEndTime",
|
2014-08-29 19:16:30 +02:00
|
|
|
"firstWeek", "refreshViewCheck", "sortByThreads", "displayRemoteInlineImages",
|
2014-07-16 20:26:30 +02:00
|
|
|
"subscribedFoldersOnly", "language", "defaultCalendar",
|
|
|
|
"enableVacation" ];
|
2010-03-25 21:17:50 +01:00
|
|
|
for (var i = 0; i < widgets.length; i++) {
|
|
|
|
var widget = $(widgets[i]);
|
|
|
|
if (widget) {
|
2010-08-06 17:34:05 +02:00
|
|
|
widget.observe("change", onChoiceChanged);
|
2010-03-25 21:17:50 +01:00
|
|
|
}
|
|
|
|
}
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2011-02-24 01:02:24 +01:00
|
|
|
// We check for non-null elements as replyPlacementList and composeMessagesType
|
|
|
|
// might not be present if ModulesConstraints disable those elements
|
|
|
|
if ($("replyPlacementList"))
|
2012-11-27 16:37:14 +01:00
|
|
|
$("replyPlacementList").on("change", onReplyPlacementListChange);
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2011-02-24 01:02:24 +01:00
|
|
|
if ($("composeMessagesType"))
|
2012-11-27 16:37:14 +01:00
|
|
|
$("composeMessagesType").on("change", onComposeMessagesTypeChange);
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2011-02-24 01:02:24 +01:00
|
|
|
// Note: we also monitor changes to the calendar categories.
|
|
|
|
// See functions endEditable and onColorPickerChoice.
|
2010-10-26 21:26:50 +02:00
|
|
|
var valueInputs = [ "calendarCategoriesValue", "calendarCategoriesValue" ];
|
|
|
|
for (var i = 0; i < valueInputs.length; i++) {
|
|
|
|
var valueInput = $(valueInputs[i]);
|
|
|
|
if (valueInput)
|
|
|
|
valueInput.value = "";
|
|
|
|
}
|
2008-07-25 20:44:31 +02:00
|
|
|
}
|
|
|
|
|
2013-11-15 21:50:46 +01:00
|
|
|
function onBodyClickHandler(event) {
|
|
|
|
var target = getTarget(event);
|
|
|
|
if (!target.hasClassName('colorBox'))
|
|
|
|
$("colorPickerDialog").hide();
|
|
|
|
}
|
|
|
|
|
2010-03-25 21:17:50 +01:00
|
|
|
function onChoiceChanged(event) {
|
|
|
|
var hasChanged = $("hasChanged");
|
|
|
|
hasChanged.value = "1";
|
|
|
|
}
|
|
|
|
|
2010-03-08 16:18:05 +01:00
|
|
|
function addDefaultEmailAddresses(event) {
|
2009-10-15 00:11:13 +02:00
|
|
|
var defaultAddresses = $("defaultEmailAddresses").value.split(/, */);
|
2009-10-30 20:37:04 +01:00
|
|
|
var addresses = $("autoReplyEmailAddresses").value.trim();
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2009-10-30 20:37:04 +01:00
|
|
|
if (addresses) addresses = addresses.split(/, */);
|
|
|
|
else addresses = new Array();
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2009-10-15 00:11:13 +02:00
|
|
|
defaultAddresses.each(function(adr) {
|
2014-07-16 20:26:30 +02:00
|
|
|
for (var i = 0; i < addresses.length; i++)
|
|
|
|
if (adr == addresses[i])
|
|
|
|
break;
|
|
|
|
if (i == addresses.length)
|
|
|
|
addresses.push(adr);
|
|
|
|
});
|
|
|
|
|
2009-10-15 00:11:13 +02:00
|
|
|
$("autoReplyEmailAddresses").value = addresses.join(", ");
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-03-08 16:18:05 +01:00
|
|
|
event.stop();
|
2009-10-15 00:11:13 +02:00
|
|
|
}
|
|
|
|
|
2008-07-25 20:44:31 +02:00
|
|
|
function initPreferences() {
|
2014-07-16 20:08:39 +02:00
|
|
|
var tabsContainer = $("preferencesTabs");
|
|
|
|
var controller = new SOGoTabsController();
|
|
|
|
controller.attachToTabsContainer(tabsContainer);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
// Inner tabs on the mail module tab
|
|
|
|
tabsContainer = $('mailOptionsTabs');
|
|
|
|
if (tabsContainer) {
|
|
|
|
var mailController = new SOGoTabsController();
|
|
|
|
mailController.attachToTabsContainer(tabsContainer);
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
// Inner tabs on the calendar module tab
|
|
|
|
tabsContainer = $('calendarOptionsTabs');
|
|
|
|
if (tabsContainer) {
|
|
|
|
var mailController = new SOGoTabsController();
|
|
|
|
mailController.attachToTabsContainer(tabsContainer);
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
_setupEvents();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
// Optional function called when initializing the preferences
|
|
|
|
// Typically defined inline in the UIxAdditionalPreferences.wox template
|
|
|
|
if (typeof (initAdditionalPreferences) != "undefined")
|
|
|
|
initAdditionalPreferences();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
// Color picker
|
|
|
|
$('colorPickerDialog').on('click', 'span', onColorPickerChoice);
|
|
|
|
$(document.body).on("click", onBodyClickHandler);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
// Calendar whiteList
|
|
|
|
var whiteList = $("appointmentsWhiteListWrapper");
|
2014-09-09 16:28:59 +02:00
|
|
|
if (whiteList) {
|
|
|
|
var whiteListString = $("whiteList").getValue();
|
2014-09-09 21:34:04 +02:00
|
|
|
var whiteListObject = {};
|
2014-09-09 16:28:59 +02:00
|
|
|
// This condition is a backward compatibility where the strings looks like : "sogo1=John DOE <sogo1@example.com>"
|
|
|
|
if (whiteListString.search("=") != -1) {
|
|
|
|
var split = whiteListString.split("=");
|
|
|
|
whiteListObject[split[0]] = split[1];
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (whiteListString != "") {
|
2014-09-09 21:34:04 +02:00
|
|
|
whiteListObject = JSON.parse(whiteListString);
|
2014-09-09 16:28:59 +02:00
|
|
|
}
|
|
|
|
var allKeys = Object.keys(whiteListObject);
|
|
|
|
var allValues = Object.values(whiteListObject);
|
|
|
|
var tablebody = $("appointmentsWhiteListWrapper").childNodesWithTag("table")[0].tBodies[0];
|
|
|
|
for (i = 0; i < allKeys.length; i++) {
|
|
|
|
var row = new Element("tr");
|
|
|
|
var td = new Element("td").update("");
|
|
|
|
var textField = new Element("input");
|
|
|
|
var span = new Element("span");
|
|
|
|
|
|
|
|
row.addClassName("whiteListRow");
|
|
|
|
row.observe("mousedown", onRowClick);
|
|
|
|
td.addClassName ("whiteListCell");
|
|
|
|
td.observe("mousedown", endAllEditables);
|
|
|
|
td.observe("dblclick", onNameEdit);
|
|
|
|
textField.addInterface(SOGoAutoCompletionInterface);
|
|
|
|
textField.SOGoUsersSearch = true;
|
|
|
|
textField.observe("autocompletion:changed", endEditable);
|
|
|
|
textField.addClassName("textField");
|
|
|
|
textField.value = allValues[i];
|
|
|
|
textField.setAttribute("uid", allKeys[i]);
|
|
|
|
textField.hide();
|
|
|
|
span.innerText = allValues[i];
|
|
|
|
|
|
|
|
td.appendChild(textField);
|
|
|
|
td.appendChild(span);
|
|
|
|
row.appendChild (td);
|
|
|
|
tablebody.appendChild(row);
|
|
|
|
$(tablebody).deselectAll();
|
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
}
|
2014-09-22 14:38:01 +02:00
|
|
|
|
|
|
|
var table = whiteList.childNodesWithTag("table")[0];
|
|
|
|
table.multiselect = true;
|
|
|
|
$("appointmentsWhiteListAdd").observe("click", onAppointmentsWhiteListAdd);
|
|
|
|
$("appointmentsWhiteListDelete").observe("click", onAppointmentsWhiteListDelete);
|
2014-07-07 19:38:37 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
// Calender categories
|
|
|
|
var wrapper = $("calendarCategoriesListWrapper");
|
|
|
|
if (wrapper) {
|
|
|
|
var table = wrapper.childNodesWithTag("table")[0];
|
|
|
|
resetCalendarCategoriesColors(null);
|
|
|
|
var r = $$("#calendarCategoriesListWrapper tbody tr");
|
|
|
|
for (var i= 0; i < r.length; i++)
|
|
|
|
r[i].identify();
|
|
|
|
table.multiselect = true;
|
|
|
|
resetCalendarTableActions();
|
|
|
|
$("calendarCategoryAdd").observe("click", onCalendarCategoryAdd);
|
|
|
|
$("calendarCategoryDelete").observe("click", onCalendarCategoryDelete);
|
|
|
|
wrapper.observe("scroll", onBodyClickHandler);
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
// Mail labels/tags
|
|
|
|
var wrapper = $("mailLabelsListWrapper");
|
|
|
|
if (wrapper) {
|
|
|
|
var table = wrapper.childNodesWithTag("table")[0];
|
|
|
|
resetMailLabelsColors(null);
|
|
|
|
var r = $$("#mailLabelsListWrapper tbody tr");
|
|
|
|
for (var i= 0; i < r.length; i++)
|
|
|
|
r[i].identify();
|
|
|
|
table.multiselect = true;
|
|
|
|
resetMailTableActions();
|
|
|
|
$("mailLabelAdd").observe("click", onMailLabelAdd);
|
|
|
|
$("mailLabelDelete").observe("click", onMailLabelDelete);
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
// Contact categories
|
|
|
|
wrapper = $("contactsCategoriesListWrapper");
|
|
|
|
if (wrapper) {
|
|
|
|
var table = wrapper.childNodesWithTag("table")[0];
|
|
|
|
var r = $$("#contactsCategoriesListWrapper tbody tr");
|
|
|
|
for (var i= 0; i < r.length; i++)
|
|
|
|
r[i].identify();
|
|
|
|
table.multiselect = true;
|
|
|
|
resetContactsTableActions();
|
|
|
|
$("contactsCategoryAdd").observe("click", onContactsCategoryAdd);
|
|
|
|
$("contactsCategoryDelete").observe("click", onContactsCategoryDelete);
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
if ($("replyPlacementList"))
|
|
|
|
onReplyPlacementListChange();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
var button = $("addDefaultEmailAddresses");
|
|
|
|
if (button)
|
|
|
|
button.observe("click", addDefaultEmailAddresses);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
button = $("changePasswordBtn");
|
|
|
|
if (button)
|
|
|
|
button.observe("click", onChangePasswordClick);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
initSieveFilters();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
initMailAccounts();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
button = $("enableVacationEndDate");
|
|
|
|
if (button) {
|
2014-07-16 20:26:30 +02:00
|
|
|
jQuery("#vacationEndDate_date").closest(".date").datepicker({ autoclose: true, position: 'above', weekStart: $('weekStartDay').getValue() });
|
2014-07-16 20:08:39 +02:00
|
|
|
button.on("click", function(event) {
|
2014-07-30 16:31:25 +02:00
|
|
|
if (this.checked)
|
|
|
|
$("vacationEndDate_date").enable();
|
|
|
|
else
|
|
|
|
$("vacationEndDate_date").disable();
|
|
|
|
});
|
2014-07-16 20:08:39 +02:00
|
|
|
}
|
|
|
|
onAddOutgoingAddressesCheck();
|
2010-03-02 20:57:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function initSieveFilters() {
|
|
|
|
var table = $("filtersList");
|
|
|
|
if (table) {
|
|
|
|
var filtersValue = $("sieveFilters").getValue();
|
|
|
|
if (filtersValue && filtersValue.length) {
|
|
|
|
filters = $(filtersValue.evalJSON(false));
|
|
|
|
for (var i = 0; i < filters.length; i++) {
|
|
|
|
appendSieveFilterRow(table, i, filters[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$("filterAdd").observe("click", onFilterAdd);
|
|
|
|
$("filterDelete").observe("click", onFilterDelete);
|
|
|
|
$("filterMoveUp").observe("click", onFilterMoveUp);
|
|
|
|
$("filterMoveDown").observe("click", onFilterMoveDown);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function appendSieveFilterRow(filterTable, number, filter) {
|
|
|
|
var row = createElement("tr");
|
|
|
|
row.observe("mousedown", onRowClick);
|
|
|
|
row.observe("dblclick", onFilterEdit.bindAsEventListener(row));
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-03-02 20:57:30 +01:00
|
|
|
var nameColumn = createElement("td");
|
|
|
|
nameColumn.appendChild(document.createTextNode(filter["name"]));
|
|
|
|
row.appendChild(nameColumn);
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-03-02 20:57:30 +01:00
|
|
|
var activeColumn = createElement("td", null, "activeColumn");
|
|
|
|
var cb = createElement("input", null, "checkBox",
|
2011-02-16 01:16:37 +01:00
|
|
|
{ type: "checkbox" },
|
2010-03-02 20:57:30 +01:00
|
|
|
null, activeColumn);
|
2011-02-16 01:16:37 +01:00
|
|
|
cb.checked = filter.active;
|
2010-03-02 20:57:30 +01:00
|
|
|
var bound = onScriptActiveCheck.bindAsEventListener(cb);
|
2010-08-27 16:56:57 +02:00
|
|
|
cb.observe("click", bound);
|
2010-03-02 20:57:30 +01:00
|
|
|
row.appendChild(activeColumn);
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-03-02 20:57:30 +01:00
|
|
|
filterTable.tBodies[0].appendChild(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onScriptActiveCheck(event) {
|
|
|
|
var index = this.parentNode.parentNode.rowIndex - 1;
|
|
|
|
filters[index].active = this.checked;
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateSieveFilterRow(filterTable, number, filter) {
|
|
|
|
var row = $(filterTable.tBodies[0].rows[number]);
|
|
|
|
var columns = row.childNodesWithTag("td");
|
|
|
|
var nameColumn = columns[0];
|
|
|
|
while (nameColumn.firstChild) {
|
|
|
|
nameColumn.removeChild(nameColumn.firstChild);
|
|
|
|
}
|
|
|
|
nameColumn.appendChild(document.createTextNode(filter.name));
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-03-02 20:57:30 +01:00
|
|
|
var activeColumn = columns[1];
|
2010-08-27 17:14:03 +02:00
|
|
|
var cb = activeColumn.childNodesWithTag("input");
|
|
|
|
cb[0].checked = filter.active;
|
2010-03-02 20:57:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function _editFilter(filterId) {
|
2014-03-04 19:23:55 +01:00
|
|
|
var urlstr = ApplicationBaseURL + "/editFilter?filter=" + filterId;
|
2010-03-02 20:57:30 +01:00
|
|
|
var win = window.open(urlstr, "sieve_filter_" + filterId,
|
2010-03-11 15:52:52 +01:00
|
|
|
"width=560,height=380,resizable=0");
|
2010-03-02 20:57:30 +01:00
|
|
|
if (win)
|
|
|
|
win.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onFilterAdd(event) {
|
|
|
|
_editFilter("new");
|
|
|
|
event.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onFilterDelete(event) {
|
|
|
|
var filtersList = $("filtersList").tBodies[0];
|
|
|
|
var nodes = filtersList.getSelectedNodes();
|
|
|
|
if (nodes.length > 0) {
|
|
|
|
var deletedFilters = [];
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
var node = nodes[i];
|
|
|
|
deletedFilters.push(node.rowIndex - 1);
|
|
|
|
}
|
2013-11-13 20:46:08 +01:00
|
|
|
deletedFilters = deletedFilters.sort(function(x,y) { return x-y; });
|
2010-03-02 20:57:30 +01:00
|
|
|
var rows = filtersList.rows;
|
|
|
|
for (var i = 0; i < deletedFilters.length; i++) {
|
|
|
|
var filterNbr = deletedFilters[i];
|
|
|
|
filters.splice(filterNbr, 1);
|
|
|
|
var row = rows[filterNbr];
|
|
|
|
row.parentNode.removeChild(row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
event.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onFilterMoveUp(event) {
|
|
|
|
var filtersList = $("filtersList").tBodies[0];
|
|
|
|
var nodes = filtersList.getSelectedNodes();
|
|
|
|
if (nodes.length > 0) {
|
|
|
|
var node = nodes[0];
|
|
|
|
var previous = node.previous();
|
|
|
|
if (previous) {
|
|
|
|
var count = node.rowIndex - 1;
|
|
|
|
node.parentNode.removeChild(node);
|
|
|
|
filtersList.insertBefore(node, previous);
|
|
|
|
var swapFilter = filters[count];
|
|
|
|
filters[count] = filters[count - 1];
|
|
|
|
filters[count - 1] = swapFilter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
event.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onFilterMoveDown(event) {
|
|
|
|
var filtersList = $("filtersList").tBodies[0];
|
|
|
|
var nodes = filtersList.getSelectedNodes();
|
|
|
|
if (nodes.length > 0) {
|
|
|
|
var node = nodes[0];
|
|
|
|
var next = node.next();
|
|
|
|
if (next) {
|
|
|
|
var count = node.rowIndex - 1;
|
|
|
|
filtersList.removeChild(next);
|
|
|
|
filtersList.insertBefore(next, node);
|
|
|
|
var swapFilter = filters[count];
|
|
|
|
filters[count] = filters[count + 1];
|
|
|
|
filters[count + 1] = swapFilter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
event.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onFilterEdit(event) {
|
|
|
|
_editFilter(this.rowIndex - 1);
|
|
|
|
event.stop();
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2012-02-02 20:54:53 +01:00
|
|
|
return false;
|
2010-03-02 20:57:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function copyFilter(originalFilter) {
|
|
|
|
var newFilter = {};
|
|
|
|
newFilter.name = originalFilter.name;
|
|
|
|
newFilter.match = originalFilter.match;
|
|
|
|
newFilter.active = originalFilter.active;
|
2010-04-06 17:41:08 +02:00
|
|
|
if (originalFilter.rules) {
|
|
|
|
newFilter.rules = [];
|
|
|
|
for (var i = 0; i < originalFilter.rules.length; i++) {
|
|
|
|
newFilter.rules.push(_copyFilterElement(originalFilter.rules[i]));
|
|
|
|
}
|
2010-03-02 20:57:30 +01:00
|
|
|
}
|
|
|
|
newFilter.actions = [];
|
|
|
|
for (var i = 0; i < originalFilter.actions.length; i++) {
|
|
|
|
newFilter.actions.push(_copyFilterElement(originalFilter.actions[i]));
|
|
|
|
}
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-03-02 20:57:30 +01:00
|
|
|
return newFilter;
|
|
|
|
}
|
|
|
|
|
|
|
|
function _copyFilterElement(filterElement) { /* element = rule or action */
|
|
|
|
var newElement = {};
|
|
|
|
for (var k in filterElement) {
|
|
|
|
var value = filterElement[k];
|
|
|
|
if (typeof(value) == "string" || typeof(value) == "number") {
|
2010-08-06 17:34:05 +02:00
|
|
|
newElement[k] = value;
|
2010-03-02 20:57:30 +01:00
|
|
|
}
|
|
|
|
}
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-03-02 20:57:30 +01:00
|
|
|
return newElement;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSieveCapabilitiesFromEditor() {
|
|
|
|
return sieveCapabilities;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getFilterFromEditor(filterId) {
|
2012-01-02 20:42:46 +01:00
|
|
|
var filter = copyFilter(filters[filterId]);
|
|
|
|
return Object.toJSON(filter);
|
2010-03-02 20:57:30 +01:00
|
|
|
}
|
|
|
|
|
2010-08-27 16:56:57 +02:00
|
|
|
function setupMailboxesFromJSON(jsonResponse) {
|
|
|
|
var responseMboxes = jsonResponse.mailboxes;
|
|
|
|
userMailboxes = $([]);
|
|
|
|
for (var i = 0; i < responseMboxes.length; i++) {
|
2014-01-27 21:43:48 +01:00
|
|
|
var mbox = { 'displayName': responseMboxes[i].displayName.substr(1),
|
2014-07-16 20:26:30 +02:00
|
|
|
'path': responseMboxes[i].path.substr(1) };
|
2014-01-27 21:43:48 +01:00
|
|
|
userMailboxes.push(mbox);
|
2010-08-27 16:56:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateFilterFromEditor(filterId, filterJSON) {
|
|
|
|
var filter = filterJSON.evalJSON();
|
2010-03-02 20:57:30 +01:00
|
|
|
var sanitized = {};
|
|
|
|
for (var k in filter) {
|
|
|
|
if (!(k == "rules" && filter.match == "allmessages")) {
|
|
|
|
sanitized[k] = filter[k];
|
|
|
|
}
|
|
|
|
}
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-03-02 20:57:30 +01:00
|
|
|
var table = $("filtersList");
|
|
|
|
if (filterId == "new") {
|
|
|
|
var newNumber = filters.length;
|
|
|
|
filters.push(sanitized);
|
|
|
|
appendSieveFilterRow(table, newNumber, sanitized);
|
|
|
|
} else {
|
|
|
|
filters[filterId] = sanitized;
|
|
|
|
updateSieveFilterRow(table, filterId, sanitized);
|
|
|
|
}
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
/* mail accounts */
|
|
|
|
function initMailAccounts() {
|
|
|
|
var mailAccountsJSON = $("mailAccountsJSON");
|
2013-12-05 15:00:01 +01:00
|
|
|
if (mailAccountsJSON) {
|
|
|
|
mailAccounts = mailAccountsJSON.value.evalJSON();
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-12-05 15:00:01 +01:00
|
|
|
var mailAccountsList = $("mailAccountsList");
|
|
|
|
if (mailAccountsList) {
|
|
|
|
var li = createMailAccountLI(mailAccounts[0], true);
|
2010-08-06 17:34:05 +02:00
|
|
|
mailAccountsList.appendChild(li);
|
2013-12-05 15:00:01 +01:00
|
|
|
for (var i = 1; i < mailAccounts.length; i++) {
|
|
|
|
li = createMailAccountLI(mailAccounts[i]);
|
|
|
|
mailAccountsList.appendChild(li);
|
|
|
|
}
|
|
|
|
var lis = mailAccountsList.childNodesWithTag("li");
|
|
|
|
lis[0].readOnly = true;
|
|
|
|
lis[0].selectElement();
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-12-05 15:00:01 +01:00
|
|
|
var button = $("mailAccountAdd");
|
|
|
|
if (button) {
|
|
|
|
button.observe("click", onMailAccountAdd);
|
|
|
|
}
|
|
|
|
button = $("mailAccountDelete");
|
|
|
|
if (button) {
|
|
|
|
button.observe("click", onMailAccountDelete);
|
|
|
|
}
|
2010-08-06 17:34:05 +02:00
|
|
|
}
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-12-05 15:00:01 +01:00
|
|
|
var inputs = $$("#accountInfo input");
|
|
|
|
for (var i = 0; i < inputs.length; i++) {
|
|
|
|
$(inputs[i]).observe("change", onMailAccountInfoChange);
|
|
|
|
}
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-12-05 15:00:01 +01:00
|
|
|
inputs = $$("#identityInfo input");
|
|
|
|
for (var i = 0; i < inputs.length; i++) {
|
|
|
|
$(inputs[i]).observe("change", onMailIdentityInfoChange);
|
|
|
|
}
|
|
|
|
$("actSignature").observe("click", onMailIdentitySignatureClick);
|
|
|
|
displayMailAccount(mailAccounts[0], true);
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-12-05 15:00:01 +01:00
|
|
|
inputs = $$("#returnReceiptsInfo input");
|
|
|
|
for (var i = 0; i < inputs.length; i++) {
|
|
|
|
$(inputs[i]).observe("change", onMailReceiptInfoChange);
|
|
|
|
}
|
|
|
|
inputs = $$("#returnReceiptsInfo select");
|
|
|
|
for (var i = 0; i < inputs.length; i++) {
|
|
|
|
$(inputs[i]).observe("change", onMailReceiptActionChange);
|
|
|
|
}
|
2010-09-01 22:27:45 +02:00
|
|
|
}
|
2010-08-06 17:34:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onMailAccountInfoChange(event) {
|
|
|
|
this.mailAccount[this.name] = this.value;
|
|
|
|
var hasChanged = $("hasChanged");
|
|
|
|
hasChanged.value = "1";
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMailIdentityInfoChange(event) {
|
|
|
|
if (!this.mailAccount["identities"]) {
|
|
|
|
this.mailAccount["identities"] = [{}];
|
|
|
|
}
|
|
|
|
var identity = this.mailAccount["identities"][0];
|
|
|
|
identity[this.name] = this.value;
|
|
|
|
var hasChanged = $("hasChanged");
|
|
|
|
hasChanged.value = "1";
|
|
|
|
}
|
|
|
|
|
2010-09-01 22:27:45 +02:00
|
|
|
function onMailReceiptInfoChange(event) {
|
|
|
|
if (!this.mailAccount["receipts"]) {
|
|
|
|
this.mailAccount["receipts"] = {};
|
|
|
|
}
|
|
|
|
var keyName = this.name.cssIdToHungarianId();
|
|
|
|
this.mailAccount["receipts"][keyName] = this.value;
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-09-01 22:27:45 +02:00
|
|
|
var popupIds = [ "receipt-non-recipient-action",
|
2014-07-16 20:26:30 +02:00
|
|
|
"receipt-outside-domain-action",
|
|
|
|
"receipt-any-action" ];
|
2010-09-01 22:27:45 +02:00
|
|
|
var receiptActionsDisable = (this.value == "ignore");
|
|
|
|
for (var i = 0; i < popupIds.length; i++) {
|
|
|
|
var actionPopup = $(popupIds[i]);
|
|
|
|
actionPopup.disabled = receiptActionsDisable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMailReceiptActionChange(event) {
|
|
|
|
if (!this.mailAccount["receipts"]) {
|
|
|
|
this.mailAccount["receipts"] = {};
|
|
|
|
}
|
|
|
|
var keyName = this.name.cssIdToHungarianId();
|
|
|
|
this.mailAccount["receipts"][keyName] = this.value;
|
|
|
|
}
|
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
function onMailIdentitySignatureClick(event) {
|
|
|
|
if (!this.readOnly) {
|
|
|
|
var dialogId = "signatureDialog";
|
|
|
|
var dialog = dialogs[dialogId];
|
|
|
|
if (!dialog) {
|
|
|
|
var label = _("Please enter your signature below:");
|
|
|
|
var fields = createElement("p");
|
|
|
|
fields.appendChild(createElement("textarea", "signature"));
|
|
|
|
fields.appendChild(createButton("okBtn", _("OK"),
|
|
|
|
onMailIdentitySignatureOK));
|
|
|
|
fields.appendChild(createButton("cancelBtn", _("Cancel"),
|
2012-09-24 21:27:18 +02:00
|
|
|
disposeDialog));
|
2010-08-06 17:34:05 +02:00
|
|
|
var dialog = createDialog(dialogId,
|
|
|
|
_("Signature"),
|
|
|
|
label,
|
|
|
|
fields,
|
|
|
|
"none");
|
2012-03-14 21:06:16 +01:00
|
|
|
if (Prototype.Browser.IE)
|
|
|
|
// Overwrite some fixes from iefixes.css
|
|
|
|
dialog.setStyle({ width: 'auto', marginLeft: 'auto' });
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
document.body.appendChild(dialog);
|
|
|
|
dialogs[dialogId] = dialog;
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
if ($("composeMessagesType").value != 0) {
|
|
|
|
CKEDITOR.replace('signature',
|
2014-01-08 21:02:41 +01:00
|
|
|
{ height: "150px",
|
2014-07-16 20:26:30 +02:00
|
|
|
toolbar: [['Bold', 'Italic', '-', 'Link',
|
|
|
|
'Font','FontSize','-','TextColor',
|
2014-12-15 16:52:04 +01:00
|
|
|
'BGColor'], ['Source']
|
2014-07-16 20:26:30 +02:00
|
|
|
],
|
|
|
|
language: localeCode,
|
|
|
|
scayt_sLang: localeCode });
|
2010-08-06 17:34:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
dialog.mailAccount = this.mailAccount;
|
|
|
|
if (!this.mailAccount["identities"]) {
|
|
|
|
this.mailAccount["identities"] = [{}];
|
|
|
|
}
|
|
|
|
var identity = this.mailAccount["identities"][0];
|
|
|
|
var area = $("signature");
|
2011-10-07 22:35:14 +02:00
|
|
|
if (typeof(identity["signature"]) != "undefined")
|
|
|
|
area.value = identity["signature"];
|
|
|
|
else
|
|
|
|
area.value = "";
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
$("bgDialogDiv").show();
|
2012-09-24 21:27:18 +02:00
|
|
|
if (Prototype.Browser.IE)
|
|
|
|
jQuery('#bgDialogDiv').css('opacity', 0.4);
|
|
|
|
jQuery(dialog).fadeIn('fast', function() {
|
2014-07-16 20:26:30 +02:00
|
|
|
if (CKEDITOR.instances["signature"])
|
|
|
|
focusCKEditor();
|
|
|
|
else
|
|
|
|
area.focus();
|
|
|
|
});
|
2012-03-14 21:06:16 +01:00
|
|
|
Event.stop(event);
|
2010-08-06 17:34:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-14 21:06:16 +01:00
|
|
|
function focusCKEditor() {
|
2013-01-15 23:46:19 +01:00
|
|
|
if (CKEDITOR.status != 'loaded')
|
2012-03-14 21:06:16 +01:00
|
|
|
setTimeout("focusCKEditor()", 100);
|
|
|
|
else
|
2013-01-15 23:46:19 +01:00
|
|
|
CKEDITOR.instances.signature.focus()
|
2014-07-16 20:26:30 +02:00
|
|
|
}
|
2012-03-14 21:06:16 +01:00
|
|
|
|
|
|
|
function hideSignature() {
|
2013-01-15 23:46:19 +01:00
|
|
|
if (CKEDITOR.status != 'loaded')
|
2012-03-14 21:06:16 +01:00
|
|
|
setTimeout("hideSignature()", 100);
|
|
|
|
else
|
2013-01-15 23:46:19 +01:00
|
|
|
disposeDialog("signatureDialog");
|
2012-03-14 21:06:16 +01:00
|
|
|
}
|
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
function onMailIdentitySignatureOK(event) {
|
|
|
|
var dialog = $("signatureDialog");
|
|
|
|
var mailAccount = dialog.mailAccount;
|
|
|
|
if (!mailAccount["identities"]) {
|
|
|
|
mailAccount["identities"] = [{}];
|
|
|
|
}
|
|
|
|
var identity = mailAccount["identities"][0];
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
var content = (CKEDITOR.instances["signature"]
|
|
|
|
? CKEDITOR.instances["signature"].getData()
|
|
|
|
: $("signature").value);
|
|
|
|
identity["signature"] = content;
|
|
|
|
displayAccountSignature(mailAccount);
|
2012-03-14 21:06:16 +01:00
|
|
|
hideSignature();
|
2010-08-06 17:34:05 +02:00
|
|
|
dialog.mailAccount = null;
|
|
|
|
var hasChanged = $("hasChanged");
|
|
|
|
hasChanged.value = "1";
|
|
|
|
}
|
|
|
|
|
|
|
|
function createMailAccountLI(mailAccount, readOnly) {
|
|
|
|
var li = createElement("li");
|
|
|
|
li.appendChild(document.createTextNode(mailAccount["name"]));
|
|
|
|
li.observe("click", onMailAccountEntryClick);
|
|
|
|
li.observe("mousedown", onRowClick);
|
|
|
|
if (readOnly) {
|
|
|
|
li.addClassName("readonly");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var editionCtlr = new RowEditionController();
|
|
|
|
editionCtlr.attachToRowElement(li);
|
|
|
|
editionCtlr.notifyNewValueCallback = function(ignore, newValue) {
|
|
|
|
mailAccount["name"] = newValue;
|
|
|
|
};
|
|
|
|
li.editionController = editionCtlr;
|
|
|
|
}
|
|
|
|
li.mailAccount = mailAccount;
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
return li;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMailAccountEntryClick(event) {
|
|
|
|
displayMailAccount(this.mailAccount, this.readOnly);
|
|
|
|
}
|
|
|
|
|
|
|
|
function displayMailAccount(mailAccount, readOnly) {
|
2012-05-14 19:11:10 +02:00
|
|
|
var inputs = $$("#accountInfo input");
|
2013-11-13 20:46:08 +01:00
|
|
|
inputs.each(function(i) {
|
2014-07-16 20:26:30 +02:00
|
|
|
i.disabled = readOnly;
|
|
|
|
i.mailAccount = mailAccount;
|
|
|
|
});
|
|
|
|
|
2012-05-14 19:11:10 +02:00
|
|
|
inputs = $$("#identityInfo input");
|
2013-11-13 20:46:08 +01:00
|
|
|
inputs.each(function(i) { i.mailAccount = mailAccount; });
|
2012-04-20 15:37:46 +02:00
|
|
|
if (!mailCustomFromEnabled) {
|
|
|
|
for (var i = 0; i < 2; i++) {
|
|
|
|
inputs[i].disabled = readOnly;
|
|
|
|
}
|
2010-08-06 17:34:05 +02:00
|
|
|
}
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-09-01 22:27:45 +02:00
|
|
|
var form = $("mainForm");
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-09-01 22:27:45 +02:00
|
|
|
var encryption = "none";
|
2010-08-06 17:34:05 +02:00
|
|
|
var encRadioValues = [ "none", "ssl", "tls" ];
|
|
|
|
if (mailAccount["encryption"]) {
|
|
|
|
encryption = mailAccount["encryption"];
|
|
|
|
}
|
|
|
|
form.setRadioValue("encryption", encRadioValues.indexOf(encryption));
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
var port;
|
|
|
|
if (mailAccount["port"]) {
|
|
|
|
port = mailAccount["port"];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (encryption == "ssl") {
|
|
|
|
port = 993;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
port = 143;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$("port").value = port;
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
$("serverName").value = mailAccount["serverName"];
|
|
|
|
$("userName").value = mailAccount["userName"];
|
|
|
|
$("password").value = mailAccount["password"];
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
var identity = (mailAccount["identities"]
|
|
|
|
? mailAccount["identities"][0]
|
|
|
|
: {} );
|
|
|
|
$("fullName").value = identity["fullName"] || "";
|
|
|
|
$("email").value = identity["email"] || "";
|
2012-04-20 15:27:21 +02:00
|
|
|
$("replyTo").value = identity["replyTo"] || "";
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
displayAccountSignature(mailAccount);
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-09-01 22:27:45 +02:00
|
|
|
var receiptAction = "ignore";
|
|
|
|
var receiptActionValues = [ "ignore", "allow" ];
|
|
|
|
if (mailAccount["receipts"] && mailAccount["receipts"]["receiptAction"]) {
|
|
|
|
receiptAction = mailAccount["receipts"]["receiptAction"];
|
|
|
|
}
|
|
|
|
for (var i = 0; i < receiptActionValues.length; i++) {
|
|
|
|
var keyName = "receipt-action-" + receiptActionValues[i];
|
|
|
|
var input = $(keyName);
|
|
|
|
input.mailAccount = mailAccount;
|
|
|
|
}
|
|
|
|
form.setRadioValue("receipt-action",
|
|
|
|
receiptActionValues.indexOf(receiptAction));
|
|
|
|
var popupIds = [ "receipt-non-recipient-action",
|
2014-07-16 20:26:30 +02:00
|
|
|
"receipt-outside-domain-action",
|
|
|
|
"receipt-any-action" ];
|
2010-09-01 22:27:45 +02:00
|
|
|
var receiptActionsDisable = (receiptAction == "ignore");
|
|
|
|
for (var i = 0; i < popupIds.length; i++) {
|
|
|
|
var actionPopup = $(popupIds[i]);
|
|
|
|
actionPopup.disabled = receiptActionsDisable;
|
|
|
|
var settingValue = "ignore";
|
|
|
|
var settingName = popupIds[i].cssIdToHungarianId();
|
|
|
|
if (mailAccount["receipts"] && mailAccount["receipts"][settingName]) {
|
|
|
|
settingValue = mailAccount["receipts"][settingName];
|
|
|
|
}
|
|
|
|
actionPopup.value = settingValue;
|
|
|
|
actionPopup.mailAccount = mailAccount;
|
|
|
|
}
|
2010-08-06 17:34:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function displayAccountSignature(mailAccount) {
|
|
|
|
var actSignature = $("actSignature");
|
|
|
|
actSignature.mailAccount = mailAccount;
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
var actSignatureValue;
|
|
|
|
var identity = (mailAccount["identities"]
|
|
|
|
? mailAccount["identities"][0]
|
|
|
|
: {} );
|
2011-10-07 22:35:14 +02:00
|
|
|
var value = identity["signature"];
|
|
|
|
if (value && value.length > 0)
|
|
|
|
value = value.stripTags().unescapeHTML().replace(/^[ \n\r]*/, "");
|
2010-08-06 17:34:05 +02:00
|
|
|
if (value && value.length > 0) {
|
|
|
|
if (value.length < 30) {
|
|
|
|
actSignatureValue = value;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
actSignatureValue = value.substr(0, 30) + "...";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
actSignatureValue = _("(Click to create)");
|
|
|
|
}
|
|
|
|
while (actSignature.firstChild) {
|
|
|
|
actSignature.removeChild(actSignature.firstChild);
|
|
|
|
}
|
2011-03-21 21:09:56 +01:00
|
|
|
actSignature.update(actSignatureValue);
|
2010-08-06 17:34:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function createMailAccount() {
|
|
|
|
var firstIdentity = mailAccounts[0]["identities"][0];
|
|
|
|
var newIdentity = {};
|
|
|
|
for (var k in firstIdentity) {
|
|
|
|
newIdentity[k] = firstIdentity[k];
|
|
|
|
}
|
|
|
|
delete newIdentity["isDefault"];
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
var newMailAccount = { name: _("New Mail Account"),
|
2014-07-16 20:26:30 +02:00
|
|
|
serverName: "mailserver",
|
|
|
|
userName: UserLogin,
|
|
|
|
password: "",
|
|
|
|
identities: [ newIdentity ] };
|
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
return newMailAccount;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMailAccountAdd(event) {
|
|
|
|
var newMailAccount = createMailAccount();
|
|
|
|
mailAccounts.push(newMailAccount);
|
|
|
|
var li = createMailAccountLI(newMailAccount);
|
|
|
|
var mailAccountsList = $("mailAccountsList");
|
|
|
|
mailAccountsList.appendChild(li);
|
|
|
|
var selection = mailAccountsList.getSelectedNodes();
|
|
|
|
for (var i = 0; i < selection.length; i++) {
|
|
|
|
selection[i].deselect();
|
|
|
|
}
|
|
|
|
displayMailAccount(newMailAccount, false);
|
|
|
|
li.selectElement();
|
|
|
|
li.editionController.startEditing();
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-08-09 15:25:02 +02:00
|
|
|
var hasChanged = $("hasChanged");
|
|
|
|
hasChanged.value = "1";
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
event.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMailAccountDelete(event) {
|
|
|
|
var mailAccountsList = $("mailAccountsList");
|
|
|
|
var selection = mailAccountsList.getSelectedNodes();
|
|
|
|
if (selection.length > 0) {
|
|
|
|
var li = selection[0];
|
|
|
|
if (!li.readOnly) {
|
|
|
|
li.deselect();
|
|
|
|
li.editionController = null;
|
|
|
|
var next = li.next();
|
|
|
|
if (!next) {
|
|
|
|
next = li.previous();
|
|
|
|
}
|
|
|
|
mailAccountsList.removeChild(li);
|
|
|
|
var index = mailAccounts.indexOf(li.mailAccount);
|
|
|
|
mailAccounts.splice(index, 1);
|
|
|
|
next.selectElement();
|
|
|
|
displayMailAccount(next.mailAccount, next.readOnly);
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-08-09 15:25:02 +02:00
|
|
|
var hasChanged = $("hasChanged");
|
|
|
|
hasChanged.value = "1";
|
2010-08-06 17:34:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
event.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
function saveMailAccounts() {
|
|
|
|
/* This removal enables us to avoid a few warning from SOPE for the inputs
|
2014-07-16 20:26:30 +02:00
|
|
|
that were created dynamically. */
|
2010-08-06 17:34:05 +02:00
|
|
|
var editor = $("mailAccountEditor");
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2011-02-24 01:02:24 +01:00
|
|
|
// Could be null if ModuleConstraints disables email access
|
|
|
|
if (editor)
|
2014-07-30 16:31:25 +02:00
|
|
|
//Instead of removing the modules, we disable it. This will prevent the window to crash if we have a connection error.
|
|
|
|
editor.select('input, select').each(function(i) { i.disable(); })
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2014-07-30 16:31:25 +02:00
|
|
|
compactMailAccounts();
|
2010-08-06 17:34:05 +02:00
|
|
|
var mailAccountsJSON = $("mailAccountsJSON");
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2011-02-24 01:02:24 +01:00
|
|
|
if (mailAccountsJSON)
|
|
|
|
mailAccountsJSON.value = Object.toJSON(mailAccounts);
|
2010-08-06 17:34:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function compactMailAccounts() {
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2011-02-24 01:02:24 +01:00
|
|
|
if (!mailAccounts)
|
|
|
|
return;
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
for (var i = 1; i < mailAccounts.length; i++) {
|
|
|
|
var account = mailAccounts[i];
|
|
|
|
var encryption = account["encryption"];
|
|
|
|
if (encryption) {
|
|
|
|
if (encryption == "none") {
|
|
|
|
delete account["encryption"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
encryption = "none";
|
|
|
|
}
|
|
|
|
var port = account["port"];
|
|
|
|
if (port) {
|
|
|
|
if ((encryption == "ssl" && port == 993)
|
|
|
|
|| port == 143) {
|
|
|
|
delete account["port"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-11 16:49:58 +01:00
|
|
|
/* common function between calendar categories and mail labels */
|
2013-11-15 21:50:46 +01:00
|
|
|
function onColorEdit(e, target) {
|
|
|
|
var view = $(target);
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-11-15 21:50:46 +01:00
|
|
|
view.select('div.colorEditing').each(function(box) {
|
2014-07-16 20:26:30 +02:00
|
|
|
box.removeClassName('colorEditing');
|
|
|
|
});
|
2013-11-13 20:46:08 +01:00
|
|
|
this.addClassName("colorEditing");
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-11-15 21:50:46 +01:00
|
|
|
var cellPosition = this.cumulativeOffset();
|
|
|
|
var cellDimensions = this.getDimensions();
|
|
|
|
var div = $('colorPickerDialog');
|
|
|
|
var divDimensions = div.getDimensions();
|
|
|
|
var left = cellPosition[0] - divDimensions["width"];
|
|
|
|
var top = cellPosition[1] - 165 - view.scrollTop;
|
|
|
|
div.setStyle({ left: left + "px", top: top + "px" });
|
|
|
|
div.writeAttribute('data-target', target);
|
|
|
|
div.show();
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
2013-11-15 21:50:46 +01:00
|
|
|
function onColorPickerChoice(event) {
|
|
|
|
var span = getTarget(event);
|
|
|
|
var dialog = span.up('.dialog');
|
|
|
|
var target = dialog.readAttribute('data-target');
|
|
|
|
var newColor = "#" + span.className.substr(4);
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-11-15 21:50:46 +01:00
|
|
|
var wrapper = $(target);
|
|
|
|
var div = wrapper.select("div.colorEditing").first();
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-11-15 21:50:46 +01:00
|
|
|
div.writeAttribute('data-color', newColor);
|
2009-08-04 21:29:38 +02:00
|
|
|
div.style.background = newColor;
|
2010-08-09 15:25:02 +02:00
|
|
|
if (parseInt($("hasChanged").value) == 0) {
|
|
|
|
var hasChanged = $("hasChanged");
|
|
|
|
hasChanged.value = "1";
|
|
|
|
}
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-11-15 21:50:46 +01:00
|
|
|
dialog.hide();
|
|
|
|
}
|
2013-11-11 16:49:58 +01:00
|
|
|
|
|
|
|
/* calendar categories */
|
|
|
|
function resetCalendarTableActions() {
|
|
|
|
var r = $$("#calendarCategoriesListWrapper tbody tr");
|
|
|
|
for (var i = 0; i < r.length; i++) {
|
|
|
|
var row = $(r[i]);
|
|
|
|
row.observe("mousedown", onRowClick);
|
|
|
|
var tds = row.childElements();
|
|
|
|
var editionCtlr = new RowEditionController();
|
|
|
|
editionCtlr.attachToRowElement(tds[0]);
|
2013-11-13 20:46:08 +01:00
|
|
|
tds[1].childElements()[0].observe("click", onCalendarColorEdit);
|
2013-11-11 16:49:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-13 20:46:08 +01:00
|
|
|
function onCalendarColorEdit(e) {
|
2013-11-11 16:49:58 +01:00
|
|
|
var onCCE = onColorEdit.bind(this);
|
2013-11-15 21:50:46 +01:00
|
|
|
onCCE(e, "calendarCategoriesListWrapper");
|
2013-11-11 16:49:58 +01:00
|
|
|
}
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2014-07-04 15:51:41 +02:00
|
|
|
function makeEditable (element) {
|
2014-07-16 20:08:39 +02:00
|
|
|
element.addClassName("editing");
|
|
|
|
element.removeClassName("whiteListCell");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
var span = element.down("SPAN");
|
|
|
|
span.update();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
var textField = element.down("INPUT");
|
|
|
|
textField.show();
|
|
|
|
textField.focus();
|
|
|
|
textField.select();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
return true;
|
2014-07-04 15:51:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function endAllEditables (e) {
|
2014-07-16 20:08:39 +02:00
|
|
|
var r = $$("TABLE#tableViewWhiteList TBODY TR TD");
|
|
|
|
for (var i = 0; i < r.length; i++) {
|
|
|
|
var element = $(r[i]);
|
|
|
|
if (r[i] != this && element.hasClassName("editing"))
|
|
|
|
endEditable(null, element.down("INPUT"));
|
|
|
|
}
|
2014-07-04 15:51:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onNameEdit (e) {
|
2014-07-16 20:08:39 +02:00
|
|
|
endAllEditables();
|
|
|
|
if (!this.hasClassName("editing")) {
|
|
|
|
makeEditable (this);
|
|
|
|
}
|
2014-07-04 15:51:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function endEditable(event, textField) {
|
2014-07-16 20:08:39 +02:00
|
|
|
if (!textField)
|
|
|
|
textField = this;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
var uid = textField.readAttribute("uid");
|
|
|
|
var cell = textField.up("TD");
|
|
|
|
var textSpan = cell.down("SPAN");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
cell.removeClassName("editing");
|
|
|
|
cell.addClassName("whiteListCell");
|
|
|
|
textField.hide();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
var tmp = textField.value;
|
|
|
|
tmp = tmp.replace (/</, "<");
|
|
|
|
tmp = tmp.replace (/>/, ">");
|
|
|
|
if (!uid)
|
|
|
|
cell.up("TR").addClassName("notfound");
|
|
|
|
if (tmp)
|
|
|
|
textSpan.update(tmp);
|
|
|
|
else
|
|
|
|
cell.up("TR").remove();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
if (event)
|
|
|
|
Event.stop(event);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
return false;
|
2014-07-04 15:51:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onAppointmentsWhiteListAdd(e) {
|
2014-07-16 20:08:39 +02:00
|
|
|
var tablebody = $("appointmentsWhiteListWrapper").childNodesWithTag("table")[0].tBodies[0];
|
|
|
|
var row = new Element("tr");
|
|
|
|
var td = new Element("td").update("");
|
|
|
|
var textField = new Element("input");
|
|
|
|
var span = new Element("span");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
row.addClassName("whiteListRow");
|
|
|
|
row.observe("mousedown", onRowClick);
|
|
|
|
td.addClassName ("whiteListCell");
|
|
|
|
td.observe("mousedown", endAllEditables);
|
|
|
|
td.observe("dblclick", onNameEdit);
|
|
|
|
textField.addInterface(SOGoAutoCompletionInterface);
|
|
|
|
textField.SOGoUsersSearch = true;
|
|
|
|
textField.observe("autocompletion:changed", endEditable);
|
|
|
|
textField.addClassName("textField");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
td.appendChild(textField);
|
|
|
|
td.appendChild(span);
|
|
|
|
row.appendChild (td);
|
|
|
|
tablebody.appendChild(row);
|
|
|
|
$(tablebody).deselectAll();
|
|
|
|
row.selectElement();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
makeEditable(td);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-04 15:51:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onAppointmentsWhiteListDelete(e) {
|
2014-07-16 20:08:39 +02:00
|
|
|
var list = $('appointmentsWhiteListWrapper').down("TABLE").down("TBODY");
|
|
|
|
var rows = list.getSelectedNodes();
|
|
|
|
var count = rows.length;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:08:39 +02:00
|
|
|
for (var i=0; i < count; i++) {
|
|
|
|
rows[i].editionController = null;
|
|
|
|
rows[i].remove();
|
|
|
|
}
|
2014-07-04 15:51:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function serializeAppointmentsWhiteList() {
|
2014-07-16 20:08:39 +02:00
|
|
|
var r = $$("#appointmentsWhiteListWrapper TBODY TR");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-09-09 16:28:59 +02:00
|
|
|
var users = {};
|
2014-07-16 20:08:39 +02:00
|
|
|
for (var i = 0; i < r.length; i++) {
|
|
|
|
var tds = r[i].childElements().first().down("INPUT");
|
|
|
|
var uid = tds.getAttribute("uid");
|
|
|
|
var value = tds.getValue();
|
|
|
|
if (uid != null)
|
2014-09-09 16:28:59 +02:00
|
|
|
users[uid] = value;
|
2014-07-16 20:08:39 +02:00
|
|
|
}
|
2014-09-09 16:28:59 +02:00
|
|
|
$("whiteList").value = Object.toJSON(users);
|
2014-07-04 15:51:41 +02:00
|
|
|
}
|
|
|
|
|
2013-11-13 20:46:08 +01:00
|
|
|
function onCalendarCategoryAdd(e) {
|
|
|
|
var row = new Element("tr");
|
|
|
|
var nametd = new Element("td").update("");
|
|
|
|
var colortd = new Element("td");
|
2013-11-15 21:50:46 +01:00
|
|
|
var colordiv = new Element("div", {"class": "colorBox", dataColor: "#F0F0F0"});
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-11-13 20:46:08 +01:00
|
|
|
row.identify();
|
|
|
|
row.addClassName("categoryListRow");
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-11-13 20:46:08 +01:00
|
|
|
nametd.addClassName("categoryListCell");
|
|
|
|
colortd.addClassName("categoryListCell");
|
2013-11-15 21:50:46 +01:00
|
|
|
colordiv.setStyle({backgroundColor: "#F0F0F0"});
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-11-13 20:46:08 +01:00
|
|
|
colortd.appendChild(colordiv);
|
|
|
|
row.appendChild(nametd);
|
|
|
|
row.appendChild(colortd);
|
|
|
|
$("calendarCategoriesListWrapper").childNodesWithTag("table")[0].tBodies[0].appendChild(row);
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-11-13 20:46:08 +01:00
|
|
|
resetCalendarTableActions();
|
2010-08-02 22:42:40 +02:00
|
|
|
nametd.editionController.startEditing();
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
2013-11-13 20:46:08 +01:00
|
|
|
function onCalendarCategoryDelete(e) {
|
2010-10-26 21:26:50 +02:00
|
|
|
var list = $('calendarCategoriesListWrapper').down("TABLE").down("TBODY");
|
2009-08-04 21:29:38 +02:00
|
|
|
var rows = list.getSelectedNodes();
|
|
|
|
var count = rows.length;
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2009-08-04 21:29:38 +02:00
|
|
|
for (var i=0; i < count; i++) {
|
2010-08-02 22:55:45 +02:00
|
|
|
rows[i].editionController = null;
|
2013-11-13 20:46:08 +01:00
|
|
|
rows[i].remove();
|
2009-08-04 21:29:38 +02:00
|
|
|
}
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
2010-10-26 21:26:50 +02:00
|
|
|
function serializeCalendarCategories() {
|
|
|
|
var r = $$("#calendarCategoriesListWrapper TBODY TR");
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2009-12-01 17:53:15 +01:00
|
|
|
var values = [];
|
2009-08-04 21:29:38 +02:00
|
|
|
for (var i = 0; i < r.length; i++) {
|
2013-11-13 20:46:08 +01:00
|
|
|
var tds = r[i].childElements();
|
2014-07-07 16:00:16 +02:00
|
|
|
var name = $(tds.first()).innerHTML.trim();
|
2013-11-15 21:50:46 +01:00
|
|
|
var color = $(tds.last().childElements().first()).readAttribute('data-color');
|
2009-12-01 17:53:15 +01:00
|
|
|
values.push("\"" + name + "\": \"" + color + "\"");
|
2009-08-04 21:29:38 +02:00
|
|
|
}
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2010-10-26 21:26:50 +02:00
|
|
|
$("calendarCategoriesValue").value = "{ " + values.join(",\n") + "}";
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
2013-11-13 20:46:08 +01:00
|
|
|
function resetCalendarCategoriesColors(e) {
|
2010-10-26 21:26:50 +02:00
|
|
|
var divs = $$("#calendarCategoriesListWrapper DIV.colorBox");
|
2009-08-04 21:29:38 +02:00
|
|
|
for (var i = 0; i < divs.length; i++) {
|
2009-08-06 21:07:25 +02:00
|
|
|
var d = divs[i];
|
2013-11-15 21:50:46 +01:00
|
|
|
var color = d.readAttribute("data-color");
|
2009-08-06 21:07:25 +02:00
|
|
|
if (color != "undefined")
|
|
|
|
d.setStyle({ backgroundColor: color });
|
2009-08-04 21:29:38 +02:00
|
|
|
}
|
2008-09-28 21:49:17 +02:00
|
|
|
}
|
|
|
|
|
2010-10-26 21:26:50 +02:00
|
|
|
/* /calendar categories */
|
|
|
|
|
2013-11-11 16:49:58 +01:00
|
|
|
/* mail label/tags */
|
|
|
|
function resetMailTableActions() {
|
|
|
|
var r = $$("#mailLabelsListWrapper tbody tr");
|
|
|
|
for (var i = 0; i < r.length; i++) {
|
|
|
|
var row = $(r[i]);
|
|
|
|
row.observe("mousedown", onRowClick);
|
|
|
|
var tds = row.childElements();
|
|
|
|
var editionCtlr = new RowEditionController();
|
|
|
|
editionCtlr.attachToRowElement(tds[0]);
|
2013-11-13 20:46:08 +01:00
|
|
|
tds[1].childElements()[0].observe("click", onMailColorEdit);
|
2013-11-11 16:49:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-13 20:46:08 +01:00
|
|
|
function onMailColorEdit(e) {
|
2013-11-11 16:49:58 +01:00
|
|
|
var onMCE = onColorEdit.bind(this);
|
2013-11-15 21:50:46 +01:00
|
|
|
onMCE(e, "mailLabelsListWrapper");
|
2013-11-11 16:49:58 +01:00
|
|
|
}
|
|
|
|
|
2013-11-13 20:46:08 +01:00
|
|
|
function onMailLabelAdd(e) {
|
|
|
|
var row = new Element("tr");
|
|
|
|
var nametd = new Element("td").update("");
|
|
|
|
var colortd = new Element("td");
|
2013-11-15 21:50:46 +01:00
|
|
|
var colordiv = new Element("div", {"class": "colorBox", dataColor: "#F0F0F0"});
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-11-13 20:46:08 +01:00
|
|
|
row.identify();
|
|
|
|
row.addClassName("labelListRow");
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-11-13 20:46:08 +01:00
|
|
|
nametd.addClassName("labelListCell");
|
|
|
|
colortd.addClassName("labelListCell");
|
2013-11-15 21:50:46 +01:00
|
|
|
colordiv.setStyle({backgroundColor: "#F0F0F0"});
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-11-13 20:46:08 +01:00
|
|
|
colortd.appendChild(colordiv);
|
|
|
|
row.appendChild(nametd);
|
|
|
|
row.appendChild(colortd);
|
|
|
|
$("mailLabelsListWrapper").childNodesWithTag("table")[0].tBodies[0].appendChild(row);
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-11-13 20:46:08 +01:00
|
|
|
resetMailTableActions();
|
2013-11-11 16:49:58 +01:00
|
|
|
nametd.editionController.startEditing();
|
|
|
|
}
|
|
|
|
|
2013-11-13 20:46:08 +01:00
|
|
|
function onMailLabelDelete(e) {
|
2013-11-11 16:49:58 +01:00
|
|
|
var list = $('mailLabelsListWrapper').down("TABLE").down("TBODY");
|
|
|
|
var rows = list.getSelectedNodes();
|
|
|
|
var count = rows.length;
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-11-11 16:49:58 +01:00
|
|
|
for (var i=0; i < count; i++) {
|
|
|
|
rows[i].editionController = null;
|
2013-11-13 20:46:08 +01:00
|
|
|
rows[i].remove();
|
2013-11-11 16:49:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-13 20:46:08 +01:00
|
|
|
function resetMailLabelsColors(e) {
|
2013-11-11 16:49:58 +01:00
|
|
|
var divs = $$("#mailLabelsListWrapper DIV.colorBox");
|
|
|
|
for (var i = 0; i < divs.length; i++) {
|
|
|
|
var d = divs[i];
|
2013-11-15 21:50:46 +01:00
|
|
|
var color = d.readAttribute('data-color');
|
2013-11-11 16:49:58 +01:00
|
|
|
if (color != "undefined")
|
|
|
|
d.setStyle({ backgroundColor: color });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function serializeMailLabels() {
|
|
|
|
var r = $$("#mailLabelsListWrapper TBODY TR");
|
2014-07-16 20:26:30 +02:00
|
|
|
|
2013-11-11 16:49:58 +01:00
|
|
|
var values = [];
|
|
|
|
for (var i = 0; i < r.length; i++) {
|
2013-11-13 20:46:08 +01:00
|
|
|
var tds = r[i].childElements();
|
2014-07-16 20:26:30 +02:00
|
|
|
var name = r[i].readAttribute("data-name");
|
2013-11-13 20:46:08 +01:00
|
|
|
var label = $(tds.first()).innerHTML;
|
2013-11-15 21:50:46 +01:00
|
|
|
var color = $(tds.last().childElements().first()).readAttribute('data-color');
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2013-11-11 16:49:58 +01:00
|
|
|
/* if name is null, that's because we've just added a new tag */
|
|
|
|
if (!name) {
|
2013-11-14 15:00:19 +01:00
|
|
|
name = label.replace(/[ \(\)\/\{%\*<>\\\"]/g, "_");
|
2014-07-16 20:26:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
values.push("\"" + name + "\": [\"" + label + "\", \"" + color + "\"]");
|
|
|
|
}
|
|
|
|
|
|
|
|
$("mailLabelsValue").value = "{ " + values.join(",\n") + "}";
|
|
|
|
}
|
|
|
|
|
|
|
|
/* /mail label/tags */
|
|
|
|
|
|
|
|
|
|
|
|
/* contacts categories */
|
|
|
|
function resetContactsTableActions() {
|
|
|
|
var r = $$("#contactsCategoriesListWrapper tbody tr");
|
|
|
|
for (var i = 0; i < r.length; i++) {
|
|
|
|
var row = $(r[i]);
|
|
|
|
row.observe("mousedown", onRowClick);
|
|
|
|
var tds = row.childElements();
|
|
|
|
var editionCtlr = new RowEditionController();
|
|
|
|
editionCtlr.attachToRowElement(tds[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onContactsCategoryAdd(e) {
|
|
|
|
var row = new Element("tr");
|
|
|
|
row.identify();
|
|
|
|
row.addClassName("categoryListRow");
|
|
|
|
|
|
|
|
var nametd = new Element("td").update("");
|
|
|
|
nametd.addClassName("categoryListCell");
|
|
|
|
row.appendChild(nametd);
|
|
|
|
var list = $('contactsCategoriesListWrapper').down("TABLE").down("TBODY");
|
|
|
|
list.appendChild(row);
|
|
|
|
|
|
|
|
resetContactsTableActions();
|
|
|
|
nametd.editionController.startEditing();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onContactsCategoryDelete(e) {
|
|
|
|
var list = $('contactsCategoriesListWrapper').down("TABLE").down("TBODY");
|
|
|
|
var rows = list.getSelectedNodes();
|
|
|
|
var count = rows.length;
|
|
|
|
|
|
|
|
for (var i = 0; i < count; i++) {
|
|
|
|
rows[i].editionController = null;
|
|
|
|
rows[i].remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function serializeContactsCategories() {
|
|
|
|
var values = [];
|
|
|
|
|
|
|
|
var tds = $$("#contactsCategoriesListWrapper TBODY TD");
|
|
|
|
|
|
|
|
for (var i = 0; i < tds.length; i++) {
|
|
|
|
var td = $(tds[i]);
|
|
|
|
values.push(td.allTextContent());
|
|
|
|
}
|
|
|
|
|
|
|
|
$("contactsCategoriesValue").value = Object.toJSON(values);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* / contact categories */
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:26:30 +02:00
|
|
|
function onAddOutgoingAddressesCheck(checkBox) {
|
|
|
|
if (!checkBox) {
|
|
|
|
checkBox = $("addOutgoingAddresses");
|
|
|
|
}
|
|
|
|
$("addressBookList").disabled = !checkBox.checked;
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 20:26:30 +02:00
|
|
|
function onReplyPlacementListChange() {
|
|
|
|
if ($("replyPlacementList").value == 0) {
|
|
|
|
// Reply placement is above quote, signature can be place before of after quote
|
|
|
|
$("signaturePlacementList").disabled = false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Reply placement is bellow quote, signature is unconditionally placed after quote
|
|
|
|
$("signaturePlacementList").value = 1;
|
|
|
|
$("signaturePlacementList").disabled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onComposeMessagesTypeChange(event) {
|
|
|
|
// var textArea = $('signature');
|
|
|
|
|
|
|
|
if (this.value == 0) /* text */ {
|
|
|
|
if (CKEDITOR.instances["signature"]) {
|
|
|
|
var content = CKEDITOR.instances["signature"].getData();
|
|
|
|
var htmlEditorWidget = $('cke_signature');
|
|
|
|
htmlEditorWidget.parentNode.removeChild(htmlEditorWidget);
|
|
|
|
delete CKEDITOR.instances["signature"];
|
|
|
|
var textArea = $("signature");
|
|
|
|
textArea.value = content;
|
|
|
|
textArea.style.display = "";
|
|
|
|
textArea.style.visibility = "";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ($("signature") && !CKEDITOR.instances["signature"]) {
|
|
|
|
CKEDITOR.replace('signature',
|
|
|
|
{
|
|
|
|
height: "70px",
|
|
|
|
toolbar: [['Bold', 'Italic', '-', 'Link',
|
|
|
|
'Font','FontSize','-','TextColor',
|
|
|
|
'BGColor']
|
|
|
|
],
|
|
|
|
language: localeCode,
|
|
|
|
scayt_sLang: localeCode
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onChangePasswordClick(event) {
|
|
|
|
var field = $("newPasswordField");
|
|
|
|
var confirmationField = $("newPasswordConfirmationField");
|
|
|
|
if (field && confirmationField) {
|
|
|
|
var password = field.value;
|
|
|
|
if (password == confirmationField.value) {
|
|
|
|
if (password.length > 0) {
|
|
|
|
var loginValues = readLoginCookie();
|
|
|
|
var policy = new PasswordPolicy(loginValues[0],
|
|
|
|
loginValues[1]);
|
|
|
|
policy.setCallbacks(onPasswordChangeSuccess,
|
|
|
|
onPasswordChangeFailure);
|
|
|
|
policy.changePassword(password);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetLogMessage("passwordError", _("Password must not be empty."), "error");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SetLogMessage("passwordError", _("The passwords do not match. Please try again."), "error");
|
|
|
|
field.focus();
|
|
|
|
field.select();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
event.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onPasswordChangeSuccess(message) {
|
|
|
|
SetLogMessage("passwordError", message, "info");
|
|
|
|
}
|
|
|
|
|
|
|
|
function onPasswordChangeFailure(code, message) {
|
|
|
|
SetLogMessage("passwordError", message, "error");
|
|
|
|
}
|
|
|
|
|
|
|
|
document.observe("dom:loaded", initPreferences);
|