diff --git a/calendar/base/content/calendar-item-editing.js b/calendar/base/content/calendar-item-editing.js index e284d72d180..fc512c0cc0e 100644 --- a/calendar/base/content/calendar-item-editing.js +++ b/calendar/base/content/calendar-item-editing.js @@ -20,6 +20,7 @@ * * Contributor(s): * Stuart Parmenter + * Robin Edrenius * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -149,7 +150,9 @@ function modifyEventWithDialog(item) } } - openEventDialog(item, item.calendar, "modify", onModifyItem); + if (item) { + openEventDialog(item, item.calendar, "modify", onModifyItem); + } } function openEventDialog(calendarItem, calendar, mode, callback) @@ -204,13 +207,15 @@ function getOccurrenceOrParent(occurrence) { var buttonLabel2 = props.GetStringFromName("editRecurSingle"); var flags = promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0 + - promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_1; + promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1 + + promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_2; - if (promptService.confirmEx(null, promptTitle, promptMessage, flags, - buttonLabel1, buttonLabel2, null, null, {})) { - return occurrence; - } else { - return occurrence.parentItem; + var choice = promptService.confirmEx(null, promptTitle, promptMessage, flags, + buttonLabel1,null , buttonLabel2, null, {}); + switch(choice) { + case 0: return occurrence.parentItem; + case 2: return occurrence; + default: return null; } } diff --git a/calendar/lightning/content/calendar-management.js b/calendar/lightning/content/calendar-management.js index cbb15c05bc0..09c4948137d 100644 --- a/calendar/lightning/content/calendar-management.js +++ b/calendar/lightning/content/calendar-management.js @@ -191,6 +191,9 @@ var ltnCalendarViewController = { // if we can modify this thing directly (e.g. just the time changed), // then do so; otherwise pop up the dialog var itemToEdit = getOccurrenceOrParent(aOccurrence); + if (!itemToEdit) { + return; + } if (aNewStartTime && aNewEndTime && !aNewStartTime.isDate && !aNewEndTime.isDate) { var instance = itemToEdit.clone(); @@ -218,6 +221,9 @@ var ltnCalendarViewController = { deleteOccurrence: function (aOccurrence) { var itemToDelete = getOccurrenceOrParent(aOccurrence); + if (!itemToDelete) { + return; + } if (itemToDelete.parentItem != itemToDelete) { var event = itemToDelete.parentItem.clone(); event.recurrenceInfo.removeOccurrenceAt(itemToDelete.recurrenceId); diff --git a/calendar/resources/content/calendarWindow.js b/calendar/resources/content/calendarWindow.js index 7d9938e5e3f..220829c013f 100644 --- a/calendar/resources/content/calendarWindow.js +++ b/calendar/resources/content/calendarWindow.js @@ -21,6 +21,7 @@ * Contributor(s): Garth Smedley * Mike Potter * Eric Belhaire + * Robin Edrenius * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -75,6 +76,9 @@ calViewController.prototype.modifyOccurrence = function (aOccurrence, aNewStartT if (aNewStartTime && aNewEndTime && !aNewStartTime.isDate && !aNewEndTime.isDate) { var itemToEdit = getOccurrenceOrParent(aOccurrence); + if (!itemToEdit) { + return; + } var instance = itemToEdit.clone(); var newStartTime = aNewStartTime; @@ -100,6 +104,9 @@ calViewController.prototype.modifyOccurrence = function (aOccurrence, aNewStartT calViewController.prototype.deleteOccurrence = function (aOccurrence) { var itemToDelete = getOccurrenceOrParent(aOccurrence); + if (!itemToDelete) { + return; + } if (itemToDelete.parentItem != itemToDelete) { var event = itemToDelete.parentItem.clone(); event.recurrenceInfo.removeOccurrenceAt(itemToDelete.recurrenceId);