in calendar/base/content/calendar-command-controller.js [119:252]
isCommandEnabled(aCommand) {
switch (aCommand) {
case "calendar_new_event_command":
case "calendar_new_event_context_command":
case "calendar_new_event_todaypane_command":
return CalendarNewEventsCommandEnabled;
case "calendar_modify_focused_item_command":
return this.item_selected && canEditSelectedItems();
case "calendar_modify_event_command":
return this.item_selected && canEditSelectedItems();
case "calendar_view_event_command":
return this.item_selected;
case "calendar_delete_focused_item_command":
return CalendarDeleteCommandEnabled && this.selected_items_writable;
case "calendar_delete_event_command":
return CalendarDeleteCommandEnabled && this.selected_items_writable;
case "calendar_new_todo_command":
case "calendar_new_todo_context_command":
case "calendar_new_todo_todaypane_command":
case "calendar_toggle_tasks_in_view_command":
return CalendarNewTasksCommandEnabled;
case "calendar_modify_todo_command":
case "calendar_modify_todo_todaypane_command":
return this.todo_items_selected;
// This code is temporarily commented out due to
// bug 469684 Unifinder-todo: raising of the context menu fires blur-event
// this.todo_tasktree_focused;
case "calendar_edit_calendar_command":
return this.isCalendarInForeground();
case "calendar_task_filter_command":
return true;
case "calendar_delete_todo_command":
if (!CalendarDeleteCommandEnabled) {
return false;
}
// falls through otherwise
case "calendar_toggle_completed_command":
case "calendar_percentComplete-0_command":
case "calendar_percentComplete-25_command":
case "calendar_percentComplete-50_command":
case "calendar_percentComplete-75_command":
case "calendar_percentComplete-100_command":
case "calendar_priority-0_command":
case "calendar_priority-9_command":
case "calendar_priority-5_command":
case "calendar_priority-1_command":
case "calendar_task_category_command":
case "calendar_general-progress_command":
case "calendar_general-priority_command":
case "calendar_general-postpone_command":
case "calendar_postpone-1hour_command":
case "calendar_postpone-1day_command":
case "calendar_postpone-1week_command":
return (
((this.isCalendarInForeground() || this.todo_tasktree_focused) &&
this.writable &&
this.todo_items_selected &&
this.todo_items_writable) ||
document.getElementById("tabmail").currentTabInfo.mode.type == "calendarTask"
);
case "calendar_delete_calendar_command":
return this.isCalendarInForeground() && !this.last_calendar;
case "calendar_import_command":
return this.writable;
case "calendar_export_selection_command":
return this.item_selected;
case "calendar_toggle_orientation_command":
return this.isInMode("calendar") && currentView().supportsRotation;
case "calendar_toggle_workdays_only_command":
return this.isInMode("calendar") && currentView().supportsWorkdaysOnly;
case "calendar_publish_selected_events_command":
return this.item_selected;
case "calendar_reload_remote_calendars":
return this.has_enabled_reloadable_calendars && !this.offline;
case "calendar_attendance_command": {
let attendSel = false;
if (this.todo_tasktree_focused) {
attendSel =
this.writable &&
this.todo_items_invitation &&
this.todo_items_selected &&
this.todo_items_writable;
} else {
attendSel =
this.item_selected && this.selected_events_invitation && this.selected_items_writable;
}
// Small hack, we want to hide instead of disable.
document.getElementById("calendar_attendance_command").setAttribute("hidden", !attendSel);
return attendSel;
}
// The following commands all just need the calendar in foreground,
// make sure you take care when changing things here.
case "calendar_view_next_command":
case "calendar_view_prev_command":
case "calendar_in_foreground":
return this.isCalendarInForeground();
case "calendar_in_background":
return !this.isCalendarInForeground();
// The following commands need calendar mode, be careful when
// changing things.
case "calendar_day-view_command":
case "calendar_week-view_command":
case "calendar_multiweek-view_command":
case "calendar_month-view_command":
case "calendar_show_unifinder_command":
case "calendar_mode_calendar":
return this.isInMode("calendar");
case "calendar_mode_task":
return this.isInMode("task");
case "cmd_selectAll":
return this.todo_tasktree_focused || this.isInMode("calendar");
// for events/tasks in a tab
case "cmd_save":
// falls through
case "cmd_accept": {
const tabType = document.getElementById("tabmail").currentTabInfo.mode.type;
return tabType == "calendarTask" || tabType == "calendarEvent";
}
default:
if (this.commands.has(aCommand)) {
// All other commands we support should be enabled by default
return true;
}
}
return false;
},