Mantis 3319: gestion des labels JavaScript

Monotone-Parent: 354ed3b0a354fd29a34c03d0b9f2d7961066e075
Monotone-Revision: 9ce00a7f3dabe1a68fa6eb5c0dc5e85403287b76

Monotone-Author: crobert@inverse.ca
Monotone-Date: 2009-09-11T20:25:06
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
C Robert 2009-09-11 20:25:06 +00:00
parent 8d8d9e4155
commit 4b54234375
13 changed files with 93 additions and 80 deletions

View File

@ -92,7 +92,7 @@ function addUserLineToTree(tree, parent, line) {
'', '',
ResourcesURL + '/abcard.gif',
ResourcesURL + '/abcard.gif');
tree.add(parent + 1, parent, labels["Please wait..."], 0, '#', null,
tree.add(parent + 1, parent, label ("Please wait..."), 0, '#', null,
null, '', '', icon, icon);
}
@ -177,7 +177,7 @@ function addFolderBranchToTree(tree, user, folder, nodeId, subId, isLast) {
function addFolderNotFoundNode (tree, nodeId) {
var icon = ResourcesURL + '/icon_unread.gif';
var node = new Node(1, nodeId, labels["No possible subscription"], 0, '#',
var node = new Node(1, nodeId, label ("No possible subscription"), 0, '#',
null, null, '', '', icon, icon);
node._ls = true;
return tree.node(node, (nodeId + 1), null);

View File

@ -225,7 +225,7 @@ function _onContactMenuAction(folderItem, action, refresh) {
for (var i = 0; i < contactIds.length; i++) {
if (contactIds[i].endsWith ("vlf")) {
alert (labels["Lists can't be moved or copied."]);
alert (label ("Lists can't be moved or copied."));
return false;
}
}
@ -274,7 +274,7 @@ function actionContactCallback(http) {
var error = html.select("p").first().firstChild.nodeValue.trim();
log("actionContactCallback failed: error " + http.status + " (" + error + ")");
if (parseInt(http.status) == 403)
window.alert(clabels["You don't have the required privileges to perform the operation."]);
window.alert(label ("You don't have the required privileges to perform the operation."));
else if (error)
window.alert(labels[error]);
refreshCurrentFolder();
@ -396,7 +396,7 @@ function onToolbarEditSelectedContacts(event) {
var rows = contactsList.getSelectedRowsId();
if (rows.length == 0) {
window.alert(labels["Please select a contact."]);
window.alert(label ("Please select a contact."));
return false;
}
@ -433,7 +433,7 @@ function onToolbarDeleteSelectedContacts(event) {
var rows = contactsList.getSelectedRowsId();
if (rows.length) {
var label = labels["Are you sure you want to delete the selected contacts?"];
var label = label ("Are you sure you want to delete the selected contacts?");
if (window.confirm(label)) {
for (var i = 0; i < rows.length; i++) {
delete cachedContacts[Contact.currentAddressBook + "/" + rows[i]];
@ -446,7 +446,7 @@ function onToolbarDeleteSelectedContacts(event) {
}
}
else {
window.alert(labels["Please select a contact."]);
window.alert(label ("Please select a contact."));
}
return false;
@ -528,7 +528,7 @@ function newList(sender) {
if (!li.hasClassName ("remote"))
openContactWindow(URLForFolderID(Contact.currentAddressBook) + "/newlist");
else
alert (clabels["You cannot create a list in a shared address book."]);
alert (label ("You cannot create a list in a shared address book."));
return false;
}
@ -615,7 +615,7 @@ function refreshContacts(cname) {
}
function onAddressBookNew(event) {
createFolder(window.prompt(labels["Name of the Address Book"], ""),
createFolder(window.prompt(label ("Name of the Address Book"), ""),
appendAddressBook);
preventDefault(event);
}
@ -723,9 +723,9 @@ function uploadCompleted (response) {
var div = $("uploadResults");
$("uploadOK").onclick = hideImportResults;
if (data.imported <= 0)
$("uploadResultsContent").update (labels["An error occured while importing contacts."]);
$("uploadResultsContent").update (label ("An error occured while importing contacts."));
else {
$("uploadResultsContent").update (labels["Imported contacts:"] + " " + data.imported);
$("uploadResultsContent").update (label ("Imported contacts:") + " " + data.imported);
refreshCurrentFolder ();
}
@ -741,7 +741,7 @@ function onAddressBookRemove(event) {
node.deselect();
var owner = node.getAttribute("owner");
if (owner == "nobody") {
var label = labels["You cannot remove nor unsubscribe from a public addressbook."];
var label = label ("You cannot remove nor unsubscribe from a public addressbook.");
window.alert(label);
}
else if (owner == UserLogin) {
@ -764,12 +764,12 @@ function onAddressBookRemove(event) {
function deletePersonalAddressBook(folderId) {
if (folderId == "personal") {
var label = labels["You cannot remove nor unsubscribe from your personal addressbook."];
var label = label ("You cannot remove nor unsubscribe from your personal addressbook.");
window.alert(label);
}
else {
var label
= labels["Are you sure you want to delete the selected address book?"];
= label ("Are you sure you want to delete the selected address book?");
if (window.confirm(label)) {
if (document.deletePersonalABAjaxRequest) {
document.deletePersonalABAjaxRequest.aborted = true;
@ -944,7 +944,7 @@ function onAddressBookModify(event) {
if (UserLogin == selected.getAttribute("owner")) {
var currentName = selected.innerHTML;
var newName = window.prompt(labels["Address Book Name"],
var newName = window.prompt(label ("Address Book Name"),
currentName);
if (newName && newName.length > 0
&& newName != currentName) {
@ -954,7 +954,7 @@ function onAddressBookModify(event) {
{node: selected, name: newName});
}
} else
window.alert(clabels["Unable to rename that folder!"]);
window.alert(label ("Unable to rename that folder!"));
}
function folderRenameCallback(http) {
@ -1271,7 +1271,7 @@ function dropSelectedContacts (action, toId) {
var contactIds = $('contactsList').getSelectedRowsId();
for (var i = 0; i < contactIds.length; i++) {
if (contactIds[i].endsWith ("vlf")) {
alert (labels["Lists can't be moved or copied."]);
alert (label ("Lists can't be moved or copied."));
return false;
}
}

View File

@ -207,7 +207,7 @@ function openMessageWindowsForSelection(action, firstOnly) {
break;
}
} else {
window.alert(labels["Please select a message."]);
window.alert(label ("Please select a message."));
}
}
@ -378,7 +378,7 @@ function deleteSelectedMessages(sender) {
{ "Content-type": "application/x-www-form-urlencoded" });
}
else
window.alert(labels["Please select a message."]);
window.alert(label ("Please select a message."));
return false;
}
@ -447,10 +447,10 @@ function deleteMessageWithDelay(url, id, mailbox, messageId) {
function onPrintCurrentMessage(event) {
var rowIds = $("messageList").getSelectedRowsId();
if (rowIds.length == 0) {
window.alert(labels["Please select a message to print."]);
window.alert(label ("Please select a message to print."));
}
else if (rowIds.length > 1) {
window.alert(labels["Please select only one message to print."]);
window.alert(label ("Please select only one message to print."));
}
else
window.print();
@ -1201,7 +1201,7 @@ function messageCallback(http) {
}
}
else if (http.status == 404) {
alert (labels["The message you have selected doesn't exist anymore."]);
alert (label ("The message you have selected doesn't exist anymore."));
window.location.reload ();
}
else
@ -1622,7 +1622,7 @@ function updateMailboxTreeInPage() {
/ Mailer.quotas.maxQuota)
/ 100);
var level = (percents > 85)? "alert" : (percents > 70)? "warn" : "ok";
var format = labels["quotasFormat"];
var format = label ("quotasFormat");
var text = format.formatted(percents,
Math.round(Mailer.quotas.maxQuota/10.24)/100);
var quotaDiv = new Element('div', { 'class': 'quota', 'info': text });
@ -1688,7 +1688,7 @@ function generateMenuForMailbox(mailbox, prefix, callback) {
if (mailbox.type != "account") {
var newNode = document.createElement("li");
newNode.mailbox = mailbox;
newNode.appendChild(document.createTextNode(labels["This Folder"]));
newNode.appendChild(document.createTextNode(label ("This Folder")));
menu.appendChild(newNode);
menu.appendChild(document.createElement("li"));
callbacks.push(callback);
@ -1882,7 +1882,7 @@ function saveFoldersStateCallback(http) {
}
function onMenuCreateFolder(event) {
var name = window.prompt(labels["Name :"], "");
var name = window.prompt(label ("Name :"), "");
if (name && name.length > 0) {
var folderID = document.menuTarget.getAttribute("dataname");
var urlstr = URLForFolderID(folderID) + "/createFolder?name=" + encodeURIComponent(name);
@ -1893,7 +1893,7 @@ function onMenuCreateFolder(event) {
}
function onMenuRenameFolder(event) {
var name = window.prompt(labels["Enter the new name of your folder :"],
var name = window.prompt(label ("Enter the new name of your folder :"),
"");
if (name && name.length > 0) {
var folderID = document.menuTarget.getAttribute("dataname");
@ -1905,11 +1905,11 @@ function onMenuRenameFolder(event) {
}
function onMenuDeleteFolder(event) {
var answer = window.confirm(labels["Do you really want to move this folder into the trash ?"]);
var answer = window.confirm(label ("Do you really want to move this folder into the trash ?"));
if (answer) {
var folderID = document.menuTarget.getAttribute("dataname");
var urlstr = URLForFolderID(folderID) + "/delete";
var errorLabel = labels["The folder could not be deleted."];
var errorLabel = label ("The folder could not be deleted.");
triggerAjaxRequest(urlstr, folderOperationCallback, errorLabel);
}
}
@ -1923,7 +1923,7 @@ function onMenuExpungeFolder(event) {
function onMenuEmptyTrash(event) {
var folderID = document.menuTarget.getAttribute("dataname");
var urlstr = URLForFolderID(folderID) + "/emptyTrash";
var errorLabel = labels["The trash could not be emptied."];
var errorLabel = label ("The trash could not be emptied.");
triggerAjaxRequest(urlstr, folderOperationCallback, errorLabel);
if (folderID == Mailer.currentMailbox) {
@ -1940,11 +1940,11 @@ function onMenuEmptyTrash(event) {
function _onMenuChangeToXXXFolder(event, folder) {
var type = document.menuTarget.getAttribute("datatype");
if (type == "additional")
window.alert(labels["You need to choose a non-virtual folder!"]);
window.alert(label ("You need to choose a non-virtual folder!"));
else {
var folderID = document.menuTarget.getAttribute("dataname");
var urlstr = URLForFolderID(folderID) + "/setAs" + folder + "Folder";
var errorLabel = labels["The folder functionality could not be changed."];
var errorLabel = label ("The folder functionality could not be changed.");
triggerAjaxRequest(urlstr, folderOperationCallback, errorLabel);
}
}
@ -2063,7 +2063,7 @@ function folderRefreshCallback(http) {
row.show();
}
}
window.alert(labels["Operation failed"]);
window.alert(label ("Operation failed"));
}
}
@ -2144,7 +2144,7 @@ function saveAs(event) {
window.open(url+"?id="+uids+"&uid="+uids+"&mailbox="+Mailer.currentMailbox+"&path="+paths);
}
else
window.alert(labels["Please select a message."]);
window.alert(label ("Please select a message."));
return false;
}

View File

@ -7,10 +7,10 @@ var MailerUIdTreeExtension = {
sent: "tbtv_sent_17x17.png",
draft: "tbtv_drafts_17x17.png",
trash: "tbtv_trash_17x17.png" },
folderNames: { inbox: labels["InboxFolderName"],
sent: labels["SentFolderName"],
draft: labels["DraftsFolderName"],
trash: labels["TrashFolderName"] },
folderNames: { inbox: label ("InboxFolderName"),
sent: label ("SentFolderName"),
draft: label ("DraftsFolderName"),
trash: label ("TrashFolderName") },
_addFolderNode: function (parent, name, fullName, type, unseen) {
var icon = this.folderIcons[type];
if (icon)

View File

@ -87,7 +87,7 @@ function editEvent() {
var nodes = listOfSelection.getSelectedRows();
if (nodes.length == 0) {
window.alert(labels["Please select an event or a task."]);
window.alert(label ("Please select an event or a task."));
return false;
}
@ -101,7 +101,7 @@ function editEvent() {
_editEventId(selectedCalendarCell[0].cname,
selectedCalendarCell[0].calendar);
} else {
window.alert(labels["Please select an event or a task."]);
window.alert(label ("Please select an event or a task."));
}
return false; /* stop following the link */
@ -124,9 +124,9 @@ function deleteEvent() {
if (nodes.length > 0) {
var label = "";
if (listOfSelection == $("tasksList"))
label = labels["taskDeleteConfirmation"];
label = label ("taskDeleteConfirmation");
else
label = labels["eventDeleteConfirmation"];
label = label ("eventDeleteConfirmation");
if (nodes.length == 1
&& nodes[0].recurrenceTime) {
@ -157,7 +157,7 @@ function deleteEvent() {
}
}
} else {
window.alert(labels["Please select an event or a task."]);
window.alert(label ("Please select an event or a task."));
}
}
else if (selectedCalendarCell) {
@ -165,7 +165,7 @@ function deleteEvent() {
_editRecurrenceDialog(selectedCalendarCell[0], "confirmDeletion");
}
else {
var label = labels["eventDeleteConfirmation"];
var label = label ("eventDeleteConfirmation");
if (confirm(label)) {
if (document.deleteEventAjaxRequest) {
document.deleteEventAjaxRequest.aborted = true;
@ -178,7 +178,7 @@ function deleteEvent() {
}
}
else
window.alert(labels["Please select an event or a task."]);
window.alert(label ("Please select an event or a task."));
return false;
}
@ -208,12 +208,12 @@ function closeInvitationWindow() {
closePseudoWin.style.top = "0px;";
closePseudoWin.style.left = "0px;";
closePseudoWin.style.right = "0px;";
closePseudoWin.appendChild(document.createTextNode(labels["closeThisWindowMessage"]));
closePseudoWin.appendChild(document.createTextNode(label ("closeThisWindowMessage")));
var calLink = document.createElement("a");
closePseudoWin.appendChild(calLink);
calLink.href = ApplicationBaseURL;
calLink.appendChild(document.createTextNode(labels["Calendar"].toLowerCase()));
calLink.appendChild(document.createTextNode(label ("Calendar").toLowerCase()));
}
function modifyEventCallback(http) {
@ -234,7 +234,7 @@ function modifyEventCallback(http) {
}
else {
// log("showing alert...");
window.alert(labels["eventPartStatModificationError"]);
window.alert(label ("eventPartStatModificationError"));
}
document.modifyEventAjaxRequest = null;
}
@ -295,7 +295,7 @@ function deleteEventCallback(http) {
}
}
else if (parseInt(http.status) == 403)
window.alert(clabels["You don't have the required privileges to perform the operation."]);
window.alert(label ("You don't have the required privileges to perform the operation."));
else
log ("deleteEventCallback Ajax error (" + http.status + ")");
}
@ -1888,7 +1888,7 @@ function updateCalendarProperties(calendarID, calendarName, calendarColor) {
}
function onCalendarNew(event) {
createFolder(window.prompt(labels["Name of the Calendar"], ""),
createFolder(window.prompt(label ("Name of the Calendar"), ""),
appendCalendar);
preventDefault(event);
}
@ -1899,7 +1899,7 @@ function onCalendarAdd(event) {
}
function onCalendarWebAdd(event) {
var calendarUrl = window.prompt(labels["URL of the Calendar"], "");
var calendarUrl = window.prompt(label ("URL of the Calendar"), "");
if (calendarUrl) {
if (document.addWebCalendarRequest) {
document.addWebCalendarRequest.aborted = true;
@ -1919,7 +1919,7 @@ function addWebCalendarCallback (http) {
changeCalendarDisplay();
}
else {
alert (labels["An error occured while importing calendar."]);
alert (label ("An error occured while importing calendar."));
}
}
@ -1975,9 +1975,9 @@ function uploadCompleted (response) {
var div = $("uploadResults");
$("uploadOK").onclick = hideImportResults;
if (data.imported <= 0)
$("uploadResultsContent").update (labels["An error occured while importing calendar."]);
$("uploadResultsContent").update (label ("An error occured while importing calendar."));
else {
$("uploadResultsContent").update (labels["Imported events:"] + " " + data.imported);
$("uploadResultsContent").update (label ("Imported events:") + " " + data.imported);
refreshEventsAndDisplay ();
}
@ -2009,7 +2009,7 @@ function appendCalendar(folderName, folderPath) {
//log ("append name: " + folderName + "; path: " + folderPath + "; owner: " + owner);
if ($(folderPath))
window.alert(clabels["You have already subscribed to that folder!"]);
window.alert(label ("You have already subscribed to that folder!"));
else {
var calendarList = $("calendarList");
var items = calendarList.select("li");

View File

@ -101,7 +101,7 @@ function subscribeToFolder(refreshCallback, refreshCallbackData) {
refreshCallbackData["folder"]);
}
else
refreshCallbackData["window"].alert(clabels["You cannot subscribe to a folder that you own!"]);
refreshCallbackData["window"].alert(label ("You cannot subscribe to a folder that you own!"));
return result;
}

View File

@ -32,25 +32,25 @@ function onOKClick(event) {
if (tag
&& $("synchronizeCalendar").checked) {
if (tag.value.blank()) {
alert(labels["tagNotDefined"]);
alert(label ("tagNotDefined"));
save = false;
}
else if (allTags
&& allTags.indexOf(tag.value) > -1) {
alert(labels["tagAlreadyExists"]);
alert(label ("tagAlreadyExists"));
save = false;
}
else if (originalTag
&& !originalTag.value.blank()) {
if (tag.value != originalTag.value)
save = confirm(labels["tagHasChanged"]);
save = confirm(label ("tagHasChanged"));
}
else
save = confirm(labels["tagWasAdded"]);
save = confirm(label ("tagWasAdded"));
}
else if (originalTag
&& !originalTag.value.blank())
save = confirm(labels["tagWasRemoved"]);
save = confirm(label ("tagWasRemoved"));
if (save)
window.opener.updateCalendarProperties(calendarID.value,

View File

@ -25,7 +25,7 @@ function onPopupAttachWindow(event) {
preventDefault(event);
var attachInput = document.getElementById("attach");
var newAttach = window.prompt(labels["Target:"], attachInput.value || "http://");
var newAttach = window.prompt(label ("Target:"), attachInput.value || "http://");
if (newAttach != null) {
var documentHref = $("documentHref");
var documentLabel = $("documentLabel");

View File

@ -46,7 +46,7 @@ function addUserLineToTree(tree, parent, line) {
ResourcesURL + '/abcard.gif',
ResourcesURL + '/abcard.gif');
if (window.opener.userFolderType != "user") {
tree.add(parent + 1, parent, labels["Please wait..."], 0, '#', null,
tree.add(parent + 1, parent, label ("Please wait..."), 0, '#', null,
null, '', '', icon, icon);
}
}
@ -184,7 +184,7 @@ function addFolderBranchToTree(tree, user, folder, nodeId, subId, isLast) {
function addFolderNotFoundNode (tree, nodeId) {
var icon = ResourcesURL + '/icon_unread.gif';
var node = new Node(1, nodeId, labels["No possible subscription"], 0, '#',
var node = new Node(1, nodeId, label ("No possible subscription"), 0, '#',
null, null, '', '', icon, icon);
node._ls = true;
return tree.node(node, (nodeId + 1));
@ -216,7 +216,7 @@ function onConfirmFolderSelection(event) {
var data = { folderName: folderName, folder: folder, window: window };
if (parent$(accessToSubscribedFolder(folder)))
window.alert(clabels["You have already subscribed to that folder!"]);
window.alert(label ("You have already subscribed to that folder!"));
else
window.opener.subscribeToFolder(window.opener.userFolderCallback, data);
}

View File

@ -112,13 +112,13 @@ function validateEditorInput(sender) {
field = document.pageform.subject;
if (field.value == "")
errortext = errortext + labels["error_missingsubject"] + "\n";
errortext = errortext + label ("error_missingsubject") + "\n";
if (!hasRecipients())
errortext = errortext + labels["error_missingrecipients"] + "\n";
errortext = errortext + label ("error_missingrecipients") + "\n";
if (errortext.length > 0) {
alert(labels["error_validationfailed"] + ":\n" + errortext);
alert(label ("error_validationfailed") + ":\n" + errortext);
return false;
}

View File

@ -235,7 +235,7 @@ function onComposeMessagesTypeChange(event) {
if (event) {
// Due to a limitation of CKEDITOR, we reload the page when the user
// changes the composition mode to avoid Javascript errors.
var saveAndReload = confirm(labels["composeMessageChanged"]);
var saveAndReload = confirm(label ("composeMessageChanged"));
if (saveAndReload)
return savePreferences();
else {

View File

@ -96,11 +96,11 @@ function toggleDetails() {
if (div.style.visibility) {
div.style.visibility = null;
window.resizeBy(0, -(div.clientHeight + buttonsHeight));
$("detailsButton").innerHTML = labels["Show Details"];
$("detailsButton").innerHTML = label ("Show Details");
} else {
div.style.visibility = 'visible;';
window.resizeBy(0, (div.clientHeight + buttonsHeight));
$("detailsButton").innerHTML = labels["Hide Details"];
$("detailsButton").innerHTML = label ("Hide Details");
}
return false;

View File

@ -1025,7 +1025,7 @@ function folderSubscriptionCallback(http) {
http.callbackData["method"](http.callbackData["data"]);
}
else
window.alert(clabels["Unable to subscribe to that folder!"]);
window.alert(label ("Unable to subscribe to that folder!"));
document.subscriptionAjaxRequest = null;
}
else
@ -1050,7 +1050,7 @@ function subscribeToFolder(refreshCallback, refreshCallbackData) {
rfCbData);
}
else
refreshCallbackData["window"].alert(clabels["You cannot subscribe to a folder that you own!"]);
refreshCallbackData["window"].alert(label ("You cannot subscribe to a folder that you own!"));
}
function folderUnsubscriptionCallback(http) {
@ -1061,7 +1061,7 @@ function folderUnsubscriptionCallback(http) {
http.callbackData["method"](http.callbackData["data"]);
}
else
window.alert(clabels["Unable to unsubscribe from that folder!"]);
window.alert(label ("Unable to unsubscribe from that folder!"));
}
}
@ -1081,7 +1081,7 @@ function unsubscribeFromFolder(folderUrl, owner, refreshCallback,
triggerAjaxRequest(url, folderUnsubscriptionCallback, rfCbData);
}
else
window.alert(clabels["You cannot unsubscribe from a folder that you own!"]);
window.alert(label ("You cannot unsubscribe from a folder that you own!"));
}
}
@ -1232,21 +1232,21 @@ function showAlarmCallback(http) {
&& http.status == 200) {
if (http.responseText.length) {
var data = http.responseText.evalJSON(true);
var msg = clabels["Reminder:"] + " " + data["summary"] + "\n";
var msg = label ("Reminder:") + " " + data["summary"] + "\n";
if (data["startDate"]) {
msg += clabels["Start:"] + " " + data["startDate"];
msg += label ("Start:") + " " + data["startDate"];
if (parseInt(data["isAllDay"]) == 0)
msg += " - " + data["startTime"];
msg += "\n";
}
if (data["dueDate"]) {
msg += clabels["Due Date:"] + " " + data["dueDate"];
msg += label ("Due Date:") + " " + data["dueDate"];
if (data["dueTime"])
msg += " - " + data["dueTime"];
msg += "\n";
}
if (data["location"].length)
msg += "\n" + clabels["Location:"] + " " + data["location"];
msg += "\n" + label ("Location:") + " " + data["location"];
if (data["description"].length)
msg += "\n\n" + data["description"];
@ -1591,7 +1591,7 @@ function createFolderCallback(http) {
data.okCB(data.name, "/" + http.responseText, UserLogin);
}
else if (http.status == 409) {
alert (clabels["A folder by that name already exists."]);
alert (label ("A folder by that name already exists."));
}
else {
if (data.notOkCB)
@ -1609,7 +1609,7 @@ function delegateInvitation(componentUrl, callbackFunction, callbackData) {
if (input.uid != null)
delegatedTo = input.uid;
else if (input.value.blank())
alert(clabels["noEmailForDelegation"]);
alert(label ("noEmailForDelegation"));
else
delegatedTo = input.value;
@ -1694,5 +1694,18 @@ AIM = {
}
function label (title) {
var rc = title;
if (labels[title]) {
rc = labels[title];
}
else if (clabels[title]) {
rc = clabels[title];
}
return rc;
}
document.observe("dom:loaded", onLoadHandler);