diff --git a/mozilla/calendar/base/content/agenda-listbox.js b/mozilla/calendar/base/content/agenda-listbox.js
index b107e00c07f..5f271da9ceb 100644
--- a/mozilla/calendar/base/content/agenda-listbox.js
+++ b/mozilla/calendar/base/content/agenda-listbox.js
@@ -110,7 +110,7 @@ agendaListbox.onCheckboxChange =
function onCheckboxChange(event) {
var periodCheckbox = event.target;
var lopen = (periodCheckbox.getAttribute("checked") == "true");
- var listItem = getParentNode(periodCheckbox, "agenda-checkbox-richlist-item");
+ var listItem = getParentNodeOrThis(periodCheckbox, "agenda-checkbox-richlist-item");
var period = listItem.getItem();
period.open= lopen;
if (lopen) {
diff --git a/mozilla/calendar/base/content/calendar-common-sets.js b/mozilla/calendar/base/content/calendar-common-sets.js
index dfcb48e2f3f..58b55954728 100644
--- a/mozilla/calendar/base/content/calendar-common-sets.js
+++ b/mozilla/calendar/base/content/calendar-common-sets.js
@@ -215,12 +215,6 @@ var calendarController = {
case "calendar_new_todo_command":
createTodoWithDialog(getSelectedCalendar());
break;
- case "calendar_modify_todo_command":
- var selectedTasks = getFocusedTaskTree().selectedTasks;
- for each (var task in selectedTasks) {
- modifyEventWithDialog(task, null, true);
- }
- break;
case "calendar_delete_todo_command":
deleteToDoCommand();
break;
@@ -258,36 +252,6 @@ var calendarController = {
case "calendar_reload_remote_calendars":
getCompositeCalendar().refresh();
break;
- case "calendar_percentComplete-0_command":
- contextChangeTaskProgress(0);
- break;
- case "calendar_percentComplete-25_command":
- contextChangeTaskProgress(25);
- break;
- case "calendar_percentComplete-50_command":
- contextChangeTaskProgress(50);
- break;
- case "calendar_percentComplete-75_command":
- contextChangeTaskProgress(75);
- break;
- case "calendar_percentComplete-100_command":
- contextChangeTaskProgress(100);
- break;
- case "calendar_percentComplete-100_command2":
- contextChangeTaskProgress2(100);
- break;
- case "calendar_priority-0_command":
- contextChangeTaskPriority(0);
- break;
- case "calendar_priority-9_command":
- contextChangeTaskPriority(9);
- break;
- case "calendar_priority-5_command":
- contextChangeTaskPriority(5);
- break;
- case "calendar_priority-1_command":
- contextChangeTaskPriority(1);
- break;
default:
if (this.defaultController && !this.isCalendarInForeground()) {
// The delete-button demands a special handling in mail-mode
@@ -448,22 +412,15 @@ var calendarController = {
},
get todo_items_selected cC_todo_items_selected() {
- var taskTree = getFocusedTaskTree();
- if (taskTree) {
- var selectedTasks = taskTree.selectedTasks;
- return (selectedTasks.length > 0);
- }
- return false;
+ var selectedTasks = getSelectedTasks();
+ return (selectedTasks.length > 0);
},
get todo_items_writable cC_todo_items_writable() {
- var taskTree = getFocusedTaskTree();
- if (taskTree) {
- var selectedTasks = taskTree.selectedTasks;
- for each (var task in selectedTasks) {
- if (isCalendarWritable(task.calendar)) {
- return true;
- }
+ var selectedTasks = getSelectedTasks();
+ for each (var task in selectedTasks) {
+ if (isCalendarWritable(task.calendar)) {
+ return true;
}
}
return false;
diff --git a/mozilla/calendar/base/content/calendar-common-sets.xul b/mozilla/calendar/base/content/calendar-common-sets.xul
index d99345b7049..ab58842e06a 100755
--- a/mozilla/calendar/base/content/calendar-common-sets.xul
+++ b/mozilla/calendar/base/content/calendar-common-sets.xul
@@ -81,18 +81,18 @@
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -330,11 +330,11 @@
+ oncommand="tasksToMail(event)"/>
+ oncommand="tasksToEvents(event)"/>
diff --git a/mozilla/calendar/base/content/calendar-task-tree.js b/mozilla/calendar/base/content/calendar-task-tree.js
index 2efb3e966b8..e7619119c0e 100644
--- a/mozilla/calendar/base/content/calendar-task-tree.js
+++ b/mozilla/calendar/base/content/calendar-task-tree.js
@@ -50,8 +50,7 @@ function addCalendarNames(aEvent) {
while (calendarMenuPopup.hasChildNodes()) {
calendarMenuPopup.removeChild(calendarMenuPopup.lastChild);
}
- var taskTree = getFocusedTaskTree();
- var tasks = taskTree.selectedTasks;
+ var tasks = getSelectedTasks(aEvent);
var tasksSelected = (tasks.length > 0);
if (tasksSelected) {
var selIndex = appendCalendarItems(tasks[0], calendarMenuPopup, null, "contextChangeTaskCalendar(event);");
@@ -62,8 +61,7 @@ function addCalendarNames(aEvent) {
}
function addCategoryNames(aEvent) {
- var taskTree = getFocusedTaskTree();
- var tasks = taskTree.selectedTasks;
+ var tasks = getSelectedTasks(aEvent);
var tasksSelected = (tasks.length > 0);
if (tasksSelected) {
var index = appendCategoryItems(tasks[0], aEvent.target, document.getElementById("calendar_task_category_command"));
@@ -92,8 +90,7 @@ function changeTaskPriorityMenu(aEvent) {
*/
function changeMenuByPropertyName(aEvent, aPropertyName) {
uncheckChildNodes(aEvent);
- var taskTree = getFocusedTaskTree();
- var tasks = taskTree.selectedTasks;
+ var tasks = getSelectedTasks(aEvent);
var tasksSelected = ((tasks != null) && (tasks.length > 0));
if (tasksSelected) {
var task = tasks[0];
@@ -109,33 +106,28 @@ function changeMenuByPropertyName(aEvent, aPropertyName) {
}
function changeContextMenuForTask(aEvent) {
- var taskTree = getFocusedTaskTree();
- var tasks = taskTree.selectedTasks;
+ var tasks = getSelectedTasks(aEvent);
var task = null;
var tasksSelected = (tasks.length > 0);
applyAttributeToMenuChildren(aEvent.target, "disabled", (!tasksSelected));
document.getElementById("calendar_new_todo_command").removeAttribute("disabled");
if (tasksSelected) {
- taskTree.contextTask = task = tasks[0];
- if (isPropertyValueSame(tasks, "isCompleted")) {;
- setBooleanAttribute(document.getElementById("calendar-context-markcompleted"), "checked", task.isCompleted);
+ if (isPropertyValueSame(tasks, "isCompleted")) {
+ setBooleanAttribute(document.getElementById("calendar-context-markcompleted"), "checked", tasks[0].isCompleted);
} else {
document.getElementById("calendar-context-markcompleted").setAttribute("checked", false);
}
- } else {
- taskTree.contextTask = null;
}
}
-function contextChangeTaskProgress2(aProgress) {
- contextChangeTaskProgress(aProgress);
+function contextChangeTaskProgress2(aEvent, aProgress) {
+ contextChangeTaskProgress(aEvent, aProgress);
document.getElementById("calendar_percentComplete-100_command2").checked = false;
}
-function contextChangeTaskProgress(aProgress) {
+function contextChangeTaskProgress(aEvent, aProgress) {
startBatchTransaction();
- var taskTree = getFocusedTaskTree();
- var tasks = taskTree.selectedTasks;
+ var tasks = getSelectedTasks(aEvent);
for (var t = 0; t < tasks.length; t++) {
var task = tasks[t];
var newTask = task.clone().QueryInterface( Components.interfaces.calITodo );
@@ -159,8 +151,7 @@ function contextChangeTaskProgress(aProgress) {
function contextChangeTaskCategory(aEvent) {
startBatchTransaction();
- var taskTree = getFocusedTaskTree();
- var tasks = taskTree.selectedTasks;
+ var tasks = getSelectedTasks(aEvent);
var tasksSelected = (tasks.length > 0);
if (tasksSelected) {
var menuItem = aEvent.target;
@@ -175,8 +166,7 @@ function contextChangeTaskCategory(aEvent) {
function contextChangeTaskCalendar(aEvent) {
startBatchTransaction();
- var taskTree = getFocusedTaskTree();
- var tasks = taskTree.selectedTasks;
+ var tasks = getSelectedTasks(aEvent);
for (var t = 0; t < tasks.length; t++) {
var task = tasks[t];
var newTask = task.clone().QueryInterface( Components.interfaces.calITodo );
@@ -186,10 +176,9 @@ function contextChangeTaskCalendar(aEvent) {
endBatchTransaction();
}
-function contextChangeTaskPriority(aPriority) {
+function contextChangeTaskPriority(aEvent, aPriority) {
startBatchTransaction();
- var taskTree = getFocusedTaskTree();
- var tasks = taskTree.selectedTasks;
+ var tasks = getSelectedTasks(aEvent);
for (var t = 0; t < tasks.length; t++) {
var task = tasks[t];
var newTask = task.clone().QueryInterface( Components.interfaces.calITodo );
@@ -199,9 +188,8 @@ function contextChangeTaskPriority(aPriority) {
endBatchTransaction();
}
-function modifyTaskFromContext() {
- var taskTree = getFocusedTaskTree();
- var tasks = taskTree.selectedTasks;
+function modifyTaskFromContext(aEvent) {
+ var tasks = getSelectedTasks(aEvent);
for (var t = 0; t < tasks.length; t++) {
modifyEventWithDialog(tasks[t], null, true);
}
@@ -210,32 +198,43 @@ function modifyTaskFromContext() {
/**
* Delete the current selected item with focus from the task tree
*/
-function deleteToDoCommand(aDoNotConfirm) {
- var taskTree = getFocusedTaskTree();
- var selectedItems = taskTree.selectedTasks;
- calendarViewController.deleteOccurrences(selectedItems.length,
- selectedItems,
+function deleteToDoCommand(aEvent, aDoNotConfirm) {
+ var tasks = getSelectedTasks(aEvent);
+ calendarViewController.deleteOccurrences(tasks.length,
+ tasks,
false,
aDoNotConfirm);
}
-function getFocusedTaskTree() {
- // Which tree is focused depends on the mode.
- var taskTree;
- var focusedElement = document.commandDispatcher.focusedElement;
- taskTree = getParentNode(focusedElement, "calendar-task-tree");
- return taskTree;
+function getSelectedTasks(aEvent) {
+ var taskTree = null;
+ if (aEvent == null) {
+ taskTree = document.getElementById("calendar-task-tree");
+ } else {
+ // If the MenuItem is part of the application menu we can get the related
+ // tree by querying the "tree" attribute that has been attached to
+ // the parental popupMenu
+ taskTree = getParentNodeOrThisByAttribute(aEvent.target, "tree", "calendar-task-tree");
+ if (taskTree == null) {
+ // in this case we know that the menuitem is part of a context menu
+ taskTree = getParentNodeOrThis(document.popupNode, "calendar-task-tree");
+ }
+ }
+ if (taskTree != null) {
+ return taskTree.selectedTasks;
+ }
+ else {
+ return [];
+ }
}
-function tasksToMail() {
- var taskTree = getFocusedTaskTree();
- var tasks = taskTree.selectedTasks;
+function tasksToMail(aEvent) {
+ var tasks = getSelectedTasks(aEvent);
calendarMailButtonDNDObserver.onDropItems(tasks);
}
-function tasksToEvents() {
- var taskTree = getFocusedTaskTree();
- var tasks = taskTree.selectedTasks;
+function tasksToEvents(aEvent) {
+ var tasks = getSelectedTasks(aEvent);
calendarCalendarButtonDNDObserver.onDropItems(tasks);
}
diff --git a/mozilla/calendar/base/content/calendar-task-tree.xml b/mozilla/calendar/base/content/calendar-task-tree.xml
index 6b088f4ba9c..f917ac03f94 100644
--- a/mozilla/calendar/base/content/calendar-task-tree.xml
+++ b/mozilla/calendar/base/content/calendar-task-tree.xml
@@ -125,7 +125,6 @@
0
[]
- null
[]
null
true
@@ -223,16 +222,6 @@
return this.mTreeView._getItemFromEvent(aEvent);
]]>