From 2da9e90ebc3212ab0573995de89b9c55e7d761b3 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 13 Oct 2009 19:14:21 +0000 Subject: [PATCH] JavaScript: fix bug with mail popup windows and event invitations. Monotone-Parent: 70c32f73a22fee53cf4091db0d979ff59560ca99 Monotone-Revision: 31bc4f6b49316e2603b7496cfee3b18fdd5e490f Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2009-10-13T19:14:21 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 +++ UI/WebServerResources/MailerUI.js | 55 ++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 406902c8e..ee68538b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-10-13 Francis Lachapelle + * UI/WebServerResources/MailerUI.js (-ICalendarButtonCallback): + delegate the execution of this method to the parent when called + from a popup window. This way, popups are properly reloaded when necessary. + * SoObjects/Appointments/SOGoAppointmentObject.m (- _handleAttendee:withDelegate:ownerUser:statusChange:inEvent:): added proper initialization of variable. diff --git a/UI/WebServerResources/MailerUI.js b/UI/WebServerResources/MailerUI.js index a483aad4a..1736efd1b 100644 --- a/UI/WebServerResources/MailerUI.js +++ b/UI/WebServerResources/MailerUI.js @@ -1099,6 +1099,7 @@ function configureiCalLinksInMessage() { delegatedToLink.stopObserving("click"); delegatedToLink.observe("click", function(event) { $("delegatedTo").show(); + $("iCalendarDelegate").show(); $("delegatedTo").focus(); this.hide(); Event.stop(event); @@ -1110,8 +1111,12 @@ function configureiCalLinksInMessage() { function onICalendarDelegate(event) { var link = $("iCalendarAttachment").value; if (link) { - var currentMsg = Mailer.currentMailbox + "/" - + Mailer.currentMessages[Mailer.currentMailbox]; + var currentMsg; + if ($(document.body).hasClassName("popup")) + currentMsg = mailboxName + "/" + messageName; + else + currentMsg = Mailer.currentMailbox + "/" + + Mailer.currentMessages[Mailer.currentMailbox]; delegateInvitation(link, ICalendarButtonCallback, currentMsg); } } @@ -1130,26 +1135,36 @@ function onICalendarButtonClick(event) { } function ICalendarButtonCallback(http) { - if (isHttpStatus204(http.status)) { - var oldMsg = http.callbackData; - var msg = Mailer.currentMailbox + "/" + Mailer.currentMessages[Mailer.currentMailbox]; - deleteCachedMessage(oldMsg); - if (oldMsg == msg) { - loadMessage(Mailer.currentMessages[Mailer.currentMailbox]); - } - for (var i = 0; i < Mailer.popups.length; i++) - if (Mailer.popups[i].messageUID == oldMsg) { - Mailer.popups[i].location.reload(); - break; + if ($(document.body).hasClassName("popup")) { + if (window.opener && window.opener.open && !window.opener.closed) + window.opener.ICalendarButtonCallback(http); + else + window.location.reload(); + } + else { + log ("ICalendarButtonCallback"); + if (isHttpStatus204(http.status)) { + var oldMsg = http.callbackData; + var msg = Mailer.currentMailbox + "/" + Mailer.currentMessages[Mailer.currentMailbox]; log (oldMsg + " => " + msg); + deleteCachedMessage(oldMsg); + if (oldMsg == msg) { + loadMessage(Mailer.currentMessages[Mailer.currentMailbox]); } + for (var i = 0; i < Mailer.popups.length; i++) { + if (Mailer.popups[i].messageUID == oldMsg) { + Mailer.popups[i].location.reload(); + break; + } + } + } + else if (http.status == 403) { + var data = http.responseText; + var msg = data.replace(/^(.*\n)*.*

((.*\n)*.*)<\/p>(.*\n)*.*$/, "$2"); + window.alert(clabels[msg]?clabels[msg]:msg); + } + else + window.alert("received code: " + http.status + "\nerror: " + http.responseText); } - else if (http.status == 403) { - var data = http.responseText; - var msg = data.replace(/^(.*\n)*.*

((.*\n)*.*)<\/p>(.*\n)*.*$/, "$2"); - window.alert(clabels[msg]?clabels[msg]:msg); - } - else - window.alert("received code: " + http.status + "\nerror: " + http.responseText); } function resizeMailContent() {