From eaec5a614d713d397b032f58f6d56ac3034165c6 Mon Sep 17 00:00:00 2001 From: Alexandre Cloutier Date: Wed, 16 Jul 2014 14:08:39 -0400 Subject: [PATCH] Change exception 403 to 409 and fix indentation in the javascript --- .../Appointments/SOGoAppointmentObject.m | 2 +- UI/WebServerResources/UIxPreferences.js | 1168 ++++++++--------- 2 files changed, 585 insertions(+), 585 deletions(-) diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 589374bb6..54de1997c 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -475,7 +475,7 @@ [reason appendString:@", "]; } [unavailableAttendees release]; - return [NSException exceptionWithHTTPStatus:403 reason: reason]; + return [NSException exceptionWithHTTPStatus:409 reason: reason]; } [unavailableAttendees release]; return nil; diff --git a/UI/WebServerResources/UIxPreferences.js b/UI/WebServerResources/UIxPreferences.js index 996e3a502..d0dc0e737 100644 --- a/UI/WebServerResources/UIxPreferences.js +++ b/UI/WebServerResources/UIxPreferences.js @@ -3,114 +3,114 @@ var mailAccounts = null; var dialogs = {}; function savePreferences(sender) { - var sendForm = true; - - var sigList = $("signaturePlacementList"); - if (sigList) - sigList.disabled = false; - - if ($("appointmentsWhiteListWrapper")) - serializeAppointmentsWhiteList(); - - if ($("calendarCategoriesListWrapper")) - serializeCalendarCategories(); - - if ($("contactsCategoriesListWrapper")) - serializeContactsCategories(); - - if ($("mailLabelsListWrapper")) - serializeMailLabels(); - - if (typeof mailCustomFromEnabled !== "undefined" && !emailRE.test($("email").value)) { - showAlertDialog(_("Please specify a valid sender address.")); - sendForm = false; - } - - if ($("replyTo")) { - var replyTo = $("replyTo").value; - if (!replyTo.blank() && !emailRE.test(replyTo)) { - showAlertDialog(_("Please specify a valid reply-to address.")); - sendForm = false; - } - } - - if ($("dayStartTime")) { - var start = $("dayStartTime"); - var selectedStart = parseInt(start.options[start.selectedIndex].value); - var end = $("dayEndTime"); - var selectedEnd = parseInt(end.options[end.selectedIndex].value); + var sendForm = true; - if (selectedStart >= selectedEnd) { - showAlertDialog (_("Day start time must be prior to day end time.")); - sendForm = false; - } - } - - 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; - } + var sigList = $("signaturePlacementList"); + if (sigList) + sigList.disabled = false; - if ($("autoReplyText").value.strip().endsWith('\n.')) { - showAlertDialog(_("Your vacation message must not end with a single dot on a line.")); - sendForm = false; - } + if ($("appointmentsWhiteListWrapper")) + serializeAppointmentsWhiteList(); - 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.")); + if ($("calendarCategoriesListWrapper")) + serializeCalendarCategories(); + + if ($("contactsCategoriesListWrapper")) + serializeContactsCategories(); + + if ($("mailLabelsListWrapper")) + serializeMailLabels(); + + if (typeof mailCustomFromEnabled !== "undefined" && !emailRE.test($("email").value)) { + showAlertDialog(_("Please specify a valid sender address.")); sendForm = false; - } } - } - - 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; - } - } - - if (typeof sieveCapabilities != "undefined") { - var jsonFilters = prototypeIfyFilters(); - $("sieveFilters").setValue(Object.toJSON(jsonFilters)); - } - - if (sendForm) { - saveMailAccounts(); - triggerAjaxRequest($("mainForm").readAttribute("action"), function (http) { - if (http.readyState == 4) { - var response = http.responseText.evalJSON(true); - if (http.status == 503) { - showAlertDialog(_(response.textStatus)); + if ($("replyTo")) { + var replyTo = $("replyTo").value; + if (!replyTo.blank() && !emailRE.test(replyTo)) { + showAlertDialog(_("Please specify a valid reply-to address.")); + sendForm = false; } - else if (http.status == 200) { - if (response.hasChanged == 1) { - window.opener.location.reload(); - window.close(); - } - else { - window.close(); - } + } + + 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) { + showAlertDialog (_("Day start time must be prior to day end time.")); + sendForm = false; } - else { - showAlertDialog(_(response.textStatus)); + } + + 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; } - } - }, - null, - Form.serialize($("mainForm")), // excludes the file input - { "Content-type": "application/x-www-form-urlencoded"} - ); + + if ($("autoReplyText").value.strip().endsWith('\n.')) { + showAlertDialog(_("Your vacation message must not end with a single dot on a line.")); + sendForm = false; + } + + 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; + } + } + } + + 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; + } + } + + if (typeof sieveCapabilities != "undefined") { + var jsonFilters = prototypeIfyFilters(); + $("sieveFilters").setValue(Object.toJSON(jsonFilters)); + } + + if (sendForm) { + saveMailAccounts(); + + triggerAjaxRequest($("mainForm").readAttribute("action"), function (http) { + 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)); + } + } + }, + null, + Form.serialize($("mainForm")), // excludes the file input + { "Content-type": "application/x-www-form-urlencoded"} + ); } - return false; + return false; } function prototypeIfyFilters() { @@ -121,14 +121,14 @@ function prototypeIfyFilters() { newFilter.name = filter.name; newFilter.match = filter.match; newFilter.active = filter.active; - + if (filter.rules) { newFilter.rules = $([]); for (var j = 0; j < filter.rules.length; j++) { newFilter.rules.push($(filter.rules[j])); } } - + if (filter.actions) { newFilter.actions = $([]); for (var j = 0; j < filter.actions.length; j++) { @@ -137,31 +137,31 @@ function prototypeIfyFilters() { } newFilters.push(newFilter); } - + return newFilters; } function _setupEvents() { var widgets = [ "timezone", "shortDateFormat", "longDateFormat", - "timeFormat", "weekStartDay", "dayStartTime", "dayEndTime", - "firstWeek", "messageCheck", "sortByThreads", "displayRemoteInlineImages", - "subscribedFoldersOnly", "language", "defaultCalendar", - "enableVacation" ]; + "timeFormat", "weekStartDay", "dayStartTime", "dayEndTime", + "firstWeek", "messageCheck", "sortByThreads", "displayRemoteInlineImages", + "subscribedFoldersOnly", "language", "defaultCalendar", + "enableVacation" ]; for (var i = 0; i < widgets.length; i++) { var widget = $(widgets[i]); if (widget) { widget.observe("change", onChoiceChanged); } } - + // We check for non-null elements as replyPlacementList and composeMessagesType // might not be present if ModulesConstraints disable those elements if ($("replyPlacementList")) $("replyPlacementList").on("change", onReplyPlacementListChange); - + if ($("composeMessagesType")) $("composeMessagesType").on("change", onComposeMessagesTypeChange); - + // Note: we also monitor changes to the calendar categories. // See functions endEditable and onColorPickerChoice. var valueInputs = [ "calendarCategoriesValue", "calendarCategoriesValue" ]; @@ -186,166 +186,166 @@ function onChoiceChanged(event) { function addDefaultEmailAddresses(event) { var defaultAddresses = $("defaultEmailAddresses").value.split(/, */); var addresses = $("autoReplyEmailAddresses").value.trim(); - + if (addresses) addresses = addresses.split(/, */); else addresses = new Array(); - + defaultAddresses.each(function(adr) { - for (var i = 0; i < addresses.length; i++) - if (adr == addresses[i]) - break; - if (i == addresses.length) - addresses.push(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(", "); - + event.stop(); } function initPreferences() { - var tabsContainer = $("preferencesTabs"); - var controller = new SOGoTabsController(); - controller.attachToTabsContainer(tabsContainer); - - // Inner tabs on the mail module tab - tabsContainer = $('mailOptionsTabs'); - if (tabsContainer) { - var mailController = new SOGoTabsController(); - mailController.attachToTabsContainer(tabsContainer); - } - - // Inner tabs on the calendar module tab - tabsContainer = $('calendarOptionsTabs'); - if (tabsContainer) { - var mailController = new SOGoTabsController(); - mailController.attachToTabsContainer(tabsContainer); - } - - _setupEvents(); - - // Optional function called when initializing the preferences - // Typically defined inline in the UIxAdditionalPreferences.wox template - if (typeof (initAdditionalPreferences) != "undefined") - initAdditionalPreferences(); - - // Color picker - $('colorPickerDialog').on('click', 'span', onColorPickerChoice); - $(document.body).on("click", onBodyClickHandler); - - // Calendar whiteList - var whiteList = $("appointmentsWhiteListWrapper"); - if(whiteList) { - var whiteListValue = $("whiteList").getValue(); - if (whiteListValue != "") { - whiteListValue = whiteListValue.split(","); - var tablebody = $("appointmentsWhiteListWrapper").childNodesWithTag("table")[0].tBodies[0]; - for (i = 0; i < whiteListValue.length; i++) - { - var elements = whiteListValue[i].split("="); - 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 = elements[1]; - textField.setAttribute("uid", elements[0]); - textField.hide(); - span.innerText = elements[1]; - - td.appendChild(textField); - td.appendChild(span); - row.appendChild (td); - tablebody.appendChild(row); - $(tablebody).deselectAll(); - - } + var tabsContainer = $("preferencesTabs"); + var controller = new SOGoTabsController(); + controller.attachToTabsContainer(tabsContainer); + + // Inner tabs on the mail module tab + tabsContainer = $('mailOptionsTabs'); + if (tabsContainer) { + var mailController = new SOGoTabsController(); + mailController.attachToTabsContainer(tabsContainer); } - var table = whiteList.childNodesWithTag("table")[0]; - table.multiselect = true; - $("appointmentsWhiteListAdd").observe("click", onAppointmentsWhiteListAdd); - $("appointmentsWhiteListDelete").observe("click", onAppointmentsWhiteListDelete); - } - - // 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); - } - - // 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); - } - - // 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); - } - - if ($("replyPlacementList")) - onReplyPlacementListChange(); - - var button = $("addDefaultEmailAddresses"); - if (button) - button.observe("click", addDefaultEmailAddresses); - - button = $("changePasswordBtn"); - if (button) - button.observe("click", onChangePasswordClick); - - initSieveFilters(); - - initMailAccounts(); - - button = $("enableVacationEndDate"); - if (button) { - jQuery("#vacationEndDate_date").closest(".date").datepicker( - { autoclose: true, position: 'above', weekStart: $('weekStartDay').getValue() }); - button.on("click", function(event) { - if (this.checked) - $("vacationEndDate_date").enable(); - else - $("vacationEndDate_date").disable(); - }); - } - onAddOutgoingAddressesCheck(); + // Inner tabs on the calendar module tab + tabsContainer = $('calendarOptionsTabs'); + if (tabsContainer) { + var mailController = new SOGoTabsController(); + mailController.attachToTabsContainer(tabsContainer); + } + + _setupEvents(); + + // Optional function called when initializing the preferences + // Typically defined inline in the UIxAdditionalPreferences.wox template + if (typeof (initAdditionalPreferences) != "undefined") + initAdditionalPreferences(); + + // Color picker + $('colorPickerDialog').on('click', 'span', onColorPickerChoice); + $(document.body).on("click", onBodyClickHandler); + + // Calendar whiteList + var whiteList = $("appointmentsWhiteListWrapper"); + if(whiteList) { + var whiteListValue = $("whiteList").getValue(); + if (whiteListValue != "") { + whiteListValue = whiteListValue.split(","); + var tablebody = $("appointmentsWhiteListWrapper").childNodesWithTag("table")[0].tBodies[0]; + for (i = 0; i < whiteListValue.length; i++) + { + var elements = whiteListValue[i].split("="); + 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 = elements[1]; + textField.setAttribute("uid", elements[0]); + textField.hide(); + span.innerText = elements[1]; + + td.appendChild(textField); + td.appendChild(span); + row.appendChild (td); + tablebody.appendChild(row); + $(tablebody).deselectAll(); + + } + } + + var table = whiteList.childNodesWithTag("table")[0]; + table.multiselect = true; + $("appointmentsWhiteListAdd").observe("click", onAppointmentsWhiteListAdd); + $("appointmentsWhiteListDelete").observe("click", onAppointmentsWhiteListDelete); + } + + // 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); + } + + // 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); + } + + // 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); + } + + if ($("replyPlacementList")) + onReplyPlacementListChange(); + + var button = $("addDefaultEmailAddresses"); + if (button) + button.observe("click", addDefaultEmailAddresses); + + button = $("changePasswordBtn"); + if (button) + button.observe("click", onChangePasswordClick); + + initSieveFilters(); + + initMailAccounts(); + + button = $("enableVacationEndDate"); + if (button) { + jQuery("#vacationEndDate_date").closest(".date").datepicker( + { autoclose: true, position: 'above', weekStart: $('weekStartDay').getValue() }); + button.on("click", function(event) { + if (this.checked) + $("vacationEndDate_date").enable(); + else + $("vacationEndDate_date").disable(); + }); + } + onAddOutgoingAddressesCheck(); } function initSieveFilters() { @@ -369,11 +369,11 @@ 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", { type: "checkbox" }, @@ -382,7 +382,7 @@ function appendSieveFilterRow(filterTable, number, filter) { var bound = onScriptActiveCheck.bindAsEventListener(cb); cb.observe("click", bound); row.appendChild(activeColumn); - + filterTable.tBodies[0].appendChild(row); } @@ -399,7 +399,7 @@ function updateSieveFilterRow(filterTable, number, filter) { nameColumn.removeChild(nameColumn.firstChild); } nameColumn.appendChild(document.createTextNode(filter.name)); - + var activeColumn = columns[1]; var cb = activeColumn.childNodesWithTag("input"); cb[0].checked = filter.active; @@ -478,7 +478,7 @@ function onFilterMoveDown(event) { function onFilterEdit(event) { _editFilter(this.rowIndex - 1); event.stop(); - + return false; } @@ -497,7 +497,7 @@ function copyFilter(originalFilter) { for (var i = 0; i < originalFilter.actions.length; i++) { newFilter.actions.push(_copyFilterElement(originalFilter.actions[i])); } - + return newFilter; } @@ -509,7 +509,7 @@ function _copyFilterElement(filterElement) { /* element = rule or action */ newElement[k] = value; } } - + return newElement; } @@ -527,7 +527,7 @@ function setupMailboxesFromJSON(jsonResponse) { userMailboxes = $([]); for (var i = 0; i < responseMboxes.length; i++) { var mbox = { 'displayName': responseMboxes[i].displayName.substr(1), - 'path': responseMboxes[i].path.substr(1) }; + 'path': responseMboxes[i].path.substr(1) }; userMailboxes.push(mbox); } } @@ -540,7 +540,7 @@ function updateFilterFromEditor(filterId, filterJSON) { sanitized[k] = filter[k]; } } - + var table = $("filtersList"); if (filterId == "new") { var newNumber = filters.length; @@ -557,7 +557,7 @@ function initMailAccounts() { var mailAccountsJSON = $("mailAccountsJSON"); if (mailAccountsJSON) { mailAccounts = mailAccountsJSON.value.evalJSON(); - + var mailAccountsList = $("mailAccountsList"); if (mailAccountsList) { var li = createMailAccountLI(mailAccounts[0], true); @@ -569,7 +569,7 @@ function initMailAccounts() { var lis = mailAccountsList.childNodesWithTag("li"); lis[0].readOnly = true; lis[0].selectElement(); - + var button = $("mailAccountAdd"); if (button) { button.observe("click", onMailAccountAdd); @@ -579,19 +579,19 @@ function initMailAccounts() { button.observe("click", onMailAccountDelete); } } - + var inputs = $$("#accountInfo input"); for (var i = 0; i < inputs.length; i++) { $(inputs[i]).observe("change", onMailAccountInfoChange); } - + inputs = $$("#identityInfo input"); for (var i = 0; i < inputs.length; i++) { $(inputs[i]).observe("change", onMailIdentityInfoChange); } $("actSignature").observe("click", onMailIdentitySignatureClick); displayMailAccount(mailAccounts[0], true); - + inputs = $$("#returnReceiptsInfo input"); for (var i = 0; i < inputs.length; i++) { $(inputs[i]).observe("change", onMailReceiptInfoChange); @@ -625,10 +625,10 @@ function onMailReceiptInfoChange(event) { } var keyName = this.name.cssIdToHungarianId(); this.mailAccount["receipts"][keyName] = this.value; - + var popupIds = [ "receipt-non-recipient-action", - "receipt-outside-domain-action", - "receipt-any-action" ]; + "receipt-outside-domain-action", + "receipt-any-action" ]; var receiptActionsDisable = (this.value == "ignore"); for (var i = 0; i < popupIds.length; i++) { var actionPopup = $(popupIds[i]); @@ -664,19 +664,19 @@ function onMailIdentitySignatureClick(event) { if (Prototype.Browser.IE) // Overwrite some fixes from iefixes.css dialog.setStyle({ width: 'auto', marginLeft: 'auto' }); - + document.body.appendChild(dialog); dialogs[dialogId] = dialog; - + if ($("composeMessagesType").value != 0) { CKEDITOR.replace('signature', { height: "150px", - toolbar: [['Bold', 'Italic', '-', 'Link', - 'Font','FontSize','-','TextColor', - 'BGColor'] - ], - language: localeCode, - scayt_sLang: localeCode }); + toolbar: [['Bold', 'Italic', '-', 'Link', + 'Font','FontSize','-','TextColor', + 'BGColor'] + ], + language: localeCode, + scayt_sLang: localeCode }); } } dialog.mailAccount = this.mailAccount; @@ -689,16 +689,16 @@ function onMailIdentitySignatureClick(event) { area.value = identity["signature"]; else area.value = ""; - + $("bgDialogDiv").show(); if (Prototype.Browser.IE) jQuery('#bgDialogDiv').css('opacity', 0.4); jQuery(dialog).fadeIn('fast', function() { - if (CKEDITOR.instances["signature"]) - focusCKEditor(); - else - area.focus(); - }); + if (CKEDITOR.instances["signature"]) + focusCKEditor(); + else + area.focus(); + }); Event.stop(event); } } @@ -708,7 +708,7 @@ function focusCKEditor() { setTimeout("focusCKEditor()", 100); else CKEDITOR.instances.signature.focus() -} + } function hideSignature() { if (CKEDITOR.status != 'loaded') @@ -724,7 +724,7 @@ function onMailIdentitySignatureOK(event) { mailAccount["identities"] = [{}]; } var identity = mailAccount["identities"][0]; - + var content = (CKEDITOR.instances["signature"] ? CKEDITOR.instances["signature"].getData() : $("signature").value); @@ -753,7 +753,7 @@ function createMailAccountLI(mailAccount, readOnly) { li.editionController = editionCtlr; } li.mailAccount = mailAccount; - + return li; } @@ -764,10 +764,10 @@ function onMailAccountEntryClick(event) { function displayMailAccount(mailAccount, readOnly) { var inputs = $$("#accountInfo input"); inputs.each(function(i) { - i.disabled = readOnly; - i.mailAccount = mailAccount; - }); - + i.disabled = readOnly; + i.mailAccount = mailAccount; + }); + inputs = $$("#identityInfo input"); inputs.each(function(i) { i.mailAccount = mailAccount; }); if (!mailCustomFromEnabled) { @@ -775,16 +775,16 @@ function displayMailAccount(mailAccount, readOnly) { inputs[i].disabled = readOnly; } } - + var form = $("mainForm"); - + var encryption = "none"; var encRadioValues = [ "none", "ssl", "tls" ]; if (mailAccount["encryption"]) { encryption = mailAccount["encryption"]; } form.setRadioValue("encryption", encRadioValues.indexOf(encryption)); - + var port; if (mailAccount["port"]) { port = mailAccount["port"]; @@ -798,20 +798,20 @@ function displayMailAccount(mailAccount, readOnly) { } } $("port").value = port; - + $("serverName").value = mailAccount["serverName"]; $("userName").value = mailAccount["userName"]; $("password").value = mailAccount["password"]; - + var identity = (mailAccount["identities"] ? mailAccount["identities"][0] : {} ); $("fullName").value = identity["fullName"] || ""; $("email").value = identity["email"] || ""; $("replyTo").value = identity["replyTo"] || ""; - + displayAccountSignature(mailAccount); - + var receiptAction = "ignore"; var receiptActionValues = [ "ignore", "allow" ]; if (mailAccount["receipts"] && mailAccount["receipts"]["receiptAction"]) { @@ -825,8 +825,8 @@ function displayMailAccount(mailAccount, readOnly) { form.setRadioValue("receipt-action", receiptActionValues.indexOf(receiptAction)); var popupIds = [ "receipt-non-recipient-action", - "receipt-outside-domain-action", - "receipt-any-action" ]; + "receipt-outside-domain-action", + "receipt-any-action" ]; var receiptActionsDisable = (receiptAction == "ignore"); for (var i = 0; i < popupIds.length; i++) { var actionPopup = $(popupIds[i]); @@ -844,7 +844,7 @@ function displayMailAccount(mailAccount, readOnly) { function displayAccountSignature(mailAccount) { var actSignature = $("actSignature"); actSignature.mailAccount = mailAccount; - + var actSignatureValue; var identity = (mailAccount["identities"] ? mailAccount["identities"][0] @@ -876,13 +876,13 @@ function createMailAccount() { newIdentity[k] = firstIdentity[k]; } delete newIdentity["isDefault"]; - + var newMailAccount = { name: _("New Mail Account"), - serverName: "mailserver", - userName: UserLogin, - password: "", - identities: [ newIdentity ] }; - + serverName: "mailserver", + userName: UserLogin, + password: "", + identities: [ newIdentity ] }; + return newMailAccount; } @@ -899,10 +899,10 @@ function onMailAccountAdd(event) { displayMailAccount(newMailAccount, false); li.selectElement(); li.editionController.startEditing(); - + var hasChanged = $("hasChanged"); hasChanged.value = "1"; - + event.stop(); } @@ -923,7 +923,7 @@ function onMailAccountDelete(event) { mailAccounts.splice(index, 1); next.selectElement(); displayMailAccount(next.mailAccount, next.readOnly); - + var hasChanged = $("hasChanged"); hasChanged.value = "1"; } @@ -933,26 +933,26 @@ function onMailAccountDelete(event) { function saveMailAccounts() { /* This removal enables us to avoid a few warning from SOPE for the inputs - that were created dynamically. */ + that were created dynamically. */ var editor = $("mailAccountEditor"); - + // Could be null if ModuleConstraints disables email access if (editor) //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(); }) - - compactMailAccounts(); + editor.select('input, select').each(function(i) { i.disable(); }) + + compactMailAccounts(); var mailAccountsJSON = $("mailAccountsJSON"); - + if (mailAccountsJSON) mailAccountsJSON.value = Object.toJSON(mailAccounts); } function compactMailAccounts() { - + if (!mailAccounts) return; - + for (var i = 1; i < mailAccounts.length; i++) { var account = mailAccounts[i]; var encryption = account["encryption"]; @@ -977,12 +977,12 @@ function compactMailAccounts() { /* common function between calendar categories and mail labels */ function onColorEdit(e, target) { var view = $(target); - + view.select('div.colorEditing').each(function(box) { - box.removeClassName('colorEditing'); - }); + box.removeClassName('colorEditing'); + }); this.addClassName("colorEditing"); - + var cellPosition = this.cumulativeOffset(); var cellDimensions = this.getDimensions(); var div = $('colorPickerDialog'); @@ -999,17 +999,17 @@ function onColorPickerChoice(event) { var dialog = span.up('.dialog'); var target = dialog.readAttribute('data-target'); var newColor = "#" + span.className.substr(4); - + var wrapper = $(target); var div = wrapper.select("div.colorEditing").first(); - + div.writeAttribute('data-color', newColor); div.style.background = newColor; if (parseInt($("hasChanged").value) == 0) { var hasChanged = $("hasChanged"); hasChanged.value = "1"; } - + dialog.hide(); } @@ -1032,116 +1032,116 @@ function onCalendarColorEdit(e) { } function makeEditable (element) { - element.addClassName("editing"); - element.removeClassName("whiteListCell"); - - var span = element.down("SPAN"); - span.update(); - - var textField = element.down("INPUT"); - textField.show(); - textField.focus(); - textField.select(); - - return true; + element.addClassName("editing"); + element.removeClassName("whiteListCell"); + + var span = element.down("SPAN"); + span.update(); + + var textField = element.down("INPUT"); + textField.show(); + textField.focus(); + textField.select(); + + return true; } function endAllEditables (e) { - 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")); - } + 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")); + } } function onNameEdit (e) { - endAllEditables(); - if (!this.hasClassName("editing")) { - makeEditable (this); - } + endAllEditables(); + if (!this.hasClassName("editing")) { + makeEditable (this); + } } function endEditable(event, textField) { - if (!textField) - textField = this; - - var uid = textField.readAttribute("uid"); - var cell = textField.up("TD"); - var textSpan = cell.down("SPAN"); - - cell.removeClassName("editing"); - cell.addClassName("whiteListCell"); - textField.hide(); - - var tmp = textField.value; - tmp = tmp.replace (//, ">"); - if (!uid) - cell.up("TR").addClassName("notfound"); - if (tmp) - textSpan.update(tmp); - else - cell.up("TR").remove(); - - if (event) - Event.stop(event); - - return false; + if (!textField) + textField = this; + + var uid = textField.readAttribute("uid"); + var cell = textField.up("TD"); + var textSpan = cell.down("SPAN"); + + cell.removeClassName("editing"); + cell.addClassName("whiteListCell"); + textField.hide(); + + var tmp = textField.value; + tmp = tmp.replace (//, ">"); + if (!uid) + cell.up("TR").addClassName("notfound"); + if (tmp) + textSpan.update(tmp); + else + cell.up("TR").remove(); + + if (event) + Event.stop(event); + + return false; } function onAppointmentsWhiteListAdd(e) { - 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"); - - 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"); - - td.appendChild(textField); - td.appendChild(span); - row.appendChild (td); - tablebody.appendChild(row); - $(tablebody).deselectAll(); - row.selectElement(); - - makeEditable(td); - + 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"); + + 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"); + + td.appendChild(textField); + td.appendChild(span); + row.appendChild (td); + tablebody.appendChild(row); + $(tablebody).deselectAll(); + row.selectElement(); + + makeEditable(td); + } function onAppointmentsWhiteListDelete(e) { - var list = $('appointmentsWhiteListWrapper').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(); - } + var list = $('appointmentsWhiteListWrapper').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 serializeAppointmentsWhiteList() { - var r = $$("#appointmentsWhiteListWrapper TBODY TR"); - - var values = []; - 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(); - var user = uid + "=" + value; - if (uid != null) - values.push(user); - } - $("whiteList").value = values; + var r = $$("#appointmentsWhiteListWrapper TBODY TR"); + + var values = []; + 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(); + var user = uid + "=" + value; + if (uid != null) + values.push(user); + } + $("whiteList").value = values; } function onCalendarCategoryAdd(e) { @@ -1149,19 +1149,19 @@ function onCalendarCategoryAdd(e) { var nametd = new Element("td").update(""); var colortd = new Element("td"); var colordiv = new Element("div", {"class": "colorBox", dataColor: "#F0F0F0"}); - + row.identify(); row.addClassName("categoryListRow"); - + nametd.addClassName("categoryListCell"); colortd.addClassName("categoryListCell"); colordiv.setStyle({backgroundColor: "#F0F0F0"}); - + colortd.appendChild(colordiv); row.appendChild(nametd); row.appendChild(colortd); $("calendarCategoriesListWrapper").childNodesWithTag("table")[0].tBodies[0].appendChild(row); - + resetCalendarTableActions(); nametd.editionController.startEditing(); } @@ -1170,7 +1170,7 @@ function onCalendarCategoryDelete(e) { var list = $('calendarCategoriesListWrapper').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(); @@ -1179,7 +1179,7 @@ function onCalendarCategoryDelete(e) { function serializeCalendarCategories() { var r = $$("#calendarCategoriesListWrapper TBODY TR"); - + var values = []; for (var i = 0; i < r.length; i++) { var tds = r[i].childElements(); @@ -1187,7 +1187,7 @@ function serializeCalendarCategories() { var color = $(tds.last().childElements().first()).readAttribute('data-color'); values.push("\"" + name + "\": \"" + color + "\""); } - + $("calendarCategoriesValue").value = "{ " + values.join(",\n") + "}"; } @@ -1226,19 +1226,19 @@ function onMailLabelAdd(e) { var nametd = new Element("td").update(""); var colortd = new Element("td"); var colordiv = new Element("div", {"class": "colorBox", dataColor: "#F0F0F0"}); - + row.identify(); row.addClassName("labelListRow"); - + nametd.addClassName("labelListCell"); colortd.addClassName("labelListCell"); colordiv.setStyle({backgroundColor: "#F0F0F0"}); - + colortd.appendChild(colordiv); row.appendChild(nametd); row.appendChild(colortd); $("mailLabelsListWrapper").childNodesWithTag("table")[0].tBodies[0].appendChild(row); - + resetMailTableActions(); nametd.editionController.startEditing(); } @@ -1247,7 +1247,7 @@ function onMailLabelDelete(e) { var list = $('mailLabelsListWrapper').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(); @@ -1266,164 +1266,164 @@ function resetMailLabelsColors(e) { function serializeMailLabels() { var r = $$("#mailLabelsListWrapper TBODY TR"); - + var values = []; for (var i = 0; i < r.length; i++) { var tds = r[i].childElements(); - var name = r[i].readAttribute("data-name"); + var name = r[i].readAttribute("data-name"); var label = $(tds.first()).innerHTML; var color = $(tds.last().childElements().first()).readAttribute('data-color'); /* if name is null, that's because we've just added a new tag */ if (!name) { name = label.replace(/[ \(\)\/\{%\*<>\\\"]/g, "_"); - } - - 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 */ + } -function onAddOutgoingAddressesCheck(checkBox) { - if (!checkBox) { - checkBox = $("addOutgoingAddresses"); - } - $("addressBookList").disabled = !checkBox.checked; - -} + values.push("\"" + name + "\": [\"" + label + "\", \"" + color + "\"]"); + } -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); + $("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 */ + + function onAddOutgoingAddressesCheck(checkBox) { + if (!checkBox) { + checkBox = $("addOutgoingAddresses"); + } + $("addressBookList").disabled = !checkBox.checked; + + } + + 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);