diff --git a/calendar/base/content/calendar-common-sets.js b/calendar/base/content/calendar-common-sets.js index d55d4e8491..8b6b11c4b5 100644 --- a/calendar/base/content/calendar-common-sets.js +++ b/calendar/base/content/calendar-common-sets.js @@ -181,14 +181,10 @@ var calendarController = { case "calendar_export_selection_command": return this.item_selected; case "calendar_toggle_orientation_command": - return this.isCalendarInForeground() && - gCurrentMode && - gCurrentMode == "calendar" && + return this.isInMode("calendar") && currentView().supportsRotation; case "calendar_toggle_workdays_only_command": - return this.isCalendarInForeground() && - gCurrentMode && - gCurrentMode == "calendar" && + return this.isInMode("calendar") && currentView().supportsWorkdaysOnly; case "calendar_publish_selected_events_command": return this.item_selected; @@ -209,14 +205,11 @@ var calendarController = { // changing things. case "calendar_show_unifinder_command": case "calendar_mode_calendar": - return this.isCalendarInForeground() && - gCurrentMode && - gCurrentMode == "calendar"; + return this.isInMode("calendar"); case "calendar_mode_task": - return this.isCalendarInForeground() && - gCurrentMode && - gCurrentMode == "task"; + return this.isInMode("task"); + default: if (this.defaultController && !this.isCalendarInForeground()) { // The delete-button demands a special handling in mail-mode @@ -445,6 +438,17 @@ var calendarController = { return isSunbird() || (gCurrentMode && gCurrentMode != "mail"); }, + isInMode: function cC_isInMode(mode) { + switch (mode) { + case "mail": + return !isCalendarInForeground(); + case "calendar": + return isSunbird() || (gCurrentMode && gCurrentMode == "calendar"); + case "task": + return !isSunbird() && (gCurrentMode && gCurrentMode == "task"); + } + }, + onSelectionChanged: function cC_onSelectionChanged(aEvent) { var selectedItems = aEvent.detail; calendarController.item_selected = selectedItems && (selectedItems.length > 0);