2010-03-02 20:57:30 +01:00
|
|
|
/* -*- Mode: java; tab-width: 2; c-label-minimum-indentation: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
|
|
|
|
var isSieveScriptsEnabled = false;
|
|
|
|
var filters = [];
|
2008-08-28 16:48:45 +02:00
|
|
|
|
2007-06-19 19:59:59 +02:00
|
|
|
function savePreferences(sender) {
|
2009-09-22 22:54:09 +02:00
|
|
|
var sendForm = true;
|
|
|
|
|
2009-08-04 21:29:38 +02:00
|
|
|
var sigList = $("signaturePlacementList");
|
|
|
|
if (sigList)
|
2009-09-22 22:54:09 +02:00
|
|
|
sigList.disabled = false;
|
2009-07-02 17:40:45 +02:00
|
|
|
|
2009-09-18 15:36:40 +02:00
|
|
|
if ($("categoriesList")) {
|
|
|
|
serializeCategories(null);
|
|
|
|
}
|
2007-06-19 19:59:59 +02:00
|
|
|
|
2009-09-22 22:54:09 +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);
|
|
|
|
if (selectedStart >= selectedEnd) {
|
|
|
|
alert (getLabel ("Day start time must be prior to day end time."));
|
|
|
|
sendForm = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-09 22:30:42 +02:00
|
|
|
if ($("enableVacation") && $("enableVacation").checked) {
|
|
|
|
if ($("autoReplyText").value.strip().length == 0
|
|
|
|
|| $("autoReplyEmailAddresses").value.strip().length == 0) {
|
|
|
|
alert(getLabel("Please specify your message and your email addresses for which you want to enable auto reply."));
|
|
|
|
sendForm = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($("enableForward") && $("enableForward").checked) {
|
|
|
|
if ($("forwardAddress").value.strip().length == 0) {
|
|
|
|
alert(getLabel("Please specify an address to which you want to forward your messages."));
|
|
|
|
sendForm = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-02 20:57:30 +01:00
|
|
|
if (isSieveScriptsEnabled) {
|
|
|
|
var jsonFilters = prototypeIfyFilters();
|
|
|
|
$("sieveFilters").setValue(jsonFilters.toJSON());
|
|
|
|
}
|
|
|
|
|
2009-09-22 22:54:09 +02:00
|
|
|
if (sendForm)
|
2010-03-02 20:57:30 +01:00
|
|
|
$("mainForm").submit();
|
2009-09-18 15:36:40 +02:00
|
|
|
|
2009-08-04 21:29:38 +02:00
|
|
|
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;
|
|
|
|
|
|
|
|
newFilter.rules = $([]);
|
|
|
|
for (var j = 0; j < filter.rules.length; j++) {
|
|
|
|
newFilter.rules.push($(filter.rules[j]));
|
|
|
|
}
|
|
|
|
|
|
|
|
newFilter.actions = $([]);
|
|
|
|
for (var j = 0; j < filter.actions.length; j++) {
|
|
|
|
newFilter.actions.push($(filter.actions[j]));
|
|
|
|
}
|
|
|
|
newFilters.push(newFilter);
|
|
|
|
}
|
|
|
|
|
|
|
|
return newFilters;
|
|
|
|
}
|
|
|
|
|
2008-07-25 20:44:31 +02:00
|
|
|
function _setupEvents(enable) {
|
2010-03-25 21:17:50 +01:00
|
|
|
var widgets = [ "timezone", "shortDateFormat", "longDateFormat",
|
|
|
|
"timeFormat", "weekStartDay", "dayStartTime", "dayEndTime",
|
|
|
|
"firstWeek", "messageCheck", "subscribedFoldersOnly",
|
|
|
|
"language"];
|
|
|
|
for (var i = 0; i < widgets.length; i++) {
|
|
|
|
var widget = $(widgets[i]);
|
|
|
|
if (widget) {
|
|
|
|
if (enable)
|
|
|
|
widget.observe("change", onChoiceChanged);
|
|
|
|
else
|
|
|
|
widget.stopObserving("change", onChoiceChanged);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-04 21:29:38 +02:00
|
|
|
$("replyPlacementList").observe ("change", onReplyPlacementListChange);
|
|
|
|
$("composeMessagesType").observe ("change", onComposeMessagesTypeChange);
|
2009-11-06 14:53:52 +01:00
|
|
|
|
|
|
|
var categoriesValue = $("categoriesValue");
|
|
|
|
if (categoriesValue)
|
|
|
|
categoriesValue.value = "";
|
2008-07-25 20:44:31 +02:00
|
|
|
}
|
|
|
|
|
2010-03-25 21:17:50 +01:00
|
|
|
function onChoiceChanged(event) {
|
|
|
|
var hasChanged = $("hasChanged");
|
|
|
|
hasChanged.value = "1";
|
|
|
|
|
|
|
|
_setupEvents(false);
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
if (addresses) addresses = addresses.split(/, */);
|
|
|
|
else addresses = new Array();
|
2009-10-15 00:11:13 +02:00
|
|
|
|
|
|
|
defaultAddresses.each(function(adr) {
|
|
|
|
for (var i = 0; i < addresses.length; i++)
|
|
|
|
if (adr == addresses[i])
|
|
|
|
break;
|
|
|
|
if (i == addresses.length)
|
|
|
|
addresses.push(adr);
|
|
|
|
});
|
|
|
|
|
|
|
|
$("autoReplyEmailAddresses").value = addresses.join(", ");
|
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() {
|
2010-03-02 20:57:30 +01:00
|
|
|
var filtersListWrapper = $("filtersListWrapper");
|
|
|
|
if (filtersListWrapper) {
|
|
|
|
isSieveScriptsEnabled = true;
|
|
|
|
}
|
2009-08-04 21:29:38 +02:00
|
|
|
_setupEvents(true);
|
|
|
|
if (typeof (initAdditionalPreferences) != "undefined")
|
|
|
|
initAdditionalPreferences();
|
|
|
|
|
|
|
|
if ($("signature")) {
|
2009-10-15 00:11:13 +02:00
|
|
|
onComposeMessagesTypeChange();
|
2009-08-04 21:29:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var table = $("categoriesList");
|
2009-09-18 15:36:40 +02:00
|
|
|
if (table) {
|
2009-10-15 00:11:13 +02:00
|
|
|
resetCategoriesColors(null);
|
2009-09-18 15:36:40 +02:00
|
|
|
var r = $$("TABLE#categoriesList tbody tr");
|
2009-10-15 00:11:13 +02:00
|
|
|
for (var i= 0; i < r.length; i++)
|
|
|
|
r[i].identify();
|
2009-09-18 15:36:40 +02:00
|
|
|
table.multiselect = true;
|
2009-10-15 00:11:13 +02:00
|
|
|
resetTableActions();
|
|
|
|
$("categoryAdd").observe("click", onCategoryAdd);
|
|
|
|
$("categoryDelete").observe("click", onCategoryDelete);
|
2009-09-18 15:36:40 +02:00
|
|
|
}
|
2009-09-10 20:19:12 +02:00
|
|
|
|
|
|
|
// Disable placement (after) if composing in HTML
|
|
|
|
if ($("composeMessagesType")) {
|
|
|
|
if ($("composeMessagesType").value == 1) {
|
|
|
|
$("replyPlacementList").selectedIndex = 0;
|
|
|
|
$("replyPlacementList").disabled = 1;
|
|
|
|
}
|
2009-10-06 20:12:07 +02:00
|
|
|
onReplyPlacementListChange ();
|
2009-09-10 20:19:12 +02:00
|
|
|
}
|
2009-10-15 00:11:13 +02:00
|
|
|
|
2010-03-08 16:18:05 +01:00
|
|
|
var button = $("addDefaultEmailAddresses");
|
|
|
|
if (button)
|
|
|
|
button.observe("click", addDefaultEmailAddresses);
|
|
|
|
|
|
|
|
var button = $("changePasswordBtn");
|
|
|
|
if (button)
|
|
|
|
button.observe("click", onChangePasswordClick);
|
2010-03-02 20:57:30 +01:00
|
|
|
|
|
|
|
initSieveFilters();
|
|
|
|
}
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
var nameColumn = createElement("td");
|
|
|
|
nameColumn.appendChild(document.createTextNode(filter["name"]));
|
|
|
|
row.appendChild(nameColumn);
|
|
|
|
|
|
|
|
var activeColumn = createElement("td", null, "activeColumn");
|
|
|
|
var cb = createElement("input", null, "checkBox",
|
|
|
|
{ checked: filter.active,
|
|
|
|
type: "checkbox" },
|
|
|
|
null, activeColumn);
|
|
|
|
var bound = onScriptActiveCheck.bindAsEventListener(cb);
|
|
|
|
cb.observe("change", bound);
|
|
|
|
row.appendChild(activeColumn);
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
var activeColumn = columns[1];
|
|
|
|
while (activeColumn.firstChild) {
|
|
|
|
activeColumn.removeChild(activeColumn.firstChild);
|
|
|
|
}
|
|
|
|
createElement("input", null, "checkBox",
|
|
|
|
{ checked: filter.active,
|
|
|
|
type: "checkbox" },
|
|
|
|
null, activeColumn);
|
|
|
|
}
|
|
|
|
|
|
|
|
function _editFilter(filterId) {
|
|
|
|
var urlstr = ApplicationBaseURL + "editFilter?filter=" + filterId;
|
|
|
|
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) {
|
|
|
|
log("onFilterAdd");
|
|
|
|
_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);
|
|
|
|
}
|
|
|
|
deletedFilters = deletedFilters.sort(function (x,y) { return x-y; });
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
function copyFilter(originalFilter) {
|
|
|
|
var newFilter = {};
|
|
|
|
|
|
|
|
newFilter.name = originalFilter.name;
|
|
|
|
newFilter.match = originalFilter.match;
|
|
|
|
newFilter.active = originalFilter.active;
|
|
|
|
newFilter.rules = [];
|
|
|
|
for (var i = 0; i < originalFilter.rules.length; i++) {
|
|
|
|
newFilter.rules.push(_copyFilterElement(originalFilter.rules[i]));
|
|
|
|
}
|
|
|
|
newFilter.actions = [];
|
|
|
|
for (var i = 0; i < originalFilter.actions.length; i++) {
|
|
|
|
newFilter.actions.push(_copyFilterElement(originalFilter.actions[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
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") {
|
|
|
|
newElement[k] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return newElement;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSieveCapabilitiesFromEditor() {
|
|
|
|
return sieveCapabilities;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getFilterFromEditor(filterId) {
|
|
|
|
return copyFilter(filters[filterId]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateFilterFromEditor(filterId, filter) {
|
|
|
|
var sanitized = {};
|
|
|
|
for (var k in filter) {
|
|
|
|
if (!(k == "rules" && filter.match == "allmessages")) {
|
|
|
|
sanitized[k] = filter[k];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2009-08-06 21:07:25 +02:00
|
|
|
function resetTableActions() {
|
2009-08-04 21:29:38 +02:00
|
|
|
var r = $$("TABLE#categoriesList tbody tr");
|
|
|
|
for (var i = 0; i < r.length; i++) {
|
|
|
|
var row = $(r[i]);
|
|
|
|
row.observe("mousedown", onRowClick);
|
2009-08-06 21:07:25 +02:00
|
|
|
var tds = row.childElements();
|
2009-08-04 21:29:38 +02:00
|
|
|
tds[0].observe("mousedown", endAllEditables);
|
2009-08-06 21:07:25 +02:00
|
|
|
tds[0].observe("dblclick", onNameEdit);
|
2009-08-04 21:29:38 +02:00
|
|
|
tds[1].observe("mousedown", endAllEditables);
|
2009-08-06 21:07:25 +02:00
|
|
|
tds[1].childElements()[0].observe ("dblclick", onColorEdit);
|
2009-08-04 21:29:38 +02:00
|
|
|
}
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function makeEditable (element) {
|
2009-08-04 21:29:38 +02:00
|
|
|
element.addClassName ("editing");
|
|
|
|
element.removeClassName ("categoryListCell");
|
|
|
|
var tmp = element.innerHTML;
|
|
|
|
element.innerHTML = "";
|
2009-11-26 02:09:50 +01:00
|
|
|
var textField = new Element ("input", {"type": "text"});
|
2009-08-04 21:29:38 +02:00
|
|
|
textField.value = tmp;
|
2009-11-26 02:09:50 +01:00
|
|
|
textField.setStyle({ width: '98%' });
|
2009-08-04 21:29:38 +02:00
|
|
|
textField.observe ("keydown", interceptEnter);
|
|
|
|
element.appendChild (textField);
|
|
|
|
textField.focus ();
|
|
|
|
textField.select ();
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function interceptEnter (e) {
|
2009-08-04 21:29:38 +02:00
|
|
|
if (e.keyCode == Event.KEY_RETURN) {
|
|
|
|
endAllEditables (null);
|
|
|
|
preventDefault (e);
|
|
|
|
return false;
|
|
|
|
}
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function endEditable (element) {
|
2009-08-04 21:29:38 +02:00
|
|
|
var tmp = element.childElements ().first ().value;
|
|
|
|
element.innerHTML = tmp;
|
|
|
|
element.removeClassName ("editing");
|
|
|
|
element.addClassName ("categoryListCell");
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function endAllEditables (e) {
|
2009-08-04 21:29:38 +02:00
|
|
|
var r = $$("TABLE#categoriesList tbody tr td");
|
|
|
|
for (var i=0; i<r.length; i++) {
|
|
|
|
if (r[i] != this && r[i].hasClassName ("editing"))
|
|
|
|
endEditable ($(r[i]));
|
|
|
|
}
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onNameEdit (e) {
|
2009-08-04 21:29:38 +02:00
|
|
|
endAllEditables ();
|
|
|
|
if (!this.hasClassName ("editing")) {
|
|
|
|
makeEditable (this);
|
|
|
|
}
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onColorEdit (e) {
|
2009-08-04 21:29:38 +02:00
|
|
|
var r = $$("TABLE#categoriesList tbody tr td div.colorEditing");
|
|
|
|
for (var i=0; i<r.length; i++)
|
|
|
|
r[i].removeClassName ("colorEditing");
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2009-08-04 21:29:38 +02:00
|
|
|
this.addClassName ("colorEditing");
|
|
|
|
var cPicker = window.open(ApplicationBaseURL + "../" + UserLogin
|
|
|
|
+ "/Calendar/colorPicker", "colorPicker",
|
|
|
|
"width=250,height=200,resizable=0,scrollbars=0"
|
|
|
|
+ "toolbar=0,location=0,directories=0,status=0,"
|
|
|
|
+ "menubar=0,copyhistory=0", "test"
|
|
|
|
);
|
|
|
|
cPicker.focus();
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2009-08-04 21:29:38 +02:00
|
|
|
preventDefault(e);
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onColorPickerChoice (newColor) {
|
2009-08-04 21:29:38 +02:00
|
|
|
var div = $$("TABLE#categoriesList tbody tr td div.colorEditing").first ();
|
|
|
|
// div.removeClassName ("colorEditing");
|
|
|
|
div.showColor = newColor;
|
|
|
|
div.style.background = newColor;
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function onCategoryAdd (e) {
|
2009-08-04 21:29:38 +02:00
|
|
|
var row = new Element ("tr");
|
|
|
|
var nametd = new Element ("td").update ("");
|
|
|
|
var colortd = new Element ("td");
|
|
|
|
var colordiv = new Element ("div", {"class": "colorBox"});
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2009-08-04 21:29:38 +02:00
|
|
|
row.identify ();
|
|
|
|
row.addClassName ("categoryListRow");
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2009-08-04 21:29:38 +02:00
|
|
|
nametd.addClassName ("categoryListCell");
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2009-08-04 21:29:38 +02:00
|
|
|
colortd.addClassName ("categoryListCell");
|
|
|
|
colordiv.innerHTML = " ";
|
|
|
|
colordiv.showColor = "#F0F0F0";
|
|
|
|
colordiv.style.background = colordiv.showColor;
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2009-08-04 21:29:38 +02:00
|
|
|
colortd.appendChild (colordiv);
|
|
|
|
row.appendChild (nametd);
|
|
|
|
row.appendChild (colortd);
|
|
|
|
$("categoriesList").tBodies[0].appendChild (row);
|
|
|
|
makeEditable (nametd);
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2009-08-04 21:29:38 +02:00
|
|
|
resetTableActions ();
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onCategoryDelete (e) {
|
2009-08-04 21:29:38 +02:00
|
|
|
var list = $('categoriesList').down("TBODY");;
|
|
|
|
var rows = list.getSelectedNodes();
|
|
|
|
var count = rows.length;
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2009-08-04 21:29:38 +02:00
|
|
|
for (var i=0; i < count; i++) {
|
|
|
|
rows[i].remove ();
|
|
|
|
}
|
2009-07-16 17:57:31 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function serializeCategories (e) {
|
2009-08-04 21:29:38 +02:00
|
|
|
var r = $$("TABLE#categoriesList tbody tr");
|
2009-07-16 17:57:31 +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++) {
|
|
|
|
var tds = r[i].childElements ();
|
|
|
|
var name = $(tds.first ()).innerHTML;
|
|
|
|
var color = $(tds.last ().childElements ().first ()).showColor;
|
2009-12-01 17:53:15 +01:00
|
|
|
values.push("\"" + name + "\": \"" + color + "\"");
|
2009-08-04 21:29:38 +02:00
|
|
|
}
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2009-12-01 17:53:15 +01:00
|
|
|
$("categoriesValue").value = "{ " + values.join(",\n") + "}";
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function resetCategoriesColors (e) {
|
2009-08-06 21:07:25 +02:00
|
|
|
var divs = $$("TABLE#categoriesList 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];
|
2009-08-04 21:29:38 +02:00
|
|
|
var color = d.innerHTML;
|
|
|
|
d.showColor = color;
|
2009-08-06 21:07:25 +02:00
|
|
|
if (color != "undefined")
|
|
|
|
d.setStyle({ backgroundColor: color });
|
|
|
|
d.update(" ");
|
2009-08-04 21:29:38 +02:00
|
|
|
}
|
2008-09-28 21:49:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onReplyPlacementListChange() {
|
2009-08-04 21:29:38 +02:00
|
|
|
// above = 0
|
|
|
|
if ($("replyPlacementList").value == 0) {
|
|
|
|
$("signaturePlacementList").disabled=false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("signaturePlacementList").value=1;
|
|
|
|
$("signaturePlacementList").disabled=true;
|
|
|
|
}
|
2008-07-25 20:44:31 +02:00
|
|
|
}
|
|
|
|
|
2009-08-06 21:07:25 +02:00
|
|
|
function onComposeMessagesTypeChange(event) {
|
2010-03-08 17:40:18 +01:00
|
|
|
// var textArea = $('signature');
|
|
|
|
|
|
|
|
if ($("composeMessagesType").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 (!CKEDITOR.instances["signature"]) {
|
|
|
|
CKEDITOR.replace('signature',
|
|
|
|
{
|
|
|
|
height: "290px",
|
|
|
|
toolbar :
|
|
|
|
[['Bold', 'Italic', '-', 'Link',
|
|
|
|
'Font','FontSize','-','TextColor',
|
|
|
|
'BGColor']
|
|
|
|
]
|
|
|
|
}
|
|
|
|
);
|
2009-08-04 21:29:38 +02:00
|
|
|
}
|
2009-07-02 17:40:45 +02:00
|
|
|
}
|
2009-06-23 19:53:18 +02:00
|
|
|
}
|
|
|
|
|
2010-03-08 16:18:05 +01:00
|
|
|
function onChangePasswordClick(event) {
|
|
|
|
var field = $("newPasswordField");
|
|
|
|
var confirmationField = $("newPasswordConfirmationField");
|
|
|
|
if (field && confirmationField) {
|
|
|
|
var password = field.value;
|
|
|
|
if (password == confirmationField.value) {
|
2010-03-08 21:52:37 +01:00
|
|
|
if (password.length > 0) {
|
|
|
|
var loginValues = readLoginCookie();
|
|
|
|
var policy = new PasswordPolicy(loginValues[0],
|
|
|
|
loginValues[1]);
|
|
|
|
policy.setCallbacks(onPasswordChangeSuccess,
|
|
|
|
onPasswordChangeFailure);
|
|
|
|
policy.changePassword(password);
|
|
|
|
}
|
2010-03-08 16:18:05 +01:00
|
|
|
else
|
2010-03-08 21:52:37 +01:00
|
|
|
SetLogMessage("passwordError", _("Password must not be empty."),
|
2010-03-08 16:18:05 +01:00
|
|
|
"error");
|
|
|
|
}
|
|
|
|
else {
|
2010-03-08 21:52:37 +01:00
|
|
|
SetLogMessage("passwordError", _("The passwords do not match."
|
2010-03-08 16:18:05 +01:00
|
|
|
+ " Please try again."),
|
|
|
|
"error");
|
|
|
|
field.focus();
|
|
|
|
field.select();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
event.stop();
|
|
|
|
}
|
|
|
|
|
2010-03-08 21:52:37 +01:00
|
|
|
function onPasswordChangeSuccess(message) {
|
|
|
|
SetLogMessage("passwordError", message, "info");
|
2010-03-08 16:18:05 +01:00
|
|
|
}
|
|
|
|
|
2010-03-08 21:52:37 +01:00
|
|
|
function onPasswordChangeFailure(code, message) {
|
|
|
|
SetLogMessage("passwordError", message, "error");
|
2010-03-08 16:18:05 +01:00
|
|
|
}
|
|
|
|
|
2009-03-12 22:09:14 +01:00
|
|
|
document.observe("dom:loaded", initPreferences);
|