Bug 346934 Unify Sunbird/Lightning item creation/modification code, r1=lilmatt, r2=mvl

This commit is contained in:
jminta%gmail.com 2006-11-06 18:41:13 +00:00
Родитель 63ccc6700f
Коммит b32e8bbf8a
5 изменённых файлов: 17 добавлений и 96 удалений

Просмотреть файл

@ -55,7 +55,7 @@ function createEventWithDialog(calendar, startDate, endDate, summary, event)
event = createEvent();
if (!startDate) {
startDate = jsDateToDateTime(new Date());
startDate = currentView().selectedDay.clone();
startDate.second = 0;
startDate.normalize();
} else if (startDate.isDate) {
@ -91,6 +91,9 @@ function createEventWithDialog(calendar, startDate, endDate, summary, event)
if (calendar) {
event.calendar = calendar;
} else if ("getSelectedCalendarOrNull" in window) {
// Sunbird specific code
event.calendar = getSelectedCalendarOrNull();
}
if (summary)
@ -118,6 +121,9 @@ function createTodoWithDialog(calendar, dueDate, summary, todo)
if (calendar) {
todo.calendar = calendar;
} else if ("getSelectedCalendarOrNull" in window) {
// Sunbird specific code
todo.calendar = getSelectedCalendarOrNull();
}
if (summary)

Просмотреть файл

@ -177,7 +177,7 @@ function handleCommandLine(aComLine) {
/* Called at midnight to tell us to update the views and other ui bits */
function refreshUIBits() {
gCalendarWindow.currentView.hiliteTodaysDate();
currentView().goToDay(now());
refreshEventTree();
// and schedule again...
@ -252,67 +252,6 @@ function deleteCalendar(event)
}
}
/**
* Defaults null start/end date based on selected date in current view.
* Defaults calendarFile to the selected calendar file.
* Calls editNewEvent.
*/
function newEvent(startDate, endDate, allDay)
{
// create a new event to be edited and added
var calendarEvent = createEvent();
if (!startDate) {
startDate = gCalendarWindow.currentView.getNewEventDate();
}
calendarEvent.startDate.jsDate = startDate;
if (!endDate) {
var pb2 = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch2);
var MinutesToAddOn = pb2.getIntPref("calendar.event.defaultlength");
endDate = new Date(startDate);
endDate.setMinutes(endDate.getMinutes() + MinutesToAddOn);
}
calendarEvent.endDate.jsDate = endDate
setDefaultAlarmValues(calendarEvent);
if (allDay)
calendarEvent.startDate.isDate = true;
var calendar = getSelectedCalendarOrNull();
createEventWithDialog(calendar, null, null, null, calendarEvent);
}
/*
* Defaults null start/due date to the no_date date.
* Defaults calendarFile to the selected calendar file.
* Calls editNewToDo.
*/
function newToDo ( startDate, dueDate )
{
var calendarToDo = createToDo();
// created todo has no start or due date unless user wants one
if (startDate)
calendarToDo.entryDate = jsDateToDateTime(startDate);
if (dueDate)
calendarToDo.dueDate = jsDateToDateTime(startDate);
setDefaultAlarmValues(calendarToDo);
var calendar = getSelectedCalendarOrNull();
createTodoWithDialog(calendar, null, null, calendarToDo);
}
/**
* Get the default calendar selected in the calendars tab.
* Returns a calICalendar object, or null if none selected.
@ -327,30 +266,6 @@ function getSelectedCalendarOrNull()
return null;
}
/**
* This is called from the unifinder's edit command
*/
function editEvent(aEvent)
{
if (aEvent) {
modifyEventWithDialog(aEvent);
return;
}
if (gXXXEvilHackSavedSelection.length == 1) {
modifyEventWithDialog(
getOccurrenceOrParent(gXXXEvilHackSavedSelection[0]));
}
}
function editToDo(task) {
if (!task)
return;
modifyEventWithDialog(getOccurrenceOrParent(task));
}
/**
* This is called from the unifinder's delete command
*

Просмотреть файл

@ -312,9 +312,9 @@ function unifinderDoubleClickEvent( event )
var calendarEvent = getCalendarEventFromEvent( event );
if( calendarEvent != null )
editEvent(calendarEvent);
modifyEventWithDialog(calendarEvent);
else
newEvent();
createEventWithDialog();
}
@ -807,7 +807,7 @@ function unifinderKeyPress(aEvent) {
switch (aEvent.keyCode) {
case 13:
// Enter, edit the event
editEvent();
modifyEventWithDialog(getSelectedItems()[0]);
break;
case kKE.DOM_VK_BACK_SPACE:
case kKE.DOM_VK_DELETE:

Просмотреть файл

@ -259,9 +259,9 @@ function modifyToDoCommand( event )
var ThisToDo = getToDoFromEvent( event );
if( ThisToDo )
editToDo( ThisToDo );
modifyEventWithDialog(ThisToDo);
else
newToDo();
createTodoWithDialog();
}
/**
@ -660,7 +660,7 @@ function contextChangePriority( event, Priority )
function modifyTaskFromContext() {
var task = document.getElementById( ToDoUnifinderTreeName ).taskView.contextTask;
if(task)
editToDo(task);
createTodoWithDialog(task);
}
function changeContextMenuForToDo(event)

Просмотреть файл

@ -49,10 +49,10 @@
</broadcasterset>
<commandset id="calendar_commands">
<command id="new_command" oncommand="newEvent()"/>
<command id="new_command" oncommand="createEventWithDialog()"/>
<command id="delete_command" oncommand="deleteEventCommand( )" disabled="true" disabledwhennoeventsselected="true"/>
<command id="delete_command_no_confirm" oncommand="deleteEventCommand( true )" disabled="true" disabledwhennoeventsselected="true"/>
<command id="modify_command" oncommand="editEvent()" disabled="true" disabledwhennoeventsselected="true"/>
<command id="modify_command" oncommand="modifyEventWithDialog(getSelectedItems()[0])" disabled="true" disabledwhennoeventsselected="true"/>
<command id="send_event_command" oncommand="sendEvent()" disabled="true" disabledwhennoeventsselected="true"/>
<command id="cmd_pageSetup" oncommand="PrintUtils.showPageSetup();"/>
<command id="print_command" oncommand="calPrint()"/>
@ -64,7 +64,7 @@
<command id="paste_command" oncommand="pasteFromClipboard()"/>
<command id="select_all_command" oncommand="selectAllEvents()"/>
<command id="new_todo_command" oncommand="newToDo()"/>
<command id="new_todo_command" oncommand="createTodoWithDialog()"/>
<command id="modify_todo_command" oncommand="editToDo()"/>
<command id="delete_todo_command" oncommand="deleteToDoCommand()" disabled="true"/>