From 71c2f1f4a842f7fe20dc9512228bb61b44393fd6 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 10 Aug 2010 13:47:11 +0000 Subject: [PATCH] See ChangeLog Monotone-Parent: aa5015ff0079b6856954284a0b566fd85c428a93 Monotone-Revision: d794ef4e02f1e288bc12d1379cbaba6e67be4e25 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2010-08-10T13:47:11 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 +++ UI/WebServerResources/ContactsUI.js | 40 ++++++---------------- UI/WebServerResources/MailerUI.js | 22 ++++++------ UI/WebServerResources/SchedulerUI.js | 20 +++++------ UI/WebServerResources/generic.js | 51 +++++++++++++++++++++++++--- 5 files changed, 83 insertions(+), 55 deletions(-) diff --git a/ChangeLog b/ChangeLog index 48810dcc9..ecaf580eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-08-10 Francis Lachapelle + + * UI/WebServerResources/generic.js (showAlertDialog): new function + to replace window.alert(). + 2010-08-05 Francis Lachapelle * UI/WebServerResources/SOGoResizableTable.js diff --git a/UI/WebServerResources/ContactsUI.js b/UI/WebServerResources/ContactsUI.js index 0f07a57b0..451a0de4b 100644 --- a/UI/WebServerResources/ContactsUI.js +++ b/UI/WebServerResources/ContactsUI.js @@ -275,9 +275,9 @@ 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(_("You don't have the required privileges to perform the operation.")); + showAlertDialog(_("You don't have the required privileges to perform the operation.")); else if (error) - window.alert(labels[error]); + showAlertDialog(labels[error]); refreshCurrentFolder(); } } @@ -397,7 +397,7 @@ function onToolbarEditSelectedContacts(event) { var rows = contactsList.getSelectedRowsId(); if (rows.length == 0) { - window.alert(_("Please select a contact.")); + showAlertDialog(_("Please select a contact.")); return false; } @@ -456,9 +456,8 @@ function onToolbarDeleteSelectedContacts(event) { } return false; } - else { - window.alert(_("Please select a contact.")); - } + else + showAlertDialog(_("Please select a contact.")); return false; } @@ -507,7 +506,7 @@ function onContactDeleteEventCallback(http) { row.show(); var displayName = row.readAttribute("contactname"); Contact.deleteContactsRequestCount--; - window.alert(labels["You cannot delete the card of \"%{0}\"."].formatted(displayName)); + showAlertDialog(_("You cannot delete the card of \"%{0}\".").formatted(displayName)); } } } @@ -786,7 +785,7 @@ function onAddressBookRemove(event) { var owner = node.getAttribute("owner"); if (owner == "nobody") { var label = _("You cannot remove nor unsubscribe from a public addressbook."); - window.alert(label); + showAlertDialog(label); } else if (owner == UserLogin) { var folderIdElements = node.getAttribute("id").split(":"); @@ -805,26 +804,7 @@ function onAddressBookRemove(event) { function deletePersonalAddressBook(folderId) { if (folderId == "personal") { - var dialogId = "deletePersonalAddressBookDialog"; - var dialog = Contact.dialogs[dialogId]; - if (dialog) { - $("bgDialogDiv").show(); - } - else { - var label = _("You cannot remove nor unsubscribe from your personal addressbook."); - var fields = createElement("p"); - fields.appendChild(createButton(dialogId + "ContinueBtn", - "Continue", - onBodyClickDialogHandler)); - dialog = createDialog(dialogId, - _("Warning"), - label, - fields, - "none"); - document.body.appendChild(dialog); - Contact.dialogs[dialogId] = dialog; - } - dialog.show(); + showAlertDialog(_("You cannot remove nor unsubscribe from your personal addressbook.")); } else { var dialogId = "deleteAddressBookDialog"; @@ -1048,7 +1028,7 @@ function onAddressBookModify(event) { {node: selected, name: newName}); } } else - window.alert(_("Unable to rename that folder!")); + showAlertDialog(_("Unable to rename that folder!")); } function folderRenameCallback(http) { @@ -1068,7 +1048,7 @@ function onMenuSharing(event) { var selected = folders.getSelectedNodes()[0]; var owner = selected.getAttribute("owner"); if (owner == "nobody") - window.alert(clabels["The user rights cannot be" + showAlertDialog(clabels["The user rights cannot be" + " edited for this object!"]); else { var title = this.innerHTML; diff --git a/UI/WebServerResources/MailerUI.js b/UI/WebServerResources/MailerUI.js index db6bfe458..579d09c88 100644 --- a/UI/WebServerResources/MailerUI.js +++ b/UI/WebServerResources/MailerUI.js @@ -94,7 +94,7 @@ function onMenuSharing(event) { var type = document.menuTarget.getAttribute("datatype"); if (type == "additional") - window.alert(clabels["The user rights cannot be" + showAlertDialog(clabels["The user rights cannot be" + " edited for this object!"]); else { var urlstr = URLForFolderID(folderID) + "/acls"; @@ -202,7 +202,7 @@ function openMessageWindowsForSelection(action, firstOnly) { break; } } else { - window.alert(_("Please select a message.")); + showAlertDialog(_("Please select a message.")); } } @@ -374,7 +374,7 @@ function deleteSelectedMessages(sender) { { "Content-type": "application/x-www-form-urlencoded" }); } else - window.alert(_("Please select a message.")); + showAlertDialog(_("Please select a message.")); return false; } @@ -451,10 +451,10 @@ function onPrintCurrentMessage(event) { var messageList = $("messageListBody").down("TBODY"); var rowIds = messageList.getSelectedNodes(); if (rowIds.length == 0) { - window.alert(_("Please select a message to print.")); + showAlertDialog(_("Please select a message to print.")); } else if (rowIds.length > 1) { - window.alert(_("Please select only one message to print.")); + showAlertDialog(_("Please select only one message to print.")); } else window.print(); @@ -1250,10 +1250,10 @@ function ICalendarButtonCallback(http) { } } if (i == Mailer.popups.length) - window.alert(_(msg)); + showAlertDialog(_(msg)); } else - window.alert("received code: " + http.status + "\nerror: " + http.responseText); + showAlertDialog("received code: " + http.status + "\nerror: " + http.responseText); } } @@ -2126,7 +2126,7 @@ function onMenuEmptyTrash(event) { function _onMenuChangeToXXXFolder(event, folder) { var type = document.menuTarget.getAttribute("datatype"); if (type == "additional") - window.alert(_("You need to choose a non-virtual folder!")); + showAlertDialog(_("You need to choose a non-virtual folder!")); else { var folderID = document.menuTarget.getAttribute("dataname"); var urlstr = URLForFolderID(folderID) + "/setAs" + folder + "Folder"; @@ -2228,7 +2228,7 @@ function folderOperationCallback(http) { && isHttpStatus204(http.status)) initMailboxTree(); else - window.alert(http.callbackData); + showAlertDialog(http.callbackData); } function folderRefreshCallback(http) { @@ -2258,7 +2258,7 @@ function folderRefreshCallback(http) { row.show(); } } - window.alert(_("Operation failed")); + showAlertDialog(_("Operation failed")); } } @@ -2339,7 +2339,7 @@ function saveAs(event) { window.location.href = (url+"?id="+uids+"&uid="+uids+"&mailbox="+Mailer.currentMailbox+"&path="+paths); } else - window.alert(_("Please select a message.")); + showAlertDialog(_("Please select a message.")); return false; } diff --git a/UI/WebServerResources/SchedulerUI.js b/UI/WebServerResources/SchedulerUI.js index b20e47a4a..e3b8a6bf8 100644 --- a/UI/WebServerResources/SchedulerUI.js +++ b/UI/WebServerResources/SchedulerUI.js @@ -161,7 +161,7 @@ function editEvent() { var nodes = listOfSelection.getSelectedRows(); if (nodes.length == 0) { - window.alert(_("Please select an event or a task.")); + showAlertDialog(_("Please select an event or a task.")); return false; } @@ -175,7 +175,7 @@ function editEvent() { _editEventId(selectedCalendarCell[0].cname, selectedCalendarCell[0].calendar); } else { - window.alert(_("Please select an event or a task.")); + showAlertDialog(_("Please select an event or a task.")); } return false; /* stop following the link */ @@ -199,7 +199,7 @@ function deleteEvent() { if (nodes.length > 0) { var label = ""; if (!nodes[0].erasable && !IsSuperUser) { - window.alert(_("You don't have the required privileges to perform the operation.")); + showAlertDialog(_("You don't have the required privileges to perform the operation.")); return false; } if (listOfSelection == $("tasksList")) @@ -235,7 +235,7 @@ function deleteEvent() { } } } else { - window.alert(_("Please select an event or a task.")); + showAlertDialog(_("Please select an event or a task.")); } } else if (selectedCalendarCell) { @@ -271,7 +271,7 @@ function deleteEvent() { } } else - window.alert(_("Please select an event or a task.")); + showAlertDialog(_("Please select an event or a task.")); return false; } @@ -329,10 +329,10 @@ function modifyEventCallback(http) { } else { msg = "delegate is a participant"; } - window.alert(_(msg)); + showAlertDialog(_(msg)); } else { - window.alert(_("eventPartStatModificationError")); + showAlertDialog(_("eventPartStatModificationError")); } document.modifyEventAjaxRequest = null; } @@ -486,7 +486,7 @@ function deleteEventCallback(http) { document.deleteEventAjaxRequest = null; } else if (parseInt(http.status) == 403) - window.alert(_("You don't have the required privileges to perform the operation.")); + showAlertDialog(_("You don't have the required privileges to perform the operation.")); else log ("deleteEventCallback Ajax error (" + http.status + ")"); } @@ -2465,7 +2465,7 @@ function appendCalendar(folderName, folderPath) { //log ("append name: " + folderName + "; path: " + folderPath + "; owner: " + owner); if ($(folderPath)) - window.alert(_("You have already subscribed to that folder!")); + showAlertDialog(_("You have already subscribed to that folder!")); else { var calendarList = $("calendarList"); var items = calendarList.select("li"); @@ -2564,7 +2564,7 @@ function onCalendarRemove(event) { if (folderId == "/personal") { var label = labels["You cannot remove nor unsubscribe from your" + " personal calendar."]; - window.alert(label); + showAlertDialog(label); } else { var folderIdElements = folderId.split(":"); diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index e3c939bb9..636655445 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -31,6 +31,9 @@ var queryParameters; var menus = new Array(); var search = {}; var sorting = {}; +var dialogs = {}; +var dialogActive = false; +var dialogsStack = new Array(); var lastClickedRow = -1; @@ -1032,7 +1035,7 @@ function folderSubscriptionCallback(http) { http.callbackData["method"](http.callbackData["data"]); } else - window.alert(_("Unable to subscribe to that folder!")); + showAlertDialog(_("Unable to subscribe to that folder!")); document.subscriptionAjaxRequest = null; } else @@ -1068,7 +1071,7 @@ function folderUnsubscriptionCallback(http) { http.callbackData["method"](http.callbackData["data"]); } else - window.alert(_("Unable to unsubscribe from that folder!")); + showAlertDialog(_("Unable to unsubscribe from that folder!")); } } @@ -1088,7 +1091,7 @@ function unsubscribeFromFolder(folderUrl, owner, refreshCallback, triggerAjaxRequest(url, folderUnsubscriptionCallback, rfCbData); } else - window.alert(_("You cannot unsubscribe from a folder that you own!")); + showAlertDialog(_("You cannot unsubscribe from a folder that you own!")); } } @@ -1723,13 +1726,53 @@ function createButton(id, caption, action) { return newButton; } +function showAlertDialog(label) { + var div = $("bgDialogDiv"); + if (div && div.visible()) { + dialogsStack.push(label); + return; + } + else { + _showAlertDialog(label); + } +} + +function _showAlertDialog(label) { + var dialog = null; + if (dialogs[label]) + dialog = dialogs[label]; + if (dialog) { + $("bgDialogDiv").show(); + } + else { + var fields = createElement("p"); + fields.appendChild(createButton(null, + _("OK"), + onBodyClickDialogHandler)); + dialog = createDialog(null, + _("Warning"), + label, + fields, + "none"); + document.body.appendChild(dialog); + dialogs[label] = dialog; + } + dialog.show(); +} + function onBodyClickDialogHandler() { $$("DIV.dialog").each(function(div) { if (div.visible()) div.hide(); }); - $("bgDialogDiv").hide(); + if (dialogsStack.length > 0) { + var label = dialogsStack.first(); + dialogsStack.splice(0, 1); + _showAlertDialog.delay(0.1, label); + } + else + $("bgDialogDiv").hide(); } function readCookie(name) {