Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit 76b8803

Browse files
authored
Merge pull request #11 from ExchangeCalendar/wip-dialogs-event-attendees
Event dialog: fix content editor and attendees dialog
2 parents b4da51e + 2132ce9 commit 76b8803

22 files changed

+723
-648
lines changed

chrome.manifest

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ overlay chrome://calendar/content/calendar-calendars-list.xul chrome://exchangec
1212
overlay chrome://messenger/content/messenger.xul chrome://exchangecalendar/content/progress_panel.xul
1313
overlay chrome://calendar/content/calendar-task-view.xul chrome://exchangecalendar/content/messenger_task_delegation.xul
1414
overlay chrome://lightning/content/lightning-standalone.xul chrome://exchangecalendar/content/progress_panel.xul
15+
1516
overlay chrome://calendar/content/calendar-event-dialog.xul chrome://exchangecalendar/content/calendar-event-dialog.xul
17+
overlay chrome://lightning/content/lightning-item-iframe.xul chrome://exchangecalendar/content/lightning-item-iframe.xul
18+
1619
overlay chrome://calendar/content/calendar-event-dialog-reminder.xul chrome://exchangecalendar/content/calendar-event-dialog-reminder.xul
1720
overlay chrome://calendar/content/calendar-summary-dialog.xul chrome://exchangecalendar/content/calendar-summary-dialog.xul
1821
overlay chrome://calendar/content/calendar-properties-dialog.xul chrome://exchangecalendar/content/calendar-properties-dialog.xul
22+
1923
overlay chrome://messenger/content/messenger.xul chrome://exchangecalendar/content/sharedCalendarParser.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6}
2024
overlay chrome://messenger/content/messenger.xul chrome://exchangecalendar/content/check4lightning.xul
2125
overlay chrome://messenger/content/preferences/preferences.xul chrome://exchangecalendar/content/messenger-overlay-preferences.xul

chrome/content/attachments-view.js

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function exchAttachments(aDocument, aWindow)
4444
}
4545

4646
exchAttachments.prototype = {
47+
_initialized: false,
4748

4849
addAttachmentDialog: function _addAttachmentDialog()
4950
{
@@ -227,45 +228,75 @@ exchAttachments.prototype = {
227228
}
228229
},
229230

231+
/**
232+
* Receives asynchronous messages from the parent context that contains the iframe.
233+
*
234+
* @param {MessageEvent} aEvent Contains the message being received
235+
*/
236+
receiveMessage: function _receiveMessage(aEvent) {
237+
let validOrigin = gTabmail ? "chrome://messenger" : "chrome://calendar";
238+
if (aEvent.origin !== validOrigin) {
239+
return;
240+
}
241+
switch (aEvent.data.command) {
242+
case "exchWebService_addAttachmentDialog": this.addAttachmentDialog(); break;
243+
}
244+
},
245+
230246
onLoad: function _onLoad()
231247
{
248+
if(this._initialized){
249+
return;
250+
}
251+
252+
var self = this;
253+
232254
if (this._document.getElementById("calendar-task-tree")) {
233255
this.globalFunctions.LOG(" -- calendar-task-tree --");
234-
var self = this;
235256
this._document.getElementById("calendar-task-tree").addEventListener("select", function(){ self.onSelectTask();}, true);
236257
return;
237-
}
258+
}
238259

239260
var args = this._window.arguments[0];
240261
var item = args.calendarEvent;
241262

242-
//this.globalFunctions.LOG(" -- onLoad 2 ("+this.globalFunctions.STACKshort()+")");
243263
this.attachmentListboxVisible = false;
244264

265+
// We can't update toolbar from iframe
245266
if ((item.calendar) && (item.calendar.type == "exchangecalendar")) {
246267
this.globalFunctions.LOG(" -- It is an Exchange Calendar event:"+item.title);
247268

248-
249-
try {
250-
// Hide Lightning URL button
251-
this._document.getElementById("button-url").hidden = true;
252-
this._document.getElementById("event-toolbar").setAttribute("currentset", "button-save,button-attendees,button-privacy,button-url,exchWebService-add-attachment-button,button-delete");
253-
this._document.getElementById("exchWebService-add-attachment-button").hidden = false;
254-
if(this._document.getElementById("options-attachments-menuitem")){
255-
this._document.getElementById("options-attachments-menuitem").setAttribute("label", this._document.getElementById("exchWebService-add-attachment-button").getAttribute("label"));
256-
this._document.getElementById("options-attachments-menuitem").setAttribute("command", "exchWebService_addAttachmentDialog");
257-
}
269+
if (this._document.getElementById("event-grid-attachment-row")) {
270+
this._document.getElementById("event-grid-attachment-row").collapsed = true;
258271
}
259-
catch (ex) {this.globalFunctions.LOG(" -- Could not add exchange attachment buttons:"+ex.toString());}
260272

261-
// calendar-event-dialog (hide existing attachment view)
262-
try {
263-
this._document.getElementById("event-grid-attachment-row").setAttribute("collapsed", "true");
264-
}
265-
catch (ex) {}
273+
// Modify context menu for the attachment list inside the "Attachment" panel
274+
let attachmentListbox = this._document.getElementById("attachment-link");
275+
276+
attachmentListbox.context = "exchWebService-attachment-popup" ;
277+
attachmentListbox.onkeypress = function (aEvent) { self.onKeyPress(aEvent); };
278+
attachmentListbox.onclick = function (aEvent) { self.onSelect(aEvent); };
279+
attachmentListbox.ondblclick = function (aEvent) { self.onDblClick(aEvent); };
266280

267281
this.addAttachmentsFromItem(item);
282+
} else {
283+
if (this._document.getElementById("event-grid-attachment-row")) {
284+
this._document.getElementById("event-grid-attachment-row").collapsed = false;
285+
}
286+
287+
// Modify context menu for the attachment list inside the "Attachment" panel
288+
let attachmentListbox = this._document.getElementById("attachment-link");
289+
290+
attachmentListbox.context = "attachment-popup" ;
291+
attachmentListbox.onkeypress="attachmentLinkKeyPress(event)" ;
292+
attachmentListbox.onclick="attachmentClick(event);" ;
293+
attachmentListbox.ondblclick="attachmentDblClick(event)" ;
268294
}
295+
296+
// Add message listener to be able to receive message from parent window or tab
297+
window.addEventListener("message", function(aEvent) { self.receiveMessage(aEvent); }, false);
298+
299+
this._initialized = true;
269300
},
270301

271302
addAttachmentsFromItem: function _addAttachmentsFromItem(aItem)
@@ -584,6 +615,6 @@ exchAttachments.prototype = {
584615
}
585616

586617
var tmpAttachment = new exchAttachments(document, window);
587-
window.addEventListener("load", function _onLoad() { window.removeEventListener("load",arguments.callee,false); tmpAttachment.onLoad(); }, true);
618+
window.addEventListener("load", function _onLoad() { tmpAttachment.onLoad(); }, false);
588619

589620

chrome/content/attachments-view.xul

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,19 @@
4747
<overlay id="exchWebService-attachment-view"
4848
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
4949

50-
<script type="application/javascript" src="chrome://exchangecalendar/content/attachments-view.js"/>
50+
<script type="application/javascript" src="chrome://exchangecalendar/content/attachments-view.js"/>
5151

5252
<!-- Commands -->
53-
<commandset id="itemCommands">
53+
<commandset>
5454
<command id="exchWebService_openAttachment"
55-
oncommand="tmpAttachment.openAttachment();"/>
55+
oncommand="tmpAttachment.openAttachment();"/>
5656
<command id="exchWebService_saveAttachment"
57-
oncommand="tmpAttachment.saveAttachment();"/>
57+
oncommand="tmpAttachment.saveAttachment();"/>
5858
<command id="exchWebService_deleteAttachment"
59-
oncommand="tmpAttachment.deleteAttachment();"/>
60-
<command id="exchWebService_addAttachmentDialog"
61-
oncommand="tmpAttachment.addAttachmentDialog();"/>
59+
oncommand="tmpAttachment.deleteAttachment();"/>
6260
</commandset>
6361

62+
<!-- Update context popup-->
6463
<popupset id="event-dialog-popupset">
6564
<menupopup id="exchWebService-attachment-popup">
6665
<menuitem id="exchWebService-attachment-popup-open"
@@ -74,26 +73,9 @@
7473
<menuitem id="exchWebService-attachment-popup-delete"
7574
label="&event.menu.item.delete.label;"
7675
accesskey="&event.menu.item.delete.accesskey;"
77-
disable-on-readonly="true"
76+
disable-on-readonly="true"
7877
command="exchWebService_deleteAttachment"/>
7978
</menupopup>
8079
</popupset>
81-
82-
<toolbarpalette id="event-toolbarpalette">
83-
<toolbarbutton id="exchWebService-add-attachment-button"
84-
mode="dialog"
85-
class="cal-event-toolbarbutton toolbarbutton-1"
86-
label="&exchWebServie.add.attachment.button.label;"
87-
disable-on-readonly="true"
88-
removable="true"
89-
command="exchWebService_addAttachmentDialog"
90-
oncommand="tmpAttachment.addAttachmentDialog();"
91-
hidden="true"/>
92-
</toolbarpalette>
93-
<toolbar id="event-toolbar" defaultset="button-save,button-attendees,button-privacy,button-url,exchWebService-add-attachment-button,button-delete">
94-
</toolbar>
95-
9680

9781
</overlay>
98-
99-

0 commit comments

Comments
 (0)