mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
bug #356833 make the event/item dialog modeless r1=lilmatt, r2=mvl
This commit is contained in:
parent
310e98d8cf
commit
8a8fb1e50f
@ -55,6 +55,32 @@ function onLoad()
|
||||
window.mode = args.mode;
|
||||
window.recurrenceInfo = null;
|
||||
|
||||
// the calling entity provides us with an object that is responsible
|
||||
// for recording details about the initiated modification. the 'finalize'-property
|
||||
// is our hook in order to receive a notification in case the operation needs
|
||||
// to be terminated prematurely. this function will be called if the calling
|
||||
// entity needs to immediately terminate the pending modification. in this
|
||||
// case we serialize the item and close the window.
|
||||
if (args.job) {
|
||||
|
||||
// keep this context...
|
||||
var self = this;
|
||||
|
||||
// store the 'finalize'-functor in the provided job-object.
|
||||
args.job.finalize = function finalize() {
|
||||
|
||||
// store any pending modifications...
|
||||
self.onAccept();
|
||||
|
||||
var item = window.calendarItem;
|
||||
|
||||
// ...and close the window.
|
||||
window.close();
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
if (window.calendarItem.calendar && window.calendarItem.calendar.readOnly) {
|
||||
gReadOnlyMode = true;
|
||||
}
|
||||
@ -99,6 +125,13 @@ function onLoad()
|
||||
self.focus();
|
||||
}
|
||||
|
||||
function dispose()
|
||||
{
|
||||
var args = window.arguments[0];
|
||||
if(args.job && args.job.dispose)
|
||||
args.job.dispose();
|
||||
}
|
||||
|
||||
function onAccept()
|
||||
{
|
||||
// if this event isn't mutable, we need to clone it like a sheep
|
||||
@ -115,12 +148,16 @@ function onAccept()
|
||||
// of a bug on 1_8_BRANCH we need this to make it really persist.
|
||||
document.persist("description-row", "collapsed");
|
||||
|
||||
dispose();
|
||||
|
||||
window.calendarItem = item;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function onCancel()
|
||||
{
|
||||
|
||||
dispose();
|
||||
}
|
||||
|
||||
function loadDialog(item)
|
||||
|
@ -48,7 +48,7 @@ function createEventWithDialog(calendar, startDate, endDate, summary, event)
|
||||
}
|
||||
|
||||
if (event) {
|
||||
openEventDialog(event, calendar, "new", onNewEvent);
|
||||
openEventDialog(event, calendar, "new", onNewEvent, null);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ function createEventWithDialog(calendar, startDate, endDate, summary, event)
|
||||
|
||||
setDefaultAlarmValues(event);
|
||||
|
||||
openEventDialog(event, calendar, "new", onNewEvent);
|
||||
openEventDialog(event, calendar, "new", onNewEvent, null);
|
||||
}
|
||||
|
||||
function createTodoWithDialog(calendar, dueDate, summary, todo)
|
||||
@ -103,7 +103,7 @@ function createTodoWithDialog(calendar, dueDate, summary, todo)
|
||||
}
|
||||
|
||||
if (todo) {
|
||||
openEventDialog(todo, calendar, "new", onNewItem);
|
||||
openEventDialog(todo, calendar, "new", onNewItem, null);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -128,11 +128,11 @@ function createTodoWithDialog(calendar, dueDate, summary, todo)
|
||||
|
||||
setDefaultAlarmValues(todo);
|
||||
|
||||
openEventDialog(todo, calendar, "new", onNewItem);
|
||||
openEventDialog(todo, calendar, "new", onNewItem, null);
|
||||
}
|
||||
|
||||
|
||||
function modifyEventWithDialog(item)
|
||||
function modifyEventWithDialog(item, job)
|
||||
{
|
||||
var onModifyItem = function(item, calendar, originalItem) {
|
||||
// compare cal.uri because there may be multiple instances of
|
||||
@ -147,29 +147,30 @@ function modifyEventWithDialog(item)
|
||||
}
|
||||
|
||||
if (item) {
|
||||
openEventDialog(item, item.calendar, "modify", onModifyItem);
|
||||
openEventDialog(item, item.calendar, "modify", onModifyItem, job);
|
||||
}
|
||||
}
|
||||
|
||||
function openEventDialog(calendarItem, calendar, mode, callback)
|
||||
function openEventDialog(calendarItem, calendar, mode, callback, job)
|
||||
{
|
||||
var args = new Object();
|
||||
args.calendarEvent = calendarItem;
|
||||
args.calendar = calendar;
|
||||
args.mode = mode;
|
||||
args.onOk = callback;
|
||||
args.job = job;
|
||||
|
||||
// the dialog will reset this to auto when it is done loading.
|
||||
window.setCursor("wait");
|
||||
|
||||
// open the dialog modally
|
||||
// open the dialog modeless
|
||||
var url = "chrome://calendar/content/calendar-event-dialog.xul";
|
||||
|
||||
if (getPrefSafe("calendar.prototypes.wcap", false)) {
|
||||
openDialog("chrome://calendar/content/sun-calendar-event-dialog.xul", "_blank",
|
||||
"chrome,titlebar,modal,resizable", args);
|
||||
} else {
|
||||
openDialog("chrome://calendar/content/calendar-event-dialog.xul", "_blank",
|
||||
"chrome,titlebar,modal,resizable", args);
|
||||
url = "chrome://calendar/content/sun-calendar-event-dialog.xul";
|
||||
}
|
||||
|
||||
openDialog(url, "_blank", "chrome,titlebar,resizable", args);
|
||||
}
|
||||
|
||||
// When editing a single instance of a recurring event, we need to figure out
|
||||
|
@ -82,7 +82,62 @@ var calendarViewController = {
|
||||
}
|
||||
},
|
||||
|
||||
pendingJobs: [],
|
||||
|
||||
// in order to initiate a modification for the occurrence passed as argument
|
||||
// we create an object that records the necessary details and store it in an
|
||||
// internal array ('pendingJobs'). this way we're in a position to terminate
|
||||
// any pending modification if need should be.
|
||||
createPendingModification: function (aOccurrence) {
|
||||
// finalize a (possibly) pending modification. this will notify
|
||||
// an open dialog to save any outstanding modifications.
|
||||
aOccurrence = this.finalizePendingModification(aOccurrence);
|
||||
|
||||
var pendingModification = {
|
||||
controller: this,
|
||||
item: aOccurrence,
|
||||
finalize: null,
|
||||
dispose: function() {
|
||||
var array = this.controller.pendingJobs;
|
||||
for (var i=0; i<array.length; i++) {
|
||||
if (array[i] == this) {
|
||||
array.splice(i,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.pendingJobs.push(pendingModification);
|
||||
|
||||
modifyEventWithDialog(aOccurrence,pendingModification);
|
||||
},
|
||||
|
||||
// iterate the list of pending modifications and see if the occurrence
|
||||
// passed as argument is currently about to be modified (event dialog is
|
||||
// open with the item in question). if this should be the case we call
|
||||
// finalize() in order to bring the dialog down and avoid dataloss.
|
||||
finalizePendingModification: function (aOccurrence) {
|
||||
|
||||
for each (var job in this.pendingJobs) {
|
||||
var item = job.item;
|
||||
var parent = item.parent;
|
||||
if (item.hasSameIds(aOccurrence) ||
|
||||
item.parentItem.hasSameIds(aOccurrence) ||
|
||||
item.hasSameIds(aOccurrence.parentItem)) {
|
||||
// terminate() will most probably create a modified item instance.
|
||||
aOccurrence = job.finalize();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return aOccurrence;
|
||||
},
|
||||
|
||||
modifyOccurrence: function (aOccurrence, aNewStartTime, aNewEndTime, aNewTitle) {
|
||||
|
||||
aOccurrence = this.finalizePendingModification(aOccurrence);
|
||||
|
||||
// if modifying this item directly (e.g. just dragged to new time),
|
||||
// then do so; otherwise pop up the dialog
|
||||
if ((aNewStartTime && aNewEndTime) || aNewTitle) {
|
||||
@ -115,7 +170,8 @@ var calendarViewController = {
|
||||
if (!itemToEdit) {
|
||||
return; // user cancelled
|
||||
}
|
||||
modifyEventWithDialog(itemToEdit);
|
||||
|
||||
this.createPendingModification(itemToEdit);
|
||||
}
|
||||
},
|
||||
|
||||
@ -124,6 +180,7 @@ var calendarViewController = {
|
||||
if (!itemToDelete) {
|
||||
return;
|
||||
}
|
||||
itemToDelete = this.finalizePendingModification(itemToDelete);
|
||||
if (!itemToDelete.parentItem.hasSameIds(itemToDelete)) {
|
||||
var event = itemToDelete.parentItem.clone();
|
||||
event.recurrenceInfo.removeOccurrenceAt(itemToDelete.recurrenceId);
|
||||
|
@ -86,6 +86,32 @@ function onLoad()
|
||||
// arguments this window has been called with.
|
||||
var args = window.arguments[0];
|
||||
|
||||
// the calling entity provides us with an object that is responsible
|
||||
// for recording details about the initiated modification. the 'finalize'-property
|
||||
// is our hook in order to receive a notification in case the operation needs
|
||||
// to be terminated prematurely. this function will be called if the calling
|
||||
// entity needs to immediately terminate the pending modification. in this
|
||||
// case we serialize the item and close the window.
|
||||
if(args.job) {
|
||||
|
||||
// keep this context...
|
||||
var self = this;
|
||||
|
||||
// store the 'finalize'-functor in the provided job-object.
|
||||
args.job.finalize = function() {
|
||||
|
||||
// store any pending modifications...
|
||||
self.onAccept();
|
||||
|
||||
var item = window.calendarItem;
|
||||
|
||||
// ...and close the window.
|
||||
window.close();
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
window.fbWrapper = args.fbWrapper;
|
||||
|
||||
// the most important attribute we expect from the
|
||||
@ -157,21 +183,34 @@ function onLoad()
|
||||
document.getElementById("item-title").select();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// dispose
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function dispose()
|
||||
{
|
||||
var args = window.arguments[0];
|
||||
if(args.job && args.job.dispose)
|
||||
args.job.dispose();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// onAccept
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function onAccept()
|
||||
{
|
||||
dispose();
|
||||
|
||||
onCommandSave();
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// onCancel
|
||||
// onCommandCancel
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function onCancel()
|
||||
function onCommandCancel()
|
||||
{
|
||||
// assume that new items need to be asked whether or
|
||||
// not the newly created item wants to be saved.
|
||||
@ -224,6 +263,19 @@ function onCancel()
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// onCancel
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function onCancel()
|
||||
{
|
||||
var result = onCommandCancel();
|
||||
if(result == true) {
|
||||
dispose();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// timezoneString
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user