Bug 431811-Context menu of tasks in today pane is broken [Error: taskTree has no properties];r=philipp
git-svn-id: svn://10.0.0.236/trunk@251995 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
03625dffcd
commit
03de302245
@ -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) {
|
||||
|
||||
@ -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,24 +412,17 @@ var calendarController = {
|
||||
},
|
||||
|
||||
get todo_items_selected cC_todo_items_selected() {
|
||||
var taskTree = getFocusedTaskTree();
|
||||
if (taskTree) {
|
||||
var selectedTasks = taskTree.selectedTasks;
|
||||
var selectedTasks = getSelectedTasks();
|
||||
return (selectedTasks.length > 0);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
get todo_items_writable cC_todo_items_writable() {
|
||||
var taskTree = getFocusedTaskTree();
|
||||
if (taskTree) {
|
||||
var selectedTasks = taskTree.selectedTasks;
|
||||
var selectedTasks = getSelectedTasks();
|
||||
for each (var task in selectedTasks) {
|
||||
if (isCalendarWritable(task.calendar)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@ -81,18 +81,18 @@
|
||||
<command id="calendar_week-view_command" oncommand="showCalendarView('week')"/>
|
||||
<command id="calendar_multiweek-view_command" oncommand="showCalendarView('multiweek')"/>
|
||||
<command id="calendar_month-view_command" oncommand="showCalendarView('month')"/>
|
||||
<command id="calendar_modify_todo_command" oncommand="goDoCommand('calendar_modify_todo_command')"/>
|
||||
<command id="calendar_modify_todo_command" oncommand="modifyTaskFromContext(event)"/>
|
||||
<command id="calendar_task_category_command" oncommand="contextChangeTaskCategory(event);"/>
|
||||
<command id="calendar_percentComplete-0_command" oncommand="goDoCommand('calendar_percentComplete-0_command')"/>
|
||||
<command id="calendar_percentComplete-25_command" oncommand="goDoCommand('calendar_percentComplete-25_command')"/>
|
||||
<command id="calendar_percentComplete-50_command" oncommand="goDoCommand('calendar_percentComplete-50_command')"/>
|
||||
<command id="calendar_percentComplete-75_command" oncommand="goDoCommand('calendar_percentComplete-75_command')"/>
|
||||
<command id="calendar_percentComplete-100_command" oncommand="goDoCommand('calendar_percentComplete-100_command')"/>
|
||||
<command id="calendar_percentComplete-100_command2" oncommand="goDoCommand('calendar_percentComplete-100_command2')"/>
|
||||
<command id="calendar_priority-0_command" oncommand="goDoCommand('calendar_priority-0_command')"/>
|
||||
<command id="calendar_priority-9_command" oncommand="goDoCommand('calendar_priority-9_command')"/>
|
||||
<command id="calendar_priority-5_command" oncommand="goDoCommand('calendar_priority-5_command')"/>
|
||||
<command id="calendar_priority-1_command" oncommand="goDoCommand('calendar_priority-1_command')"/>
|
||||
<command id="calendar_percentComplete-0_command" oncommand="contextChangeTaskProgress(event, 0)"/>
|
||||
<command id="calendar_percentComplete-25_command" oncommand="contextChangeTaskProgress(event, 25)"/>
|
||||
<command id="calendar_percentComplete-50_command" oncommand="contextChangeTaskProgress(event, 50)"/>
|
||||
<command id="calendar_percentComplete-75_command" oncommand="contextChangeTaskProgress(event, 75)"/>
|
||||
<command id="calendar_percentComplete-100_command" oncommand="contextChangeTaskProgress(event, 100)"/>
|
||||
<command id="calendar_percentComplete-100_command2" oncommand="contextChangeTaskProgress2(event, 100)"/>
|
||||
<command id="calendar_priority-0_command" oncommand="contextChangeTaskPriority(event, 0)"/>
|
||||
<command id="calendar_priority-9_command" oncommand="contextChangeTaskPriority(event, 9)"/>
|
||||
<command id="calendar_priority-5_command" oncommand="contextChangeTaskPriority(event, 5)"/>
|
||||
<command id="calendar_priority-1_command" oncommand="contextChangeTaskPriority(event, 1)"/>
|
||||
<command id="calendar_general-priority_command" oncommand="goDoCommand('calendar_general-priority_command')"/>
|
||||
<command id="calendar_toggle_orientation_command" persist="checked" oncommand="toggleOrientation()" disabled="true"/>
|
||||
<command id="calendar_toggle_workdays_only_command" persist="checked" oncommand="toggleWorkdaysOnly()"/>
|
||||
@ -330,11 +330,11 @@
|
||||
<menuitem id="calendar-context-converttomessage"
|
||||
label="&calendar.context.convertmenu.message.label;"
|
||||
accesskey="&calendar.context.convertmenu.message.accesskey;"
|
||||
oncommand="tasksToMail()"/>
|
||||
oncommand="tasksToMail(event)"/>
|
||||
<menuitem id="calendar-context-converttoevent"
|
||||
label="&calendar.context.convertmenu.event.label;"
|
||||
accesskey="&calendar.context.convertmenu.event.accesskey;"
|
||||
oncommand="tasksToEvents()"/>
|
||||
oncommand="tasksToEvents(event)"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menupopup>
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -125,7 +125,6 @@
|
||||
<field name="mLoadCount">0</field>
|
||||
<field name="mTaskArray">[]</field>
|
||||
<field name="mHash2Index"><![CDATA[({})]]></field>
|
||||
<field name="mContextTask">null</field>
|
||||
<field name="mRefreshQueue">[]</field>
|
||||
<field name="mPendingRefresh">null</field>
|
||||
<field name="mShowCompletedTasks">true</field>
|
||||
@ -224,16 +223,6 @@
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<property name="contextTask">
|
||||
<getter><![CDATA[
|
||||
return this.mContextTask;
|
||||
]]></getter>
|
||||
<setter><![CDATA[
|
||||
this.mContextTask = val;
|
||||
return this.mContextTask;
|
||||
]]></setter>
|
||||
</property>
|
||||
|
||||
<field name="mTreeView"><![CDATA[
|
||||
({
|
||||
/**
|
||||
|
||||
@ -107,7 +107,7 @@
|
||||
<implementation>
|
||||
<field name="kMinimonth">null</field>
|
||||
<constructor><![CDATA[
|
||||
this.kMinimonth = getParentNode(this, "minimonth");
|
||||
this.kMinimonth = getParentNodeOrThis(this, "minimonth");
|
||||
]]></constructor>
|
||||
<property name="month">
|
||||
<setter><![CDATA[
|
||||
@ -201,7 +201,7 @@
|
||||
<field name="mPopup">null</field>
|
||||
<field name="mScrollYearsHandler">{}</field>
|
||||
<constructor><![CDATA[
|
||||
this.kMinimonth = getParentNode(this, "minimonth");
|
||||
this.kMinimonth = getParentNodeOrThis(this, "minimonth");
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "left-button").kMinimonth = this.kMinimonth;
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "today-button").kMinimonth = this.kMinimonth;
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "right-button").kMinimonth = this.kMinimonth;
|
||||
@ -367,7 +367,7 @@
|
||||
<handler event="click">
|
||||
<![CDATA[
|
||||
var element = event.originalTarget;
|
||||
var popup = getParentNode(element, "popup");
|
||||
var popup = getParentNodeOrThis(element, "popup");
|
||||
if (popup) {
|
||||
var anonid = popup.getAttribute("anonid")
|
||||
switch(anonid) {
|
||||
|
||||
@ -1987,11 +1987,49 @@ function setBooleanAttribute(aXulElement, aAttribute, aValue) {
|
||||
}
|
||||
}
|
||||
|
||||
function getParentNode(aNode, aLocalName) {
|
||||
var node = aNode;
|
||||
do {
|
||||
node = node && node.parentNode;
|
||||
} while (node && (node.localName != aLocalName));
|
||||
/**
|
||||
* returns a parentnode - or the overgiven node - with the given localName,
|
||||
* by "walking up" the DOM-hierarchy.
|
||||
*
|
||||
* @param aChildNode The childnode.
|
||||
* @param aLocalName The localName of the to-be-returned parent
|
||||
* that is looked for.
|
||||
* @return The parent with the given localName or the
|
||||
* given childNode 'aChildNode'. If no appropriate
|
||||
* parent node with aLocalName could be
|
||||
* retrieved it is returned 'null'.
|
||||
*/
|
||||
function getParentNodeOrThis(aChildNode, aLocalName) {
|
||||
var node = aChildNode;
|
||||
while (node && (node.localName != aLocalName)) {
|
||||
node = node.parentNode;
|
||||
if (node.tagName == undefined) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a parentnode - or the overgiven node - with the given attributevalue
|
||||
* for the given attributename by "walking up" the DOM-hierarchy.
|
||||
*
|
||||
* @param aChildNode The childnode.
|
||||
* @param aAttibuteName The name of the attribute that is to be compared with
|
||||
* @param aAttibuteValue The value of the attribute that is to be compared with
|
||||
* @return The parent with the given attributeName set that has
|
||||
* the same value as the given given attributevalue
|
||||
* 'aAttributeValue'. If no appropriate
|
||||
* parent node can be retrieved it is returned 'null'.
|
||||
*/
|
||||
function getParentNodeOrThisByAttribute(aChildNode, aAttributeName, aAttributeValue) {
|
||||
var node = aChildNode;
|
||||
while (node && (node.getAttribute(aAttributeName) != aAttributeValue)) {
|
||||
node = node.parentNode;
|
||||
if (node.tagName == undefined) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@ -548,6 +548,7 @@ function copyPopupMenus() {
|
||||
addToPopupList(menulist[2], null, taskpopuplist, excludeList, true, true);
|
||||
addToPopupList(menulist[3], document.getElementById("calendar-GoPopupMenu"), taskpopuplist, excludeList, true, false);
|
||||
var tasksViewMenuPopup = clonePopupMenu("taskitem-context-menu", "taskitem-menu", "menu-");
|
||||
tasksViewMenuPopup.setAttribute("tree", "calendar-task-tree");
|
||||
tasksViewMenuPopup.removeChild(getMenuElementById("menu-" + "task-context-menu-modify", tasksViewMenuPopup));
|
||||
tasksViewMenuPopup.removeChild(getMenuElementById("menu-" + "task-context-menu-delete", tasksViewMenuPopup));
|
||||
addToPopupList(menulist[4], tasksViewMenuPopup, taskpopuplist, excludeList, false, false);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user