Merge pull request #46 from alexcloutier/feature/DragNDropCalendars
Improve drag'n'drop of events in multi-column viewpull/47/head
commit
11920f592c
|
@ -23,6 +23,7 @@
|
|||
#import <Foundation/NSCalendarDate.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSArray.h>
|
||||
|
||||
#import <NGObjWeb/NSException+HTTP.h>
|
||||
#import <NGObjWeb/SoPermissions.h>
|
||||
|
@ -52,19 +53,25 @@
|
|||
WOResponse *response;
|
||||
WORequest *rq;
|
||||
SOGoAppointmentObject *co;
|
||||
SoSecurityManager *sm;
|
||||
iCalEvent *event;
|
||||
NSCalendarDate *start, *newStart, *end, *newEnd;
|
||||
NSTimeInterval newDuration;
|
||||
SOGoUserDefaults *ud;
|
||||
NSString *daysDelta, *startDelta, *durationDelta;
|
||||
NSString *daysDelta, *startDelta, *durationDelta, *destionationCalendar;
|
||||
NSArray *calendarsID;
|
||||
NSTimeZone *tz;
|
||||
NSException *ex;
|
||||
SOGoAppointmentFolder *targetCalendar, *sourceCalendar;
|
||||
SOGoAppointmentFolders *folders;
|
||||
|
||||
rq = [context request];
|
||||
|
||||
daysDelta = [rq formValueForKey: @"days"];
|
||||
startDelta = [rq formValueForKey: @"start"];
|
||||
durationDelta = [rq formValueForKey: @"duration"];
|
||||
destionationCalendar = [rq formValueForKey: @"destination"];
|
||||
|
||||
if ([daysDelta length] > 0
|
||||
|| [startDelta length] > 0 || [durationDelta length] > 0)
|
||||
{
|
||||
|
@ -109,6 +116,26 @@
|
|||
|
||||
[event setLastModified: [NSCalendarDate calendarDate]];
|
||||
ex = [co saveComponent: event];
|
||||
// This condition will be executed only if the event is moved from a calendar to another. If destionationCalendar == 0; there is no calendar change
|
||||
if (![destionationCalendar isEqualToString:@"0"])
|
||||
{
|
||||
folders = [[self->context activeUser] calendarsFolderInContext: self->context];
|
||||
sourceCalendar = [co container];
|
||||
targetCalendar = [folders lookupName:[destionationCalendar stringValue] inContext: self->context acquire: 0];
|
||||
// The event was moved to a different calendar.
|
||||
sm = [SoSecurityManager sharedSecurityManager];
|
||||
if (![sm validatePermission: SoPerm_DeleteObjects
|
||||
onObject: sourceCalendar
|
||||
inContext: context])
|
||||
{
|
||||
if (![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
|
||||
onObject: targetCalendar
|
||||
inContext: context])
|
||||
ex = [co moveToFolder: targetCalendar];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (ex)
|
||||
{
|
||||
NSDictionary *jsonResponse;
|
||||
|
|
|
@ -191,7 +191,7 @@
|
|||
NSMutableDictionary *calendar;
|
||||
unsigned int count, foldersCount;
|
||||
NSString *folderName, *fDisplayName;
|
||||
NSNumber *isActive;
|
||||
BOOL *isActive;
|
||||
|
||||
co = [self clientObject];
|
||||
folders = [co subFolders];
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<div class="days">
|
||||
<var:foreach list="calendarsToDisplay" item="currentCalendar">
|
||||
<var:foreach list="daysToDisplay" item="currentTableDay">
|
||||
<div var:class="dayClasses" var:day="currentTableDay.shortDateString" var:id="currentAllDayId" hour="allday"><!-- space --></div>
|
||||
<div var:class="dayClasses" var:day="currentTableDay.shortDateString" var:id="currentAllDayId" var:calendar="currentCalendar.folder" hour="allday"><!-- space --></div>
|
||||
</var:foreach>
|
||||
</var:foreach>
|
||||
</div>
|
||||
|
@ -75,7 +75,7 @@
|
|||
<var:if condition="isMultiColumnView">
|
||||
<var:foreach list="calendarsToDisplay" item="currentCalendar">
|
||||
<var:foreach list="daysToDisplay" item="currentTableDay">
|
||||
<div var:class="dayClasses" var:id="currentDayId" var:day-number="currentDayNumber" var:day="currentTableDay.shortDateString">
|
||||
<div var:class="dayClasses" var:id="currentDayId" var:day-number="currentDayNumber" var:calendar="currentCalendar.folder" var:day="currentTableDay.shortDateString">
|
||||
<div class="hourCells">
|
||||
<var:foreach list="hoursToDisplay" item="currentTableHour">
|
||||
<div var:class="clickableHourCellClass" var:day="currentTableDay.shortDateString" var:hour="currentAppointmentHour">
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
className="UIxPageFrame"
|
||||
const:userDefaultsKeys="SOGoCalendarCategoriesColors,SOGoDefaultCalendar"
|
||||
const:userSettingsKeys="Calendar,ShowCompletedTasks"
|
||||
const:jsFiles="SchedulerUIDnD.js"
|
||||
const:jsFiles="SchedulerUIDnD.js,jquery-ui.js"
|
||||
title="title">
|
||||
<script type="text/javascript">
|
||||
var firstDayOfWeek = <var:string value="firstDayOfWeek"/>;
|
||||
|
@ -34,6 +34,7 @@
|
|||
<div class="preload" style="visibility: hidden;">
|
||||
<img rsrc:src="event-gradient.png"/>
|
||||
</div>
|
||||
<img rsrc:src="event7.png" id="DnDLeftPanelImage" style="visibility: hidden;"/>
|
||||
<div class="menu" id="monthListMenu">
|
||||
<ul>
|
||||
<var:foreach list="monthMenuItems" item="monthMenuItem"
|
||||
|
|
|
@ -1297,14 +1297,12 @@ DIV#daysView DIV.event.lasts96
|
|||
DIV.event > DIV.eventInside
|
||||
{ position: absolute;
|
||||
overflow: hidden;
|
||||
width:100%;
|
||||
top: 0px;
|
||||
bottom: 0px;
|
||||
-webkit-border-radius: 2px;
|
||||
border-radius: 2px; }
|
||||
|
||||
DIV.eventInside {
|
||||
width:100%;
|
||||
}
|
||||
border-radius: 2px;
|
||||
cursor:move; }
|
||||
|
||||
DIV.eventInside SPAN.location
|
||||
{ font-size: smaller; }
|
||||
|
@ -1442,7 +1440,8 @@ DIV.event.draggable:hover DIV.rightDragGrip
|
|||
#daysView DIV.eventDragGhost > DIV.eventInside
|
||||
{ padding: 0px;
|
||||
border-left: 1px solid #555;
|
||||
border-right: 1px solid #555; }
|
||||
border-right: 1px solid #555;
|
||||
}
|
||||
|
||||
#daysView DIV.eventDragGhost.startGhost > DIV.eventInside
|
||||
{ border-top: 1px solid #555; }
|
||||
|
@ -1536,6 +1535,24 @@ DIV#calendarContent .alert-box span {
|
|||
border:1px solid #8ed9f6;
|
||||
}
|
||||
|
||||
DIV#dragDropVisual
|
||||
{
|
||||
background-image: url(event7.png);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 4px 2px;
|
||||
width: 5px;
|
||||
height: 20px;
|
||||
padding-left: 24px;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
#DnDLeftPanelImage
|
||||
{
|
||||
position:absolute;
|
||||
z-index:1;
|
||||
left:0;
|
||||
top:0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ var preventAutoScroll = false;
|
|||
var userStates = [ "needs-action", "accepted", "declined", "tentative", "delegated" ];
|
||||
|
||||
var calendarHeaderAdjusted = false;
|
||||
var recurrenceBool = false;
|
||||
|
||||
var categoriesStyles = new Hash();
|
||||
var categoriesStyleSheet = null;
|
||||
|
@ -57,9 +58,6 @@ function printView() {
|
|||
|
||||
function newEvent(type, day, hour, duration) {
|
||||
var folder = null;
|
||||
/* if (currentView == "multicolumndayview") {
|
||||
Need to find where the click register is saved
|
||||
}*/
|
||||
if (UserDefaults['SOGoDefaultCalendar'] == 'personal')
|
||||
folder = $("calendarList").down("li");
|
||||
else if (UserDefaults['SOGoDefaultCalendar'] == 'first') {
|
||||
|
@ -123,22 +121,31 @@ function newEventFromDragging(controller, day, coordinates) {
|
|||
newEvent("event", day, startHm, lengthHm);
|
||||
}
|
||||
|
||||
function updateEventFromDragging(controller, eventCells, eventDelta) {
|
||||
if (eventDelta.dayNumber || eventDelta.start || eventDelta.duration) {
|
||||
var params = ("days=" + eventDelta.dayNumber
|
||||
function updateEventFromDragging(controller, eventCells, eventDelta, calendarID) {
|
||||
if (eventDelta.dayNumber || eventDelta.start || eventDelta.duration || calendarID != 0) {
|
||||
if (calendarID != 0)
|
||||
var params = ("destination=" + calendarID[1]
|
||||
+ "&days=" + 0
|
||||
+ "&start=" + eventDelta.start * 15
|
||||
+ "&duration=" + eventDelta.duration * 15);
|
||||
else
|
||||
var params = ("destination=" + 0
|
||||
+ "&days=" + eventDelta.dayNumber
|
||||
+ "&start=" + eventDelta.start * 15
|
||||
+ "&duration=" + eventDelta.duration * 15);
|
||||
// log("eventCells: " + eventCells.length);
|
||||
var eventCell = eventCells[0];
|
||||
// log(" time: " + eventCell.recurrenceTime);
|
||||
// log(" exception: " + eventCell.isException);
|
||||
|
||||
recurrenceBool = false;
|
||||
if (calendarID == 0) {
|
||||
recurrenceBool = true;
|
||||
}
|
||||
if (eventCell.recurrenceTime && !eventCell.isException)
|
||||
_editRecurrenceDialog(eventCell, "confirmAdjustment", params);
|
||||
else {
|
||||
var urlstr = (ApplicationBaseURL
|
||||
+ "/" + eventCell.calendar + "/" + eventCell.cname);
|
||||
if (eventCell.recurrenceTime)
|
||||
var urlstr = (ApplicationBaseURL + "/" + eventCell.calendar + "/" + eventCell.cname);
|
||||
if (eventCell.recurrenceTime && recurrenceBool)
|
||||
urlstr += "/occurence" + eventCell.recurrenceTime;
|
||||
urlstr += ("/adjust?" + params);
|
||||
// log(" urlstr: " + urlstr);
|
||||
|
@ -149,7 +156,7 @@ function updateEventFromDragging(controller, eventCells, eventDelta) {
|
|||
|
||||
function performEventAdjustment(folder, event, recurrence, params) {
|
||||
var urlstr = ApplicationBaseURL + "/" + folder + "/" + event;
|
||||
if (recurrence)
|
||||
if (recurrence && recurrenceBool)
|
||||
urlstr += "/" + recurrence;
|
||||
urlstr += "/adjust" + generateQueryString(params);
|
||||
triggerAjaxRequest(urlstr, updateEventFromDraggingCallback);
|
||||
|
@ -1098,6 +1105,7 @@ function eventsListCallback(http) {
|
|||
}
|
||||
}
|
||||
}
|
||||
configureDraggables();
|
||||
}
|
||||
else
|
||||
log ("eventsListCallback Ajax error");
|
||||
|
@ -1109,6 +1117,7 @@ function activeTasksCallback(http) {
|
|||
document.activeTasksAjaxRequest = null;
|
||||
var data = http.responseText.evalJSON(true);
|
||||
var list = $("calendarList");
|
||||
<<<<<<< HEAD
|
||||
|
||||
var items = list.childNodesWithTag("li");
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
|
@ -1127,6 +1136,20 @@ function activeTasksCallback(http) {
|
|||
}
|
||||
if (number > 0) {
|
||||
activeTasks.innerHTML = number;
|
||||
=======
|
||||
|
||||
var items = list.childNodesWithTag("li");
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var id = items[i].getAttribute("id").substr(1);
|
||||
var number = data[id];
|
||||
var input = items[i].childNodesWithTag("input")[0];
|
||||
var activeTasks = items[i].childNodesWithTag("span")[0];
|
||||
if (number == "0") {
|
||||
activeTasks.innerHTML = "";
|
||||
}
|
||||
else {
|
||||
activeTasks.innerHTML = "(" + number + ")";
|
||||
>>>>>>> added event7.png and adjust javascript indentation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1863,10 +1886,10 @@ function newBaseEventDIV(eventRep, event, eventText) {
|
|||
eventCell.writeAttribute('day', startDate.getDayString());
|
||||
eventCell.writeAttribute('hour', event[8]? 'allday' : startDate.getHourString());
|
||||
}
|
||||
// if (event[8] == 1)
|
||||
// eventCell.addClassName("private");
|
||||
// else if (event[8] == 2)
|
||||
// eventCell.addClassName("confidential");
|
||||
// if (event[8] == 1)
|
||||
// eventCell.addClassName("private");
|
||||
// else if (event[8] == 2)
|
||||
// eventCell.addClassName("confidential");
|
||||
if (eventRep.recurrenceTime)
|
||||
eventCell.recurrenceTime = eventRep.recurrenceTime;
|
||||
//eventCell.owner = event[12];
|
||||
|
@ -1875,8 +1898,8 @@ function newBaseEventDIV(eventRep, event, eventText) {
|
|||
eventCell.erasable = event[19] || IsSuperUser;
|
||||
eventCell.ownerIsOrganizer = event[20];
|
||||
eventCell.addClassName("event");
|
||||
// if (event[14] > 0)
|
||||
// eventCell.addClassName("alarm");
|
||||
// if (event[14] > 0)
|
||||
// eventCell.addClassName("alarm");
|
||||
|
||||
var innerDiv = createElement("div");
|
||||
eventCell.appendChild(innerDiv);
|
||||
|
@ -2293,6 +2316,22 @@ function calendarDisplayCallback(http) {
|
|||
if (currentView == "monthview")
|
||||
days[i].observe("scroll", onBodyClickHandler);
|
||||
}
|
||||
else if (currentView == "multicolumndayview") {
|
||||
var calendarHeader = $("calendarHeader");
|
||||
var headerCalendarsLabels = calendarHeader.select("DIV.calendarLabels DIV.calendarsToDisplay");
|
||||
var headerDays = calendarHeader.select("DIV.days DIV.day");
|
||||
for (var i = 0; i < days.length; i++) {
|
||||
headerDays[i].hour = "allday";
|
||||
headerCalendarsLabels[i].observe("mousedown", listRowMouseDownHandler);
|
||||
headerDays[i].observe("click", onCalendarSelectDay);
|
||||
headerDays[i].observe("dblclick", onClickableCellsDblClick);
|
||||
days[i].observe("click", onCalendarSelectDay);
|
||||
|
||||
var clickableCells = days[i].select("DIV.clickableHourCell");
|
||||
for (var j = 0; j < clickableCells.length; j++)
|
||||
clickableCells[j].observe("dblclick", onClickableCellsDblClick);
|
||||
}
|
||||
}
|
||||
else {
|
||||
var calendarHeader = $("calendarHeader");
|
||||
var headerDaysLabels = calendarHeader.select("DIV.dayLabels DIV.day");
|
||||
|
@ -2706,6 +2745,19 @@ function onCalendarSelectDay(event) {
|
|||
|
||||
var target = Event.findElement(event);
|
||||
var div = target.up('div');
|
||||
|
||||
// Select the calendar associated with the day clicked
|
||||
if (currentView == "multicolumndayview") {
|
||||
if (target.getAttribute("calendar"))
|
||||
var calendar = "[id='/" + target.getAttribute("calendar") + "']";
|
||||
else
|
||||
var calendar = "[id='/" + target.up("[calendar]").getAttribute("calendar") + "']";
|
||||
var list = $("calendarList");
|
||||
var selectedCalendar = list.down(calendar);
|
||||
|
||||
onRowClick(event, selectedCalendar);
|
||||
}
|
||||
|
||||
if (div && !div.hasClassName('event') && !div.hasClassName('eventInside') && !div.hasClassName('text') && !div.hasClassName('gradient')) {
|
||||
// Target is not an event -- unselect all events.
|
||||
listOfSelection = $("eventsList");
|
||||
|
@ -2863,6 +2915,7 @@ function updateCalendarsList(method) {
|
|||
var url = URLForFolderID(folderID) + "/canAccessContent";
|
||||
triggerAjaxRequest(url, calendarEntryCallback, folderID);
|
||||
}
|
||||
configureDroppables();
|
||||
}
|
||||
|
||||
//function validateBrowseURL(input) {
|
||||
|
@ -2957,6 +3010,7 @@ function onTasksListMenuPrepareVisibility() {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getMenus() {
|
||||
var menus = {};
|
||||
|
||||
|
@ -3030,7 +3084,6 @@ function onMenuRawTask(event) {
|
|||
openGenericWindow.delay(0.1, url);
|
||||
}
|
||||
|
||||
|
||||
function onMenuSharing(event) {
|
||||
if ($(this).hasClassName("disabled"))
|
||||
return;
|
||||
|
@ -3064,6 +3117,102 @@ function onMenuAllDayView(event) {
|
|||
popupMenu(event, 'allDayViewMenu', getTarget(event));
|
||||
}
|
||||
|
||||
function configureDraggables() {
|
||||
if ($("eventsList")) {
|
||||
var rows = jQuery("tr.eventRow");
|
||||
try { rows.draggable("destroy"); } catch (e) {}
|
||||
rows.draggable({
|
||||
helper: function (event) { return '<div id="dragDropVisual"></div>'; },
|
||||
start: startDragging,
|
||||
drag: whileDragging,
|
||||
stop: stopDragging,
|
||||
appendTo: 'body',
|
||||
cursorAt: { right: 25 },
|
||||
scroll: false,
|
||||
distance: 4,
|
||||
zIndex: 20
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function configureDroppables() {
|
||||
jQuery("#calendarList li").droppable({ hoverClass: 'genericHoverClass',
|
||||
drop: dropAction });
|
||||
}
|
||||
|
||||
function startDragging(event, ui) {
|
||||
var row = event.target;
|
||||
var handle = ui.helper;
|
||||
var events = $('eventsList').getSelectedRowsId();
|
||||
var count = events.length;
|
||||
|
||||
if (count == 0 || events.indexOf(row.id) < 0) {
|
||||
onRowClick(event, $(row.id));
|
||||
events = $("eventsList").getSelectedRowsId();
|
||||
count = events.length;
|
||||
}
|
||||
handle.html(count);
|
||||
|
||||
handle.show();
|
||||
}
|
||||
|
||||
function whileDragging(event, ui) {
|
||||
if (event)
|
||||
var handle = ui.helper;
|
||||
}
|
||||
|
||||
function stopDragging(event, ui) {
|
||||
var handle = ui.helper;
|
||||
handle.hide();
|
||||
}
|
||||
|
||||
function dropAction(event, ui) {
|
||||
|
||||
var action = "adjust";
|
||||
refreshEventsAndDisplay();
|
||||
dropSelectedEvents(action, this.id.substr(1));
|
||||
}
|
||||
|
||||
function dropSelectedEvents(action, toId) {
|
||||
var selectedCalendars = $("calendarList").getElementsByTagName("li");
|
||||
if (selectedCalendars.length > 0) {
|
||||
var eventIds = $('eventsList').getSelectedRowsId();
|
||||
for (var i = 0; i < eventIds.length; i++) {
|
||||
// Find the event ID (.ics)
|
||||
if (!eventIds[i].endsWith("ics")) {
|
||||
// If it is a repeated event, substract the occurence part
|
||||
if (eventIds[i].indexOf(".ics")) {
|
||||
var x = eventIds[i].indexOf(".ics") + 4;
|
||||
eventIds[i] = eventIds[i].substr(0,x);
|
||||
}
|
||||
else {
|
||||
log("Can't find the event(.ics) on the item dragged : " + eventIds[i]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Distinction between personal calendar and a calendar with a reference ID (ex: 4535-7545-B-5D3J)
|
||||
if (eventIds[i].search(toId+"-") == -1) {
|
||||
var x = eventIds[i].indexOf('-');
|
||||
if (eventIds[i].indexOf('-') == 4) {
|
||||
var regEx = new RegExp(/\w+\-\w+\-\w+\-\w+/);
|
||||
var fromId = regEx.exec(eventIds[i]);
|
||||
var eventICS = eventIds[i].substr(fromId[0].length + 1);
|
||||
}
|
||||
else {
|
||||
var regEx = new RegExp(/\w+/);
|
||||
var fromId = regEx.exec(eventIds[i]);
|
||||
var eventICS = eventIds[i].substr(fromId[0].length + 1);
|
||||
}
|
||||
var destinationCalendar = "destination=" + toId;
|
||||
var params = destinationCalendar + "&days=0&start=0&duration=0";
|
||||
var urlstr = ApplicationBaseURL + "/" + fromId + "/" + eventICS + "/adjust?" + params;
|
||||
|
||||
triggerAjaxRequest(urlstr, updateEventFromDraggingCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function configureDragHandles() {
|
||||
var handle = $("verticalDragHandle");
|
||||
if (handle) {
|
||||
|
@ -3094,8 +3243,15 @@ function initCalendarSelector() {
|
|||
var items = list.childNodesWithTag("li");
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var input = items[i].childNodesWithTag("input")[0];
|
||||
var activeTasks = items[i].childNodesWithTag("span")[1];
|
||||
var activeTasks = items[i].childNodesWithTag("span")[0];
|
||||
$(input).observe("click", clickEventWrapper(updateCalendarStatus));
|
||||
if (activeTasks.textContent == "0") {
|
||||
activeTasks.innerHTML = "";
|
||||
}
|
||||
else {
|
||||
activeTasks.innerHTML = "(" + activeTasks.innerText + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var links = $("calendarSelectorButtons").childNodesWithTag("a");
|
||||
|
@ -3344,12 +3500,6 @@ function appendCalendar(folderName, folderPath) {
|
|||
|
||||
var colorBox = document.createElement("div");
|
||||
colorBox.appendChild(document.createTextNode("\u00a0"));
|
||||
li.appendChild(colorBox);
|
||||
|
||||
var displayName = document.createElement("span");
|
||||
displayName.appendChild(document.createTextNode(folderName));
|
||||
li.appendChild(displayName);
|
||||
|
||||
$(colorBox).addClassName("colorBox");
|
||||
$(colorBox).addClassName('calendarFolder' + folderPath.substr(1));
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ var SOGoEventDragDayLength = 24 * 4; /* quarters */
|
|||
var SOGoEventDragHandleSize = 8; /* handles for dragging mode */
|
||||
var SOGoEventDragHorizontalOffset = 3;
|
||||
var SOGoEventDragVerticalOffset = 3;
|
||||
var calendarID = [], activeCalendars = [];
|
||||
|
||||
/* singleton */
|
||||
var _sogoEventDragUtilities = null;
|
||||
|
@ -218,10 +219,7 @@ SOGoEventDragEventCoordinates.prototype = {
|
|||
|
||||
initFromEventCellMultiDay: function(eventCell) {
|
||||
var classNames = eventCell.className.split(" ");
|
||||
for (var i = 0;
|
||||
(this.start == -1 || this.duration == -1)
|
||||
&& i < classNames.length;
|
||||
i++) {
|
||||
for (var i = 0; (this.start == -1 || this.duration == -1) && i < classNames.length; i++) {
|
||||
var className = classNames[i];
|
||||
if (className.startsWith("starts")) {
|
||||
this.start = parseInt(className.substr(6));
|
||||
|
@ -231,7 +229,13 @@ SOGoEventDragEventCoordinates.prototype = {
|
|||
}
|
||||
}
|
||||
var dayNumber = -1;
|
||||
|
||||
var dayNode = eventCell.parentNode.parentNode;
|
||||
if (currentView == "multicolumndayview") {
|
||||
calendarID[0] = dayNode.getAttribute("calendar");
|
||||
var dayNumber = this._updateMulticolumnViewDayNumber(calendarID);
|
||||
}
|
||||
else {
|
||||
var classNames = dayNode.className.split(" ");
|
||||
for (var i = 0; dayNumber == -1 && i < classNames.length; i++) {
|
||||
var className = classNames[i];
|
||||
|
@ -239,6 +243,7 @@ SOGoEventDragEventCoordinates.prototype = {
|
|||
dayNumber = parseInt(className.substr(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
this.dayNumber = dayNumber;
|
||||
},
|
||||
initFromEventCellMultiDayAllDay: function(eventCell) {
|
||||
|
@ -246,6 +251,11 @@ SOGoEventDragEventCoordinates.prototype = {
|
|||
this.duration = SOGoEventDragDayLength;
|
||||
|
||||
var dayNode = eventCell.parentNode;
|
||||
if (currentView == "multicolumndayview") {
|
||||
calendarID[0] = dayNode.getAttribute("calendar");
|
||||
var dayNumber = this._updateMulticolumnViewDayNumber(calendarID);
|
||||
}
|
||||
else {
|
||||
var classNames = dayNode.className.split(" ");
|
||||
var dayNumber = -1;
|
||||
for (var i = 0; dayNumber == -1 && i < classNames.length; i++) {
|
||||
|
@ -254,6 +264,7 @@ SOGoEventDragEventCoordinates.prototype = {
|
|||
dayNumber = parseInt(className.substr(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
this.dayNumber = dayNumber;
|
||||
},
|
||||
initFromEventCellMonthly: function(eventCell) {
|
||||
|
@ -322,6 +333,19 @@ SOGoEventDragEventCoordinates.prototype = {
|
|||
return "" + hours + ":" + mins;
|
||||
},
|
||||
|
||||
_updateMulticolumnViewDayNumber: function(calendarID) {
|
||||
var calendarList = $("calendarList").getElementsByTagName("li");
|
||||
for (var j = 0; j < calendarList.length ; j++) {
|
||||
if ($("calendarList").getElementsByTagName("li")[j].down().checked)
|
||||
activeCalendars.push($("calendarList").getElementsByTagName("li")[j].getAttribute("id").substr(1));
|
||||
}
|
||||
for (var k = 0; k < activeCalendars.length; k++) {
|
||||
if (activeCalendars[k] == calendarID[0]) {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getStartTime: function() {
|
||||
return this._quartersToHM(this.start);
|
||||
},
|
||||
|
@ -504,8 +528,7 @@ SOGoEventDragGhostController.prototype = {
|
|||
this.currentPointerCoordinates = newCoordinates;
|
||||
if (this.originalPointerCoordinates) {
|
||||
if (!newCoordinates)
|
||||
this.currentPointerCoordinates
|
||||
= this.originalPointerCoordinates.clone();
|
||||
this.currentPointerCoordinates = this.originalPointerCoordinates.clone();
|
||||
this._updateCoordinates();
|
||||
if (this.ghosts) {
|
||||
this._updateGhosts();
|
||||
|
@ -516,10 +539,29 @@ SOGoEventDragGhostController.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
_updateMulticolumnViewDayNumber_SEDGC: function() {
|
||||
var calendarID_SEDGC = this.folderClass.substr(14);
|
||||
var calendarList = $("calendarList").getElementsByTagName("li");
|
||||
activeCalendars = [];
|
||||
for (var j = 0; j < calendarList.length ; j++) {
|
||||
if ($("calendarList").getElementsByTagName("li")[j].down().checked)
|
||||
activeCalendars.push($("calendarList").getElementsByTagName("li")[j].getAttribute("id").substr(1));
|
||||
}
|
||||
for (var k = 0; k < activeCalendars.length; k++) {
|
||||
if (activeCalendars[k] == calendarID_SEDGC) {
|
||||
this.currentCoordinates.dayNumber = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_updateCoordinates: function SEDGC__updateCoordinates() {
|
||||
var delta = this.currentPointerCoordinates
|
||||
.getDelta(this.originalPointerCoordinates);
|
||||
var deltaQuarters = delta.x * SOGoEventDragDayLength + delta.y;
|
||||
if (currentView == "multicolumndayview")
|
||||
this._updateMulticolumnViewDayNumber_SEDGC();
|
||||
else
|
||||
this.currentCoordinates.dayNumber = this.originalCoordinates.dayNumber;
|
||||
|
||||
// log("dragMode: " + this.dragMode);
|
||||
|
@ -565,6 +607,10 @@ SOGoEventDragGhostController.prototype = {
|
|||
var deltaDays = Math.floor(this.currentCoordinates.start
|
||||
/ SOGoEventDragDayLength);
|
||||
this.currentCoordinates.start -= deltaDays * SOGoEventDragDayLength;
|
||||
|
||||
// This dayNumber needs to be updated with the calendar number.
|
||||
if (currentView == "multicolumndayview")
|
||||
this._updateMulticolumnViewDayNumber_SEDGC();
|
||||
this.currentCoordinates.dayNumber += deltaDays;
|
||||
}
|
||||
},
|
||||
|
@ -925,6 +971,45 @@ SOGoScrollController.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
function SOGoEventDragLeftPanelController() {
|
||||
}
|
||||
|
||||
SOGoEventDragLeftPanelController.prototype = {
|
||||
updateLeftPanelVisual : null,
|
||||
dropCalendar : null,
|
||||
DnDLeftPanelImage : $("DnDLeftPanelImage"),
|
||||
|
||||
setLeftPanelVisual: function SEDLPC_setLeftPanelVisual() {
|
||||
var that = this;
|
||||
this.updateLeftPanelVisual = $("leftPanel").on("mousemove", function(e){
|
||||
that.DnDLeftPanelImage.style.left = e.pageX + "px";
|
||||
that.DnDLeftPanelImage.style.top = e.pageY + "px";
|
||||
});
|
||||
this.updateLeftPanelVisual.stop();
|
||||
},
|
||||
|
||||
updateFromPointerHandler: function SEDLPC_updateFromPointerHandler() {
|
||||
// Highlight the calendar hover
|
||||
$$('#calendarList li').each(function(e) {
|
||||
e.removeClassName('genericHoverClass');
|
||||
});
|
||||
var hoverCalendar = $(event).findElement('#calendarList li');
|
||||
if (hoverCalendar)
|
||||
hoverCalendar.addClassName('genericHoverClass');
|
||||
this.dropCalendar = hoverCalendar;
|
||||
},
|
||||
|
||||
startEvent: function SEDLPC_startEvent() {
|
||||
this.DnDLeftPanelImage.style.visibility = 'visible';
|
||||
this.updateLeftPanelVisual.start();
|
||||
},
|
||||
|
||||
stopEvent: function SEDLPC_stopEvent() {
|
||||
this.DnDLeftPanelImage.style.visibility = 'hidden';
|
||||
this.updateLeftPanelVisual.stop();
|
||||
}
|
||||
}
|
||||
|
||||
function SOGoEventDragController() {
|
||||
}
|
||||
|
||||
|
@ -939,6 +1024,7 @@ SOGoEventDragController.prototype = {
|
|||
draggingModeAreas: null,
|
||||
|
||||
ghostController: null,
|
||||
leftPanelController: null,
|
||||
|
||||
hasSelected: false,
|
||||
dragHasStarted: false,
|
||||
|
@ -959,6 +1045,7 @@ SOGoEventDragController.prototype = {
|
|||
this.eventCells = eventCells;
|
||||
|
||||
this.ghostController = new SOGoEventDragGhostController();
|
||||
this.leftPanelController = new SOGoEventDragLeftPanelController();
|
||||
this._determineEventInvitation(eventCells[0]);
|
||||
this._determineEventType(eventCells[0]);
|
||||
this._prepareEventType();
|
||||
|
@ -966,6 +1053,7 @@ SOGoEventDragController.prototype = {
|
|||
this.ghostController.setTitle(this.title);
|
||||
this.ghostController.setLocation(this.location);
|
||||
this.ghostController.setFolderClass(this.folderClass);
|
||||
this.leftPanelController.setLeftPanelVisual();
|
||||
|
||||
this.onDragStartBound = this.onDragStart.bindAsEventListener(this);
|
||||
for (var i = 0; i < eventCells.length; i++) {
|
||||
|
@ -1036,8 +1124,16 @@ SOGoEventDragController.prototype = {
|
|||
this.ghostController.initWithCoordinates(coordinates);
|
||||
|
||||
if (!this.eventCells) {
|
||||
if (currentView == "multicolumndayview") {
|
||||
if (target.getAttribute("calendar"))
|
||||
var folderID = target.getAttribute("calendar");
|
||||
else
|
||||
var folderID = target.up("[calendar]").getAttribute("calendar");
|
||||
}
|
||||
else {
|
||||
var folder = getSelectedFolder();
|
||||
var folderID = folder.readAttribute("id").substr(1);
|
||||
}
|
||||
this.ghostController.setFolderClass("calendarFolder" + folderID);
|
||||
}
|
||||
this.ghostController.setDragMode(this._determineDragMode());
|
||||
|
@ -1296,6 +1392,7 @@ SOGoEventDragController.prototype = {
|
|||
Event.stopObserving(document.body, "mousemove", this.onDragModeBound);
|
||||
this.onDragStopBound = null;
|
||||
this.onDragModeBound = null;
|
||||
this.leftPanelController.stopEvent();
|
||||
|
||||
var utilities = SOGoEventDragUtilities();
|
||||
if (this.dragHasStarted) {
|
||||
|
@ -1311,7 +1408,25 @@ SOGoEventDragController.prototype = {
|
|||
.currentCoordinates
|
||||
.getDelta(this.ghostController
|
||||
.originalCoordinates);
|
||||
this.updateDropCallback(this, this.eventCells, delta);
|
||||
|
||||
if (this.leftPanelController.dropCalendar != null) {
|
||||
$$('#calendarList li').each(function(e) {
|
||||
e.removeClassName('genericHoverClass');
|
||||
});
|
||||
calendarID[0] = this.folderClass.substr(14);
|
||||
calendarID[1] = this.leftPanelController.dropCalendar.getAttribute("id").substr(1);
|
||||
delta.start = 0;
|
||||
if (calendarID[0] != calendarID[1])
|
||||
this.updateDropCallback(this, this.eventCells, delta, calendarID);
|
||||
}
|
||||
else if (currentView == "multicolumndayview" && delta.dayNumber != 0) {
|
||||
var position = activeCalendars.indexOf(calendarID[0]);
|
||||
position += delta.dayNumber;
|
||||
calendarID[1] = activeCalendars[position];
|
||||
this.updateDropCallback(this, this.eventCells, delta, calendarID);
|
||||
}
|
||||
else
|
||||
this.updateDropCallback(this, this.eventCells, delta, 0);
|
||||
} else {
|
||||
var eventContainerNodes = utilities.getEventContainerNodes();
|
||||
var dayNode = eventContainerNodes[this.ghostController
|
||||
|
@ -1345,8 +1460,23 @@ SOGoEventDragController.prototype = {
|
|||
this.scrollController.updateFromPointerHandler();
|
||||
|
||||
if (this.dragHasStarted) {
|
||||
var newCoordinates = this.ghostController.pointerHandler.getEventViewCoordinates();
|
||||
if (newCoordinates == null && this.leftPanelController != null) {
|
||||
if (this.ghostController.ghosts) {
|
||||
this.ghostController.hideGhosts();
|
||||
this.leftPanelController.startEvent();
|
||||
}
|
||||
this.leftPanelController.updateFromPointerHandler();
|
||||
}
|
||||
else {
|
||||
if (this.ghostController.ghosts == null) {
|
||||
this.ghostController.showGhosts();
|
||||
this.leftPanelController.stopEvent();
|
||||
}
|
||||
this.ghostController.updateFromPointerHandler();
|
||||
} else {
|
||||
}
|
||||
}
|
||||
else {
|
||||
var distance = this.pointerHandler.getDistance();
|
||||
if (distance > 3) {
|
||||
$("eventDialog").hide();
|
||||
|
@ -1361,7 +1491,6 @@ SOGoEventDragController.prototype = {
|
|||
this.ghostController.updateFromPointerHandler();
|
||||
}
|
||||
}
|
||||
|
||||
Event.stop(event);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -11,10 +11,9 @@ function onThisButtonClick(event) {
|
|||
else if (action == 'delete')
|
||||
window.opener.performEventDeletion(calendarFolder, componentName,
|
||||
recurrenceName);
|
||||
else if (action == 'adjust') {
|
||||
else if (action == 'adjust')
|
||||
window.opener.performEventAdjustment(calendarFolder, componentName,
|
||||
recurrenceName, queryParameters);
|
||||
}
|
||||
else
|
||||
window.alert("Invalid action: " + action);
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 413 B |
Loading…
Reference in New Issue