diff --git a/UI/Contacts/UIxContactFoldersView.h b/UI/Contacts/UIxContactFoldersView.h index 686982197..51f58b9d6 100644 --- a/UI/Contacts/UIxContactFoldersView.h +++ b/UI/Contacts/UIxContactFoldersView.h @@ -26,6 +26,13 @@ #import @interface UIxContactFoldersView : UIxComponent +{ + NSUserDefaults *ud; + NSMutableDictionary *moduleSettings; +} + +- (WOResponse *) getDragHandlesStateAction; +- (WOResponse *) saveDragHandleStateAction; @end diff --git a/UI/Contacts/UIxContactFoldersView.m b/UI/Contacts/UIxContactFoldersView.m index c662072a0..964d3506b 100644 --- a/UI/Contacts/UIxContactFoldersView.m +++ b/UI/Contacts/UIxContactFoldersView.m @@ -21,6 +21,7 @@ */ #import +#import #import #import @@ -46,6 +47,27 @@ @implementation UIxContactFoldersView +- (void) _setupContext +{ + SOGoUser *activeUser; + NSString *module; + SOGoContactFolders *clientObject; + + activeUser = [context activeUser]; + clientObject = [self clientObject]; + + module = [clientObject nameInContainer]; + + ud = [activeUser userSettings]; + moduleSettings = [ud objectForKey: module]; + if (!moduleSettings) + { + moduleSettings = [NSMutableDictionary new]; + [moduleSettings autorelease]; + } + [ud setObject: moduleSettings forKey: module]; +} + - (id) _selectActionForApplication: (NSString *) actionName { SOGoContactFolders *folders; @@ -247,4 +269,44 @@ // ? contactFolder : nil); // } +- (WOResponse *) getDragHandlesStateAction +{ + NSArray *dragHandles; + NSString *vertical, *horizontal; + + [self _setupContext]; + + vertical = [moduleSettings objectForKey: @"DragHandleVertical"]; + horizontal = [moduleSettings objectForKey: @"DragHandleHorizontal"]; + dragHandles = [[NSArray alloc] initWithObjects: + vertical ? vertical : @"", + horizontal ? horizontal : @"", + nil]; + + return [self responseWithStatus: 200 + andString: [dragHandles jsonRepresentation]]; +} + +- (WOResponse *) saveDragHandleStateAction +{ + WORequest *request; + NSString *dragHandle; + + [self _setupContext]; + request = [context request]; + + if ((dragHandle = [request formValueForKey: @"vertical"]) != nil) + [moduleSettings setObject: dragHandle + forKey: @"DragHandleVertical"]; + else if ((dragHandle = [request formValueForKey: @"horizontal"]) != nil) + [moduleSettings setObject: dragHandle + forKey: @"DragHandleHorizontal"]; + else + return [self responseWithStatus: 400]; + + [ud synchronize]; + + return [self responseWithStatus: 204]; +} + @end diff --git a/UI/Contacts/product.plist b/UI/Contacts/product.plist index 7cb5f6fcb..4a0285aee 100644 --- a/UI/Contacts/product.plist +++ b/UI/Contacts/product.plist @@ -50,6 +50,16 @@ protectedBy = "View"; pageName = "UIxContactsUserFolders"; }; + dragHandlesState = { + protectedBy = ""; + pageName = "UIxContactFoldersView"; + actionName = "getDragHandlesState"; + }; + saveDragHandleState = { + protectedBy = "View"; + pageName = "UIxContactFoldersView"; + actionName = "saveDragHandleState"; + }; }; }; diff --git a/UI/MailerUI/UIxMailMainFrame.h b/UI/MailerUI/UIxMailMainFrame.h index 2147d5f18..a4f3dcc6b 100644 --- a/UI/MailerUI/UIxMailMainFrame.h +++ b/UI/MailerUI/UIxMailMainFrame.h @@ -34,7 +34,7 @@ - (WOResponse *) getDragHandlesStateAction; - (WOResponse *) getFoldersStateAction; -- (WOResponse *) saveDragHandlesStateAction; +- (WOResponse *) saveDragHandleStateAction; - (WOResponse *) saveFoldersStateAction; @end diff --git a/UI/MailerUI/UIxMailMainFrame.m b/UI/MailerUI/UIxMailMainFrame.m index 83f24614e..40126f46d 100644 --- a/UI/MailerUI/UIxMailMainFrame.m +++ b/UI/MailerUI/UIxMailMainFrame.m @@ -165,12 +165,20 @@ - (WOResponse *) getDragHandlesStateAction { - NSString *dragHandles; + NSArray *dragHandles; + NSString *vertical, *horizontal; [self _setupContext]; - dragHandles = [moduleSettings objectForKey: @"DragHandles"]; - return [self responseWithStatus: 200 andString: dragHandles]; + vertical = [moduleSettings objectForKey: @"DragHandleVertical"]; + horizontal = [moduleSettings objectForKey: @"DragHandleHorizontal"]; + dragHandles = [[NSArray alloc] initWithObjects: + vertical ? vertical : @"", + horizontal ? horizontal : @"", + nil]; + + return [self responseWithStatus: 200 + andString: [dragHandles jsonRepresentation]]; } - (WOResponse *) getFoldersStateAction @@ -183,20 +191,25 @@ return [self responseWithStatus: 200 andString: expandedFolders]; } -- (WOResponse *) saveDragHandlesStateAction +- (WOResponse *) saveDragHandleStateAction { WORequest *request; - NSString *dragHandles; + NSString *dragHandle; [self _setupContext]; request = [context request]; - dragHandles = [request formValueForKey: @"dragHandles"]; + + if ((dragHandle = [request formValueForKey: @"vertical"]) != nil) + [moduleSettings setObject: dragHandle + forKey: @"DragHandleVertical"]; + else if ((dragHandle = [request formValueForKey: @"horizontal"]) != nil) + [moduleSettings setObject: dragHandle + forKey: @"DragHandleHorizontal"]; + else + return [self responseWithStatus: 400]; - [moduleSettings setObject: dragHandles - forKey: @"DragHandles"]; - [ud synchronize]; - + return [self responseWithStatus: 204]; } diff --git a/UI/MailerUI/product.plist b/UI/MailerUI/product.plist index e15dd206a..4b10ad44d 100644 --- a/UI/MailerUI/product.plist +++ b/UI/MailerUI/product.plist @@ -340,10 +340,10 @@ pageName = "UIxMailMainFrame"; actionName = "getFoldersState"; }; - saveDragHandlesState = { + saveDragHandleState = { protectedBy = "View"; pageName = "UIxMailMainFrame"; - actionName = "saveDragHandlesState"; + actionName = "saveDragHandleState"; }; saveFoldersState = { protectedBy = "View"; diff --git a/UI/Scheduler/UIxCalMainView.h b/UI/Scheduler/UIxCalMainView.h index b1e13a08d..3ebb2fe04 100644 --- a/UI/Scheduler/UIxCalMainView.h +++ b/UI/Scheduler/UIxCalMainView.h @@ -33,6 +33,8 @@ { NSString *monthMenuItem; NSNumber *yearMenuItem; + NSUserDefaults *ud; + NSMutableDictionary *moduleSettings; } - (NSArray *) monthMenuItems; @@ -45,6 +47,9 @@ - (void) setYearMenuItem: (NSNumber *) aYearMenuItem; - (NSNumber *) yearMenuItem; +- (WOResponse *) getDragHandlesStateAction; +- (WOResponse *) saveDragHandleStateAction; + @end #endif /* UIXCALMAINVIEW_H */ diff --git a/UI/Scheduler/UIxCalMainView.m b/UI/Scheduler/UIxCalMainView.m index fdbdd81f7..0739df961 100644 --- a/UI/Scheduler/UIxCalMainView.m +++ b/UI/Scheduler/UIxCalMainView.m @@ -28,11 +28,14 @@ #import #import +#import #import #import #import +#import + #import "UIxCalMainView.h" #import @@ -42,6 +45,27 @@ static NSMutableArray *yearMenuItems = nil; @implementation UIxCalMainView +- (void) _setupContext +{ + SOGoUser *activeUser; + NSString *module; + SOGoAppointmentFolders *clientObject; + + activeUser = [context activeUser]; + clientObject = [self clientObject]; + + module = [clientObject nameInContainer]; + + ud = [activeUser userSettings]; + moduleSettings = [ud objectForKey: module]; + if (!moduleSettings) + { + moduleSettings = [NSMutableDictionary new]; + [moduleSettings autorelease]; + } + [ud setObject: moduleSettings forKey: module]; +} + - (NSArray *) monthMenuItems { unsigned int count; @@ -100,4 +124,44 @@ static NSMutableArray *yearMenuItems = nil; return yearMenuItem; } +- (WOResponse *) getDragHandlesStateAction +{ + NSArray *dragHandles; + NSString *vertical, *horizontal; + + [self _setupContext]; + + vertical = [moduleSettings objectForKey: @"DragHandleVertical"]; + horizontal = [moduleSettings objectForKey: @"DragHandleHorizontal"]; + dragHandles = [[NSArray alloc] initWithObjects: + vertical != nil ? vertical : @"", + horizontal ? horizontal : @"", + nil]; + + return [self responseWithStatus: 200 + andString: [dragHandles jsonRepresentation]]; +} + +- (WOResponse *) saveDragHandleStateAction +{ + WORequest *request; + NSString *dragHandle; + + [self _setupContext]; + request = [context request]; + + if ((dragHandle = [request formValueForKey: @"vertical"]) != nil) + [moduleSettings setObject: dragHandle + forKey: @"DragHandleVertical"]; + else if ((dragHandle = [request formValueForKey: @"horizontal"]) != nil) + [moduleSettings setObject: dragHandle + forKey: @"DragHandleHorizontal"]; + else + return [self responseWithStatus: 400]; + + [ud synchronize]; + + return [self responseWithStatus: 204]; +} + @end diff --git a/UI/Scheduler/product.plist b/UI/Scheduler/product.plist index 5b1c52486..18a20e1aa 100644 --- a/UI/Scheduler/product.plist +++ b/UI/Scheduler/product.plist @@ -40,6 +40,16 @@ protectedBy = "View"; pageName = "UIxCalMainView"; }; + dragHandlesState = { + protectedBy = ""; + pageName = "UIxCalMainView"; + actionName = "getDragHandlesState"; + }; + saveDragHandleState = { + protectedBy = "View"; + pageName = "UIxCalMainView"; + actionName = "saveDragHandleState"; + }; dateselector = { protectedBy = "View"; pageName = "UIxCalDateSelector"; diff --git a/UI/WebServerResources/ContactsUI.js b/UI/WebServerResources/ContactsUI.js index 03eae4a44..87c12eae9 100644 --- a/UI/WebServerResources/ContactsUI.js +++ b/UI/WebServerResources/ContactsUI.js @@ -763,8 +763,29 @@ function folderRenameCallback(http) { } } -function saveDragHandlesState() { - // Call from SOGoDragHandles.js +function getDragHandlesState() { + var urlstr = ApplicationBaseURL + "dragHandlesState"; + triggerAjaxRequest(urlstr, getDragHandlesStateCallback); +} + +function getDragHandlesStateCallback(http) { + if (http.status == 200) { + if (http.responseText.length > 0) { + // The response text is a JSON array + // of the top and right offsets. + var data = http.responseText.evalJSON(true); + if (data[0].length > 0) { + $("contactsListContent").setStyle({ height: data[0] }); + $("contactView").setStyle({ top: data[0] }); + $("rightDragHandle").setStyle({ top: data[0] }); + } + if (data[1].length > 0) { + $("contactFoldersList").setStyle({ width: data[1] }); + $("rightPanel").setStyle({ left: data[1] }); + $("dragHandle").setStyle({ left: data[1] }); + } + } + } } function onMenuSharing(event) { @@ -836,6 +857,7 @@ function configureSelectionButtons() { function initContacts(event) { if (!document.body.hasClassName("popup")) { configureAbToolbar(); + getDragHandlesState(); } else configureSelectionButtons(); diff --git a/UI/WebServerResources/MailerUI.js b/UI/WebServerResources/MailerUI.js index 83e7a0ff0..fb055ebc5 100644 --- a/UI/WebServerResources/MailerUI.js +++ b/UI/WebServerResources/MailerUI.js @@ -1496,15 +1496,18 @@ function getDragHandlesStateCallback(http) { if (http.status == 200) { if (http.responseText.length > 0) { // The response text is a JSON array - // of the right and top offsets. + // of the top and right offsets. var data = http.responseText.evalJSON(true); - - $("leftPanel").setStyle({ width: data[0] }); - $("rightPanel").setStyle({ left: data[0] }); - $("verticalDragHandle").setStyle({ left: data[0] }); - $("mailboxContent").setStyle({ height: data[1] }); - $("messageContent").setStyle({ top: data[1] }); - $("rightDragHandle").setStyle({ top: data[1] }); + if (data[0].length > 0) { + $("mailboxContent").setStyle({ height: data[0] }); + $("messageContent").setStyle({ top: data[0] }); + $("rightDragHandle").setStyle({ top: data[0] }); + } + if (data[1].length > 0) { + $("leftPanel").setStyle({ width: data[1] }); + $("rightPanel").setStyle({ left: data[1] }); + $("verticalDragHandle").setStyle({ left: data[1] }); + } } } } @@ -1532,26 +1535,6 @@ function getFoldersStateCallback(http) { } } -function saveDragHandlesState() { - // Call from SOGoDragHandles.js - var leftBlock = $("leftPanel"); - var upperBlock = $("mailboxContent"); - - if (leftBlock && upperBlock) { - var dragHandlesState = new Array(leftBlock.getStyle("width"), - upperBlock.getStyle("height")); - var urlstr = ApplicationBaseURL + "saveDragHandlesState" + "?dragHandles=" + dragHandlesState.toJSON(); - triggerAjaxRequest(urlstr, saveDragHandlesStateCallback); - } -} - -function saveDragHandlesStateCallback(http) { - if (http.readyState == 4 - && isHttpStatus204(http.status)) { - log ("drag handles state saved"); - } -} - function saveFoldersState() { if (mailAccounts.length > 0) { var foldersState = mailboxTree.getFoldersState(); diff --git a/UI/WebServerResources/SOGoDragHandles.js b/UI/WebServerResources/SOGoDragHandles.js index b81b281dc..54ac371b2 100644 --- a/UI/WebServerResources/SOGoDragHandles.js +++ b/UI/WebServerResources/SOGoDragHandles.js @@ -70,7 +70,9 @@ var SOGoDragHandlesInterface = { this.rightBlock.setStyle({ left: (this.origRight + deltaX) + 'px' }); this.leftBlock.setStyle({ width: (this.origLeft + deltaX) + 'px' }); } - } else if (this.dhType == 'vertical') { + this.saveDragHandleState(this.dhType, this.leftBlock.getStyle("width")); + } + else if (this.dhType == 'vertical') { var pointerY = Event.pointerY(event); if (pointerY <= this.topMargin) { this.lowerBlock.setStyle({ top: (this.topMargin - delta) + 'px' }); @@ -81,6 +83,7 @@ var SOGoDragHandlesInterface = { this.lowerBlock.setStyle({ top: (this.origLower + deltaY - delta) + 'px' }); this.upperBlock.setStyle({ height: (this.origUpper + deltaY - delta) + 'px' }); } + this.saveDragHandleState(this.dhType, this.upperBlock.getStyle("height")); } Event.stopObserving(document.body, "mouseup", this.stopHandleDraggingBound, true); Event.stopObserving(document.body, "mousemove", this.moveBound, true); @@ -88,8 +91,6 @@ var SOGoDragHandlesInterface = { document.body.setAttribute('style', ''); Event.stop(event); - - saveDragHandlesState(); }, move: function (event) { if (!this.dhType) @@ -135,6 +136,19 @@ var SOGoDragHandlesInterface = { this.lowerBlock.setStyle({ top: (uTop + topdelta) + 'px' }); } } + }, + saveDragHandleState: function (type, position) { + var urlstr = ApplicationBaseURL + "saveDragHandleState" + + "?" + type + "=" + position; + triggerAjaxRequest(urlstr, this.saveDragHandleStateCallback); + }, + + saveDragHandleStateCallback: function (http) { + if (isHttpStatus204(http.status)) { + log ("drag handle state saved"); + } + else if (http.readyState == 4) { + log ("can't save handle state"); + } } - }; diff --git a/UI/WebServerResources/SchedulerUI.js b/UI/WebServerResources/SchedulerUI.js index 510d0cb61..d9ab34890 100644 --- a/UI/WebServerResources/SchedulerUI.js +++ b/UI/WebServerResources/SchedulerUI.js @@ -1722,8 +1722,29 @@ function deletePersonalCalendarCallback(http) { log ("ajax problem 5: " + http.status); } -function saveDragHandlesState() { - // Call from SOGoDragHandles.js +function getDragHandlesState() { + var urlstr = ApplicationBaseURL + "dragHandlesState"; + triggerAjaxRequest(urlstr, getDragHandlesStateCallback); +} + +function getDragHandlesStateCallback(http) { + if (http.status == 200) { + if (http.responseText.length > 0) { + // The response text is a JSON array + // of the top and right offsets. + var data = http.responseText.evalJSON(true); + if (data[0].length > 0) { + $("eventsListView").setStyle({ height: data[0] }); + $("calendarView").setStyle({ top: data[0] }); + $("rightDragHandle").setStyle({ top: data[0] }); + } + if (data[1].length > 0) { + $("leftPanel").setStyle({ width: data[1] }); + $("rightPanel").setStyle({ left: data[1] }); + $("verticalDragHandle").setStyle({ left: data[1] }); + } + } + } } function configureLists() { @@ -1765,6 +1786,7 @@ function initCalendars() { sorting["ascending"] = true; if (!document.body.hasClassName("popup")) { + getDragHandlesState(); initDateSelectorEvents(); initCalendarSelector(); configureSearchField();