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:
Berend.Cornelius%sun.com 2008-05-30 19:32:03 +00:00
parent 03625dffcd
commit 03de302245
8 changed files with 154 additions and 170 deletions

View File

@ -110,7 +110,7 @@ agendaListbox.onCheckboxChange =
function onCheckboxChange(event) { function onCheckboxChange(event) {
var periodCheckbox = event.target; var periodCheckbox = event.target;
var lopen = (periodCheckbox.getAttribute("checked") == "true"); 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(); var period = listItem.getItem();
period.open= lopen; period.open= lopen;
if (lopen) { if (lopen) {

View File

@ -215,12 +215,6 @@ var calendarController = {
case "calendar_new_todo_command": case "calendar_new_todo_command":
createTodoWithDialog(getSelectedCalendar()); createTodoWithDialog(getSelectedCalendar());
break; 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": case "calendar_delete_todo_command":
deleteToDoCommand(); deleteToDoCommand();
break; break;
@ -258,36 +252,6 @@ var calendarController = {
case "calendar_reload_remote_calendars": case "calendar_reload_remote_calendars":
getCompositeCalendar().refresh(); getCompositeCalendar().refresh();
break; 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: default:
if (this.defaultController && !this.isCalendarInForeground()) { if (this.defaultController && !this.isCalendarInForeground()) {
// The delete-button demands a special handling in mail-mode // The delete-button demands a special handling in mail-mode
@ -448,22 +412,15 @@ var calendarController = {
}, },
get todo_items_selected cC_todo_items_selected() { get todo_items_selected cC_todo_items_selected() {
var taskTree = getFocusedTaskTree(); var selectedTasks = getSelectedTasks();
if (taskTree) { return (selectedTasks.length > 0);
var selectedTasks = taskTree.selectedTasks;
return (selectedTasks.length > 0);
}
return false;
}, },
get todo_items_writable cC_todo_items_writable() { get todo_items_writable cC_todo_items_writable() {
var taskTree = getFocusedTaskTree(); var selectedTasks = getSelectedTasks();
if (taskTree) { for each (var task in selectedTasks) {
var selectedTasks = taskTree.selectedTasks; if (isCalendarWritable(task.calendar)) {
for each (var task in selectedTasks) { return true;
if (isCalendarWritable(task.calendar)) {
return true;
}
} }
} }
return false; return false;

View File

@ -81,18 +81,18 @@
<command id="calendar_week-view_command" oncommand="showCalendarView('week')"/> <command id="calendar_week-view_command" oncommand="showCalendarView('week')"/>
<command id="calendar_multiweek-view_command" oncommand="showCalendarView('multiweek')"/> <command id="calendar_multiweek-view_command" oncommand="showCalendarView('multiweek')"/>
<command id="calendar_month-view_command" oncommand="showCalendarView('month')"/> <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_task_category_command" oncommand="contextChangeTaskCategory(event);"/>
<command id="calendar_percentComplete-0_command" oncommand="goDoCommand('calendar_percentComplete-0_command')"/> <command id="calendar_percentComplete-0_command" oncommand="contextChangeTaskProgress(event, 0)"/>
<command id="calendar_percentComplete-25_command" oncommand="goDoCommand('calendar_percentComplete-25_command')"/> <command id="calendar_percentComplete-25_command" oncommand="contextChangeTaskProgress(event, 25)"/>
<command id="calendar_percentComplete-50_command" oncommand="goDoCommand('calendar_percentComplete-50_command')"/> <command id="calendar_percentComplete-50_command" oncommand="contextChangeTaskProgress(event, 50)"/>
<command id="calendar_percentComplete-75_command" oncommand="goDoCommand('calendar_percentComplete-75_command')"/> <command id="calendar_percentComplete-75_command" oncommand="contextChangeTaskProgress(event, 75)"/>
<command id="calendar_percentComplete-100_command" oncommand="goDoCommand('calendar_percentComplete-100_command')"/> <command id="calendar_percentComplete-100_command" oncommand="contextChangeTaskProgress(event, 100)"/>
<command id="calendar_percentComplete-100_command2" oncommand="goDoCommand('calendar_percentComplete-100_command2')"/> <command id="calendar_percentComplete-100_command2" oncommand="contextChangeTaskProgress2(event, 100)"/>
<command id="calendar_priority-0_command" oncommand="goDoCommand('calendar_priority-0_command')"/> <command id="calendar_priority-0_command" oncommand="contextChangeTaskPriority(event, 0)"/>
<command id="calendar_priority-9_command" oncommand="goDoCommand('calendar_priority-9_command')"/> <command id="calendar_priority-9_command" oncommand="contextChangeTaskPriority(event, 9)"/>
<command id="calendar_priority-5_command" oncommand="goDoCommand('calendar_priority-5_command')"/> <command id="calendar_priority-5_command" oncommand="contextChangeTaskPriority(event, 5)"/>
<command id="calendar_priority-1_command" oncommand="goDoCommand('calendar_priority-1_command')"/> <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_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_orientation_command" persist="checked" oncommand="toggleOrientation()" disabled="true"/>
<command id="calendar_toggle_workdays_only_command" persist="checked" oncommand="toggleWorkdaysOnly()"/> <command id="calendar_toggle_workdays_only_command" persist="checked" oncommand="toggleWorkdaysOnly()"/>
@ -330,11 +330,11 @@
<menuitem id="calendar-context-converttomessage" <menuitem id="calendar-context-converttomessage"
label="&calendar.context.convertmenu.message.label;" label="&calendar.context.convertmenu.message.label;"
accesskey="&calendar.context.convertmenu.message.accesskey;" accesskey="&calendar.context.convertmenu.message.accesskey;"
oncommand="tasksToMail()"/> oncommand="tasksToMail(event)"/>
<menuitem id="calendar-context-converttoevent" <menuitem id="calendar-context-converttoevent"
label="&calendar.context.convertmenu.event.label;" label="&calendar.context.convertmenu.event.label;"
accesskey="&calendar.context.convertmenu.event.accesskey;" accesskey="&calendar.context.convertmenu.event.accesskey;"
oncommand="tasksToEvents()"/> oncommand="tasksToEvents(event)"/>
</menupopup> </menupopup>
</menu> </menu>
</menupopup> </menupopup>

View File

@ -50,8 +50,7 @@ function addCalendarNames(aEvent) {
while (calendarMenuPopup.hasChildNodes()) { while (calendarMenuPopup.hasChildNodes()) {
calendarMenuPopup.removeChild(calendarMenuPopup.lastChild); calendarMenuPopup.removeChild(calendarMenuPopup.lastChild);
} }
var taskTree = getFocusedTaskTree(); var tasks = getSelectedTasks(aEvent);
var tasks = taskTree.selectedTasks;
var tasksSelected = (tasks.length > 0); var tasksSelected = (tasks.length > 0);
if (tasksSelected) { if (tasksSelected) {
var selIndex = appendCalendarItems(tasks[0], calendarMenuPopup, null, "contextChangeTaskCalendar(event);"); var selIndex = appendCalendarItems(tasks[0], calendarMenuPopup, null, "contextChangeTaskCalendar(event);");
@ -62,8 +61,7 @@ function addCalendarNames(aEvent) {
} }
function addCategoryNames(aEvent) { function addCategoryNames(aEvent) {
var taskTree = getFocusedTaskTree(); var tasks = getSelectedTasks(aEvent);
var tasks = taskTree.selectedTasks;
var tasksSelected = (tasks.length > 0); var tasksSelected = (tasks.length > 0);
if (tasksSelected) { if (tasksSelected) {
var index = appendCategoryItems(tasks[0], aEvent.target, document.getElementById("calendar_task_category_command")); var index = appendCategoryItems(tasks[0], aEvent.target, document.getElementById("calendar_task_category_command"));
@ -92,8 +90,7 @@ function changeTaskPriorityMenu(aEvent) {
*/ */
function changeMenuByPropertyName(aEvent, aPropertyName) { function changeMenuByPropertyName(aEvent, aPropertyName) {
uncheckChildNodes(aEvent); uncheckChildNodes(aEvent);
var taskTree = getFocusedTaskTree(); var tasks = getSelectedTasks(aEvent);
var tasks = taskTree.selectedTasks;
var tasksSelected = ((tasks != null) && (tasks.length > 0)); var tasksSelected = ((tasks != null) && (tasks.length > 0));
if (tasksSelected) { if (tasksSelected) {
var task = tasks[0]; var task = tasks[0];
@ -109,33 +106,28 @@ function changeMenuByPropertyName(aEvent, aPropertyName) {
} }
function changeContextMenuForTask(aEvent) { function changeContextMenuForTask(aEvent) {
var taskTree = getFocusedTaskTree(); var tasks = getSelectedTasks(aEvent);
var tasks = taskTree.selectedTasks;
var task = null; var task = null;
var tasksSelected = (tasks.length > 0); var tasksSelected = (tasks.length > 0);
applyAttributeToMenuChildren(aEvent.target, "disabled", (!tasksSelected)); applyAttributeToMenuChildren(aEvent.target, "disabled", (!tasksSelected));
document.getElementById("calendar_new_todo_command").removeAttribute("disabled"); document.getElementById("calendar_new_todo_command").removeAttribute("disabled");
if (tasksSelected) { if (tasksSelected) {
taskTree.contextTask = task = tasks[0]; if (isPropertyValueSame(tasks, "isCompleted")) {
if (isPropertyValueSame(tasks, "isCompleted")) {; setBooleanAttribute(document.getElementById("calendar-context-markcompleted"), "checked", tasks[0].isCompleted);
setBooleanAttribute(document.getElementById("calendar-context-markcompleted"), "checked", task.isCompleted);
} else { } else {
document.getElementById("calendar-context-markcompleted").setAttribute("checked", false); document.getElementById("calendar-context-markcompleted").setAttribute("checked", false);
} }
} else {
taskTree.contextTask = null;
} }
} }
function contextChangeTaskProgress2(aProgress) { function contextChangeTaskProgress2(aEvent, aProgress) {
contextChangeTaskProgress(aProgress); contextChangeTaskProgress(aEvent, aProgress);
document.getElementById("calendar_percentComplete-100_command2").checked = false; document.getElementById("calendar_percentComplete-100_command2").checked = false;
} }
function contextChangeTaskProgress(aProgress) { function contextChangeTaskProgress(aEvent, aProgress) {
startBatchTransaction(); startBatchTransaction();
var taskTree = getFocusedTaskTree(); var tasks = getSelectedTasks(aEvent);
var tasks = taskTree.selectedTasks;
for (var t = 0; t < tasks.length; t++) { for (var t = 0; t < tasks.length; t++) {
var task = tasks[t]; var task = tasks[t];
var newTask = task.clone().QueryInterface( Components.interfaces.calITodo ); var newTask = task.clone().QueryInterface( Components.interfaces.calITodo );
@ -159,8 +151,7 @@ function contextChangeTaskProgress(aProgress) {
function contextChangeTaskCategory(aEvent) { function contextChangeTaskCategory(aEvent) {
startBatchTransaction(); startBatchTransaction();
var taskTree = getFocusedTaskTree(); var tasks = getSelectedTasks(aEvent);
var tasks = taskTree.selectedTasks;
var tasksSelected = (tasks.length > 0); var tasksSelected = (tasks.length > 0);
if (tasksSelected) { if (tasksSelected) {
var menuItem = aEvent.target; var menuItem = aEvent.target;
@ -175,8 +166,7 @@ function contextChangeTaskCategory(aEvent) {
function contextChangeTaskCalendar(aEvent) { function contextChangeTaskCalendar(aEvent) {
startBatchTransaction(); startBatchTransaction();
var taskTree = getFocusedTaskTree(); var tasks = getSelectedTasks(aEvent);
var tasks = taskTree.selectedTasks;
for (var t = 0; t < tasks.length; t++) { for (var t = 0; t < tasks.length; t++) {
var task = tasks[t]; var task = tasks[t];
var newTask = task.clone().QueryInterface( Components.interfaces.calITodo ); var newTask = task.clone().QueryInterface( Components.interfaces.calITodo );
@ -186,10 +176,9 @@ function contextChangeTaskCalendar(aEvent) {
endBatchTransaction(); endBatchTransaction();
} }
function contextChangeTaskPriority(aPriority) { function contextChangeTaskPriority(aEvent, aPriority) {
startBatchTransaction(); startBatchTransaction();
var taskTree = getFocusedTaskTree(); var tasks = getSelectedTasks(aEvent);
var tasks = taskTree.selectedTasks;
for (var t = 0; t < tasks.length; t++) { for (var t = 0; t < tasks.length; t++) {
var task = tasks[t]; var task = tasks[t];
var newTask = task.clone().QueryInterface( Components.interfaces.calITodo ); var newTask = task.clone().QueryInterface( Components.interfaces.calITodo );
@ -199,9 +188,8 @@ function contextChangeTaskPriority(aPriority) {
endBatchTransaction(); endBatchTransaction();
} }
function modifyTaskFromContext() { function modifyTaskFromContext(aEvent) {
var taskTree = getFocusedTaskTree(); var tasks = getSelectedTasks(aEvent);
var tasks = taskTree.selectedTasks;
for (var t = 0; t < tasks.length; t++) { for (var t = 0; t < tasks.length; t++) {
modifyEventWithDialog(tasks[t], null, true); modifyEventWithDialog(tasks[t], null, true);
} }
@ -210,32 +198,43 @@ function modifyTaskFromContext() {
/** /**
* Delete the current selected item with focus from the task tree * Delete the current selected item with focus from the task tree
*/ */
function deleteToDoCommand(aDoNotConfirm) { function deleteToDoCommand(aEvent, aDoNotConfirm) {
var taskTree = getFocusedTaskTree(); var tasks = getSelectedTasks(aEvent);
var selectedItems = taskTree.selectedTasks; calendarViewController.deleteOccurrences(tasks.length,
calendarViewController.deleteOccurrences(selectedItems.length, tasks,
selectedItems,
false, false,
aDoNotConfirm); aDoNotConfirm);
} }
function getFocusedTaskTree() { function getSelectedTasks(aEvent) {
// Which tree is focused depends on the mode. var taskTree = null;
var taskTree; if (aEvent == null) {
var focusedElement = document.commandDispatcher.focusedElement; taskTree = document.getElementById("calendar-task-tree");
taskTree = getParentNode(focusedElement, "calendar-task-tree"); } else {
return taskTree; // 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() { function tasksToMail(aEvent) {
var taskTree = getFocusedTaskTree(); var tasks = getSelectedTasks(aEvent);
var tasks = taskTree.selectedTasks;
calendarMailButtonDNDObserver.onDropItems(tasks); calendarMailButtonDNDObserver.onDropItems(tasks);
} }
function tasksToEvents() { function tasksToEvents(aEvent) {
var taskTree = getFocusedTaskTree(); var tasks = getSelectedTasks(aEvent);
var tasks = taskTree.selectedTasks;
calendarCalendarButtonDNDObserver.onDropItems(tasks); calendarCalendarButtonDNDObserver.onDropItems(tasks);
} }

View File

@ -125,7 +125,6 @@
<field name="mLoadCount">0</field> <field name="mLoadCount">0</field>
<field name="mTaskArray">[]</field> <field name="mTaskArray">[]</field>
<field name="mHash2Index"><![CDATA[({})]]></field> <field name="mHash2Index"><![CDATA[({})]]></field>
<field name="mContextTask">null</field>
<field name="mRefreshQueue">[]</field> <field name="mRefreshQueue">[]</field>
<field name="mPendingRefresh">null</field> <field name="mPendingRefresh">null</field>
<field name="mShowCompletedTasks">true</field> <field name="mShowCompletedTasks">true</field>
@ -223,16 +222,6 @@
return this.mTreeView._getItemFromEvent(aEvent); return this.mTreeView._getItemFromEvent(aEvent);
]]></body> ]]></body>
</method> </method>
<property name="contextTask">
<getter><![CDATA[
return this.mContextTask;
]]></getter>
<setter><![CDATA[
this.mContextTask = val;
return this.mContextTask;
]]></setter>
</property>
<field name="mTreeView"><![CDATA[ <field name="mTreeView"><![CDATA[
({ ({

View File

@ -107,7 +107,7 @@
<implementation> <implementation>
<field name="kMinimonth">null</field> <field name="kMinimonth">null</field>
<constructor><![CDATA[ <constructor><![CDATA[
this.kMinimonth = getParentNode(this, "minimonth"); this.kMinimonth = getParentNodeOrThis(this, "minimonth");
]]></constructor> ]]></constructor>
<property name="month"> <property name="month">
<setter><![CDATA[ <setter><![CDATA[
@ -201,7 +201,7 @@
<field name="mPopup">null</field> <field name="mPopup">null</field>
<field name="mScrollYearsHandler">{}</field> <field name="mScrollYearsHandler">{}</field>
<constructor><![CDATA[ <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", "left-button").kMinimonth = this.kMinimonth;
document.getAnonymousElementByAttribute(this, "anonid", "today-button").kMinimonth = this.kMinimonth; document.getAnonymousElementByAttribute(this, "anonid", "today-button").kMinimonth = this.kMinimonth;
document.getAnonymousElementByAttribute(this, "anonid", "right-button").kMinimonth = this.kMinimonth; document.getAnonymousElementByAttribute(this, "anonid", "right-button").kMinimonth = this.kMinimonth;
@ -367,7 +367,7 @@
<handler event="click"> <handler event="click">
<![CDATA[ <![CDATA[
var element = event.originalTarget; var element = event.originalTarget;
var popup = getParentNode(element, "popup"); var popup = getParentNodeOrThis(element, "popup");
if (popup) { if (popup) {
var anonid = popup.getAttribute("anonid") var anonid = popup.getAttribute("anonid")
switch(anonid) { switch(anonid) {

View File

@ -263,7 +263,7 @@ function guessSystemTimezone() {
return 0; return 0;
} }
} }
var subComp = tz.component; var subComp = tz.component;
// find currently applicable time period, not just first, // find currently applicable time period, not just first,
// because offsets of timezone may be changed over the years. // because offsets of timezone may be changed over the years.
@ -287,7 +287,7 @@ function guessSystemTimezone() {
if (offsetDec == standardTZOffset && offsetJun == daylightTZOffset && if (offsetDec == standardTZOffset && offsetJun == daylightTZOffset &&
daylight) { daylight) {
var dateMatchWt = systemTZMatchesTimeShiftDates(tz, subComp); var dateMatchWt = systemTZMatchesTimeShiftDates(tz, subComp);
if (dateMatchWt > 0) { if (dateMatchWt > 0) {
if (standardName && standardName == tzNameJun && if (standardName && standardName == tzNameJun &&
daylightName && daylightName == tzNameDec) { daylightName && daylightName == tzNameDec) {
return 3; return 3;
@ -310,7 +310,7 @@ function guessSystemTimezone() {
if (offsetJun == standardTZOffset && offsetDec == daylightTZOffset && if (offsetJun == standardTZOffset && offsetDec == daylightTZOffset &&
daylight) { daylight) {
var dateMatchWt = systemTZMatchesTimeShiftDates(tz, subComp); var dateMatchWt = systemTZMatchesTimeShiftDates(tz, subComp);
if (dateMatchWt > 0) { if (dateMatchWt > 0) {
if (standardName && standardName == tzNameJun && if (standardName && standardName == tzNameJun &&
daylightName && daylightName == tzNameDec) { daylightName && daylightName == tzNameDec) {
return 3; return 3;
@ -348,7 +348,7 @@ function guessSystemTimezone() {
(beforeSpringShiftJSDate.getTimezoneOffset() > (beforeSpringShiftJSDate.getTimezoneOffset() >
afterSpringShiftJSDate.getTimezoneOffset())) { afterSpringShiftJSDate.getTimezoneOffset())) {
return 2; return 2;
} }
// Try with 7 DAYS fuzz in either direction, so if no other tz found, // Try with 7 DAYS fuzz in either direction, so if no other tz found,
// will have a nearby tz that disagrees only on the weekday of shift // will have a nearby tz that disagrees only on the weekday of shift
// (sunday vs. friday vs. calendar day), or off by exactly one week, // (sunday vs. friday vs. calendar day), or off by exactly one week,
@ -377,7 +377,7 @@ function guessSystemTimezone() {
const untilRegex = /UNTIL=(\d{8}T\d{6}Z)/; const untilRegex = /UNTIL=(\d{8}T\d{6}Z)/;
function findCurrentTimePeriod(tz, subComp, standardOrDaylight, function findCurrentTimePeriod(tz, subComp, standardOrDaylight,
isForNextTransitionDate) { isForNextTransitionDate) {
// Iterate through 'STANDARD' declarations or 'DAYLIGHT' declarations // Iterate through 'STANDARD' declarations or 'DAYLIGHT' declarations
// (periods in history with different settings. // (periods in history with different settings.
// e.g., US changes daylight start in 2007 (from April to March).) // e.g., US changes daylight start in 2007 (from April to March).)
@ -396,7 +396,7 @@ function guessSystemTimezone() {
// some zones (e.g., Arizona, Hawaii) may stop using daylight // some zones (e.g., Arizona, Hawaii) may stop using daylight
// time, so there might not be a next daylight start. // time, so there might not be a next daylight start.
var rrule = period.getFirstProperty("RRULE"); var rrule = period.getFirstProperty("RRULE");
if (rrule) { if (rrule) {
var match = untilRegex.exec(rrule.valueAsIcalString); var match = untilRegex.exec(rrule.valueAsIcalString);
if (match) { if (match) {
periodUntilCalDate.icalString = match[1]; periodUntilCalDate.icalString = match[1];
@ -409,12 +409,12 @@ function guessSystemTimezone() {
// found period that covers today. // found period that covers today.
if (!isForNextTransitionDate) { if (!isForNextTransitionDate) {
return period; return period;
} else /*isForNextTranstionDate*/ { } else /*isForNextTranstionDate*/ {
if (todayUTC.nativeTime < periodStartCalDate.nativeTime) { if (todayUTC.nativeTime < periodStartCalDate.nativeTime) {
// already know periodStartCalDate < oneYr from now, // already know periodStartCalDate < oneYr from now,
// and transitions are at most once per year, so it is next. // and transitions are at most once per year, so it is next.
return periodStartCalDate.jsDate; return periodStartCalDate.jsDate;
} else if (rrule) { } else if (rrule) {
// find next occurrence after today // find next occurrence after today
periodCalRule.icalProperty = rrule; periodCalRule.icalProperty = rrule;
var nextTransitionDate = var nextTransitionDate =
@ -427,7 +427,7 @@ function guessSystemTimezone() {
} }
} }
// no such period found // no such period found
return null; return null;
} }
@ -437,14 +437,14 @@ function guessSystemTimezone() {
var probableTZScore = 0; var probableTZScore = 0;
var probableTZSource = null; var probableTZSource = null;
const sbSvc = const sbSvc =
Components.classes["@mozilla.org/intl/stringbundle;1"] Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService); .getService(Components.interfaces.nsIStringBundleService);
const calProperties = const calProperties =
sbSvc.createBundle("chrome://calendar/locale/calendar.properties"); sbSvc.createBundle("chrome://calendar/locale/calendar.properties");
// First, try to detect operating system timezone. // First, try to detect operating system timezone.
try { try {
var osUserTimeZone = null; var osUserTimeZone = null;
var zoneInfoIdFromOSUserTimeZone = null; var zoneInfoIdFromOSUserTimeZone = null;
@ -458,7 +458,7 @@ function guessSystemTimezone() {
// in releases built on Gecko 1.9 or later. // in releases built on Gecko 1.9 or later.
regOSName = "Windows"; regOSName = "Windows";
fileOSName = "Windows98"; fileOSName = "Windows98";
} }
// If on Windows NT (2K/XP/Vista), current timezone only lists its // If on Windows NT (2K/XP/Vista), current timezone only lists its
// localized name, so to find its registry key name, match localized // localized name, so to find its registry key name, match localized
@ -512,7 +512,7 @@ function guessSystemTimezone() {
// - /etc/sysconfig/clock file line content. // - /etc/sysconfig/clock file line content.
// The timezone is set per user via the TZ environment variable. // The timezone is set per user via the TZ environment variable.
// TZ may contain a path that may start with a colon and ends with // TZ may contain a path that may start with a colon and ends with
// a ZoneInfo timezone identifier, such as ":America/New_York" or // a ZoneInfo timezone identifier, such as ":America/New_York" or
// ":/share/lib/zoneinfo/America/New_York". The others are // ":/share/lib/zoneinfo/America/New_York". The others are
// in the filesystem so they give one timezone for the system; // in the filesystem so they give one timezone for the system;
// the values are similar (but cannot have a leading colon). // the values are similar (but cannot have a leading colon).
@ -562,11 +562,11 @@ function guessSystemTimezone() {
const PR_RDONLY = 0x1; const PR_RDONLY = 0x1;
fileInstream.init(file, PR_RDONLY, 0, 0); fileInstream.init(file, PR_RDONLY, 0, 0);
fileInstream.QueryInterface(CI.nsILineInputStream); fileInstream.QueryInterface(CI.nsILineInputStream);
try { try {
var line = {}, hasMore = true, MAXLINES = 10; var line = {}, hasMore = true, MAXLINES = 10;
for (var i = 0; hasMore && i < MAXLINES; i++) { for (var i = 0; hasMore && i < MAXLINES; i++) {
hasMore = fileInstream.readLine(line); hasMore = fileInstream.readLine(line);
if (line.value && line.value.match(tzRegex)) { if (line.value && line.value.match(tzRegex)) {
return filepath+": "+line.value; return filepath+": "+line.value;
} }
} }
@ -578,7 +578,7 @@ function guessSystemTimezone() {
Components.utils.reportError(filepath+": "+ex); Components.utils.reportError(filepath+": "+ex);
return ""; return "";
} }
} }
osUserTimeZone = (environmentVariableValue("TZ") || osUserTimeZone = (environmentVariableValue("TZ") ||
symbolicLinkTarget("/etc/localtime") || symbolicLinkTarget("/etc/localtime") ||
@ -592,7 +592,7 @@ function guessSystemTimezone() {
} }
// check how well OS tz matches tz defined in our version of zoneinfo db // check how well OS tz matches tz defined in our version of zoneinfo db
if (zoneInfoIdFromOSUserTimeZone != null) { if (zoneInfoIdFromOSUserTimeZone != null) {
var tzId = tzSvc.tzidPrefix + zoneInfoIdFromOSUserTimeZone; var tzId = tzSvc.tzidPrefix + zoneInfoIdFromOSUserTimeZone;
var score = checkTZ(tzId); var score = checkTZ(tzId);
switch(score) { switch(score) {
@ -626,29 +626,29 @@ function guessSystemTimezone() {
("SkippingOSTimezone", ("SkippingOSTimezone",
[zoneInfoIdFromOSUserTimeZone || osUserTimeZone], 1)); [zoneInfoIdFromOSUserTimeZone || osUserTimeZone], 1));
Components.utils.reportError(errMsg+" "+ex); Components.utils.reportError(errMsg+" "+ex);
} }
// Second, give priority to "likelyTimezone"s if provided by locale. // Second, give priority to "likelyTimezone"s if provided by locale.
try { try {
// The likelyTimezone property is a comma-separated list of // The likelyTimezone property is a comma-separated list of
// ZoneInfo timezone ids. // ZoneInfo timezone ids.
const bundleTZString = const bundleTZString =
calProperties.GetStringFromName("likelyTimezone"); calProperties.GetStringFromName("likelyTimezone");
const bundleTZIds = bundleTZString.split(/\s*,\s*/); const bundleTZIds = bundleTZString.split(/\s*,\s*/);
for each (var bareTZId in bundleTZIds) { for each (var bareTZId in bundleTZIds) {
var tzId = bareTZId; var tzId = bareTZId;
if (tzId.indexOf("/mozilla.org/") == -1) { if (tzId.indexOf("/mozilla.org/") == -1) {
// Convert a ZoneInfo timezone to a mozilla timezone-string // Convert a ZoneInfo timezone to a mozilla timezone-string
tzId = tzSvc.tzidPrefix + tzId; tzId = tzSvc.tzidPrefix + tzId;
} }
try { try {
var score = checkTZ(tzId); var score = checkTZ(tzId);
switch (score) { switch (score) {
case 0: case 0:
break; break;
case 1: case 2: case 1: case 2:
if (score > probableTZScore) { if (score > probableTZScore) {
probableTZId = tzId; probableTZId = tzId;
probableTZScore = score; probableTZScore = score;
probableTZSource = (calProperties.GetStringFromName probableTZSource = (calProperties.GetStringFromName
@ -667,14 +667,14 @@ function guessSystemTimezone() {
} catch (ex) { // Oh well, this didn't work, next option... } catch (ex) { // Oh well, this didn't work, next option...
Components.utils.reportError(ex); Components.utils.reportError(ex);
} }
// Third, try all known timezones. // Third, try all known timezones.
const tzIDs = tzSvc.timezoneIds; const tzIDs = tzSvc.timezoneIds;
while (tzIDs.hasMore()) { while (tzIDs.hasMore()) {
var tzId = tzIDs.getNext(); var tzId = tzIDs.getNext();
try { try {
var score = checkTZ(tzId); var score = checkTZ(tzId);
switch(score) { switch(score) {
case 0: break; case 0: break;
case 1: case 2: case 1: case 2:
if (score > probableTZScore) { if (score > probableTZScore) {
@ -695,7 +695,7 @@ function guessSystemTimezone() {
} }
// If reach here, there were no score=3 matches, so Warn in console. // If reach here, there were no score=3 matches, so Warn in console.
try { try {
switch(probableTZScore) { switch(probableTZScore) {
case 0: case 0:
WARN(calProperties.GetStringFromName("warningUsingFloatingTZNoMatch")); WARN(calProperties.GetStringFromName("warningUsingFloatingTZNoMatch"));
@ -721,7 +721,7 @@ function guessSystemTimezone() {
var standardStart = getIcalString(standard, "DTSTART"); var standardStart = getIcalString(standard, "DTSTART");
var standardStartWeekday = weekday(standardStart); var standardStartWeekday = weekday(standardStart);
var standardRule = getIcalString(standard, "RRULE"); var standardRule = getIcalString(standard, "RRULE");
var standardText = var standardText =
(" Standard: "+standardStart+" "+standardStartWeekday+"\n"+ (" Standard: "+standardStart+" "+standardStartWeekday+"\n"+
" "+standardRule+"\n"); " "+standardRule+"\n");
var daylightStart = getIcalString(daylight, "DTSTART"); var daylightStart = getIcalString(daylight, "DTSTART");
@ -1154,7 +1154,7 @@ function getUUID() {
if ("@mozilla.org/uuid-generator;1" in Components.classes) { if ("@mozilla.org/uuid-generator;1" in Components.classes) {
var uuidGen = Components.classes["@mozilla.org/uuid-generator;1"]. var uuidGen = Components.classes["@mozilla.org/uuid-generator;1"].
getService(Components.interfaces.nsIUUIDGenerator); getService(Components.interfaces.nsIUUIDGenerator);
// generate uuids without braces to avoid problems with // generate uuids without braces to avoid problems with
// CalDAV servers that don't support filenames with {} // CalDAV servers that don't support filenames with {}
return uuidGen.generateUUID().toString().replace(/[{}]/g, ''); return uuidGen.generateUUID().toString().replace(/[{}]/g, '');
} }
@ -1166,7 +1166,7 @@ function getUUID() {
* have 2 objects. Use these functions to force them both to get wrapped * have 2 objects. Use these functions to force them both to get wrapped
* the same way, allowing for normal comparison. * the same way, allowing for normal comparison.
*/ */
/** /**
* calIItemBase comparer * calIItemBase comparer
*/ */
@ -1340,10 +1340,10 @@ function setDefaultStartEndHour(aItem, aReferenceDate) {
****/ ****/
/** /**
* Logs a string or an object to both stderr and the js-console only in the case * Logs a string or an object to both stderr and the js-console only in the case
* where the calendar.debug.log pref is set to true. * where the calendar.debug.log pref is set to true.
* *
* @param aArg either a string to log or an object whose entire set of * @param aArg either a string to log or an object whose entire set of
* properties should be logged. * properties should be logged.
*/ */
function LOG(aArg) { function LOG(aArg) {
@ -1369,7 +1369,7 @@ function LOG(aArg) {
} else { } else {
string = aArg; string = aArg;
} }
dump(string + '\n'); dump(string + '\n');
getConsoleService().logStringMessage(string); getConsoleService().logStringMessage(string);
} }
@ -1444,7 +1444,7 @@ function showError(aMsg) {
/** /**
* Pick whichever of "black" or "white" will look better when used as a text * Pick whichever of "black" or "white" will look better when used as a text
* color against a background of bgColor. * color against a background of bgColor.
* *
* @param bgColor the background color as a "#RRGGBB" string * @param bgColor the background color as a "#RRGGBB" string
*/ */
@ -1874,7 +1874,7 @@ function calSetProdidVersion(aIcalComponent) {
* @param * @param
* aElement The XUL element to derive the sibling from * aElement The XUL element to derive the sibling from
* @param * @param
* aDistance An integer value denoting how the relative position * aDistance An integer value denoting how the relative position
* of the returned sibling within the parent container * of the returned sibling within the parent container
*/ */
function getAdjacentSibling(aElement, aDistance) { function getAdjacentSibling(aElement, aDistance) {
@ -1899,7 +1899,7 @@ function getAdjacentSibling(aElement, aDistance) {
* *
* @param aMenuPopupId The Id of the popup-menu to be cloned * @param aMenuPopupId The Id of the popup-menu to be cloned
* @param aNewPopupId The new id of the cloned popup-menu * @param aNewPopupId The new id of the cloned popup-menu
* @param aNewIdPrefix To keep the ids unique the childnodes of the returned * @param aNewIdPrefix To keep the ids unique the childnodes of the returned
* popup-menu are prepended with a prefix * popup-menu are prepended with a prefix
* @return the cloned popup-menu * @return the cloned popup-menu
*/ */
@ -1939,15 +1939,15 @@ function applyAttributeToMenuChildren(aElement, aAttributeName, aValue) {
} }
} }
domObject.setAttribute(aAttributeName, aValue); domObject.setAttribute(aAttributeName, aValue);
sibling = sibling.nextSibling; sibling = sibling.nextSibling;
} }
} while (sibling); } while (sibling);
} }
/** /**
* compares the value of a property of an array of objects and returns * compares the value of a property of an array of objects and returns
* true or false if it is same or not among all array members * true or false if it is same or not among all array members
* *
* @param aObjects An Array of Objects to inspect * @param aObjects An Array of Objects to inspect
* @param aProperty Name the name of the Property of which the value is compared * @param aProperty Name the name of the Property of which the value is compared
@ -1965,9 +1965,9 @@ function isPropertyValueSame(aObjects, aPropertyName) {
} }
return true; return true;
} }
/** /**
* sets the value of a boolean attribute by either setting the value or * sets the value of a boolean attribute by either setting the value or
* removing the attribute * removing the attribute
* *
* @param aXulElement The XulElement the attribute is applied to * @param aXulElement The XulElement the attribute is applied to
@ -1987,12 +1987,50 @@ function setBooleanAttribute(aXulElement, aAttribute, aValue) {
} }
} }
function getParentNode(aNode, aLocalName) { /**
var node = aNode; * returns a parentnode - or the overgiven node - with the given localName,
do { * by "walking up" the DOM-hierarchy.
node = node && node.parentNode; *
} while (node && (node.localName != aLocalName)); * @param aChildNode The childnode.
return node; * @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;
} }
function setItemProperty(item, propertyName, aValue, aCapability) { function setItemProperty(item, propertyName, aValue, aCapability) {
@ -2222,7 +2260,7 @@ function sendItipInvitation(aItem, aTypeOfInvitation, aRecipientsList) {
bodyStringId = "itipCancelBody"; bodyStringId = "itipCancelBody";
break; break;
} }
var subject = sb.formatStringFromName(subjectStringId, var subject = sb.formatStringFromName(subjectStringId,
[summary], 1); [summary], 1);
var body = sb.formatStringFromName(bodyStringId, var body = sb.formatStringFromName(bodyStringId,

View File

@ -548,6 +548,7 @@ function copyPopupMenus() {
addToPopupList(menulist[2], null, taskpopuplist, excludeList, true, true); addToPopupList(menulist[2], null, taskpopuplist, excludeList, true, true);
addToPopupList(menulist[3], document.getElementById("calendar-GoPopupMenu"), taskpopuplist, excludeList, true, false); addToPopupList(menulist[3], document.getElementById("calendar-GoPopupMenu"), taskpopuplist, excludeList, true, false);
var tasksViewMenuPopup = clonePopupMenu("taskitem-context-menu", "taskitem-menu", "menu-"); 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-modify", tasksViewMenuPopup));
tasksViewMenuPopup.removeChild(getMenuElementById("menu-" + "task-context-menu-delete", tasksViewMenuPopup)); tasksViewMenuPopup.removeChild(getMenuElementById("menu-" + "task-context-menu-delete", tasksViewMenuPopup));
addToPopupList(menulist[4], tasksViewMenuPopup, taskpopuplist, excludeList, false, false); addToPopupList(menulist[4], tasksViewMenuPopup, taskpopuplist, excludeList, false, false);