2010-08-02 22:42:53 +02:00
|
|
|
/* bind method: attachToEventCells(cells), attachToDayNode(dayNode)
|
|
|
|
* callback method: updateDropCallback(this, eventCells, delta),
|
|
|
|
createDropCallback(this, dayDate, currentCoordinates);
|
|
|
|
*/
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
|
|
|
|
var SOGoEventDragDayLength = 24 * 4; /* quarters */
|
|
|
|
var SOGoEventDragHandleSize = 8; /* handles for dragging mode */
|
|
|
|
var SOGoEventDragHorizontalOffset = 3;
|
|
|
|
var SOGoEventDragVerticalOffset = 3;
|
2014-07-15 23:29:39 +02:00
|
|
|
var calendarID = [], activeCalendars = [];
|
2010-02-11 03:36:43 +01:00
|
|
|
|
|
|
|
/* singleton */
|
|
|
|
var _sogoEventDragUtilities = null;
|
|
|
|
function SOGoEventDragUtilities() {
|
|
|
|
if (!_sogoEventDragUtilities)
|
|
|
|
_sogoEventDragUtilities = new _SOGoEventDragUtilities();
|
|
|
|
|
|
|
|
return _sogoEventDragUtilities;
|
|
|
|
}
|
|
|
|
|
|
|
|
function _SOGoEventDragUtilities() {
|
|
|
|
}
|
|
|
|
|
|
|
|
_SOGoEventDragUtilities.prototype = {
|
2010-02-11 20:48:09 +01:00
|
|
|
eventType: null,
|
|
|
|
eventContainerNodes: null,
|
|
|
|
_prepareEventContainerNodes: null,
|
2010-02-11 03:36:43 +01:00
|
|
|
quarterHeight: -1,
|
|
|
|
dayWidth: -1,
|
2010-02-11 20:48:09 +01:00
|
|
|
dayHeight: -1,
|
2010-02-11 03:36:43 +01:00
|
|
|
daysOffset: -1,
|
|
|
|
eventsViewNode: null,
|
|
|
|
eventsViewNodeCumulativeCoordinates: null,
|
|
|
|
|
|
|
|
reset: function() {
|
2010-02-11 20:48:09 +01:00
|
|
|
this.eventContainerNodes = null;
|
|
|
|
this._prepareEventContainerNodes = null;
|
2010-02-11 03:36:43 +01:00
|
|
|
this.quarterHeight = -1;
|
|
|
|
this.dayWidth = -1;
|
2010-02-11 20:48:09 +01:00
|
|
|
this.dayHeight = -1;
|
2010-02-11 03:36:43 +01:00
|
|
|
this.daysOffset = -1;
|
|
|
|
this.eventsViewNode = null;
|
|
|
|
this.eventsViewNodeCumulativeCoordinates = null;
|
|
|
|
},
|
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
setEventType: function(eventType) {
|
|
|
|
var prepareMethods
|
|
|
|
= { "multiday": this._prepareEventMultiDayContainerNodes,
|
|
|
|
"multiday-allday": this._prepareEventMultiDayAllDayContainerNodes,
|
|
|
|
"monthly": this._prepareEventMonthlyContainerNodes,
|
|
|
|
"unknown": null };
|
|
|
|
this._prepareEventContainerNodes = prepareMethods[eventType];
|
|
|
|
this.eventType = eventType;
|
|
|
|
},
|
|
|
|
getEventType: function(eventType) {
|
|
|
|
return this.eventType;
|
2010-02-11 03:36:43 +01:00
|
|
|
},
|
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
getEventContainerNodes: function() {
|
|
|
|
if (!this.eventContainerNodes) {
|
|
|
|
this._prepareEventContainerNodes();
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.eventContainerNodes;
|
|
|
|
},
|
|
|
|
_prepareEventMultiDayContainerNodes: function() {
|
|
|
|
this.eventContainerNodes = [];
|
2010-02-11 03:36:43 +01:00
|
|
|
var daysView = $("daysView");
|
|
|
|
var daysViewSubnodes = daysView.childNodesWithTag("div");
|
|
|
|
for (var i = 0; i < daysViewSubnodes.length; i++) {
|
|
|
|
var daysViewSubnode = daysViewSubnodes[i];
|
|
|
|
if (daysViewSubnode.hasClassName("days")) {
|
|
|
|
this.daysOffset = daysViewSubnode.offsetLeft + 2;
|
|
|
|
var daysSubnodes = daysViewSubnode.childNodesWithTag("div");
|
|
|
|
for (var j = 0; j < daysSubnodes.length; j++) {
|
|
|
|
var daysSubnode = daysSubnodes[j];
|
|
|
|
if (daysSubnode.hasClassName("day")) {
|
|
|
|
this._appendDayEventsNode(daysSubnode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2010-02-11 20:48:09 +01:00
|
|
|
_prepareEventMultiDayAllDayContainerNodes: function() {
|
|
|
|
this.eventContainerNodes = [];
|
|
|
|
var headerNode = $("calendarHeader");
|
|
|
|
var headerSubnodes = headerNode.childNodesWithTag("div");
|
|
|
|
for (var i = 0; i < headerSubnodes.length; i++) {
|
|
|
|
var headerSubnode = headerSubnodes[i];
|
|
|
|
if (headerSubnode.hasClassName("days")) {
|
|
|
|
this.daysOffset = headerSubnode.offsetLeft + 2;
|
|
|
|
var daysSubnodes = headerSubnode.childNodesWithTag("div");
|
|
|
|
for (var j = 0; j < daysSubnodes.length; j++) {
|
|
|
|
var daysSubnode = daysSubnodes[j];
|
|
|
|
if (daysSubnode.hasClassName("day"))
|
|
|
|
this.eventContainerNodes.push(daysSubnode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
_prepareEventMonthlyContainerNodes: function() {
|
|
|
|
var monthView = $("monthDaysView");
|
|
|
|
this.eventContainerNodes = monthView.childNodesWithTag("div");
|
|
|
|
this.daysOffset = this.eventContainerNodes[0].offsetLeft + 2;
|
|
|
|
},
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
_appendDayEventsNode: function(dayNode) {
|
|
|
|
var daySubnodes = dayNode.childNodesWithTag("div");
|
|
|
|
for (var i = 0; i < daySubnodes.length; i++) {
|
|
|
|
var daySubnode = daySubnodes[i];
|
|
|
|
if (daySubnode.hasClassName("events")) {
|
2010-02-11 20:48:09 +01:00
|
|
|
this.eventContainerNodes.push(daySubnode);
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getQuarterHeight: function() {
|
|
|
|
if (this.quarterHeight == -1) {
|
2010-02-13 00:24:24 +01:00
|
|
|
var hour0 = $("hour0");
|
|
|
|
var hour23 = $("hour23");
|
|
|
|
this.quarterHeight = ((hour23.offsetTop - hour0.offsetTop)
|
|
|
|
/ (23 * 4));
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return this.quarterHeight;
|
|
|
|
},
|
|
|
|
|
|
|
|
getDaysOffset: function() {
|
|
|
|
if (this.daysOffset == -1)
|
2010-02-11 20:48:09 +01:00
|
|
|
this._prepareEventContainerNodes();
|
2010-02-11 03:36:43 +01:00
|
|
|
|
|
|
|
return this.daysOffset;
|
|
|
|
},
|
|
|
|
|
|
|
|
getDayWidth: function() {
|
|
|
|
if (this.dayWidth == -1) {
|
2010-02-11 20:48:09 +01:00
|
|
|
var nodes = this.getEventContainerNodes();
|
2010-02-11 03:36:43 +01:00
|
|
|
if (nodes.length > 1) {
|
2010-02-11 20:48:09 +01:00
|
|
|
if (this.eventType == "monthly") {
|
|
|
|
var total = (nodes[6].cumulativeOffset()[0]
|
|
|
|
- nodes[0].cumulativeOffset()[0]);
|
|
|
|
this.dayWidth = total / 6;
|
|
|
|
} else {
|
|
|
|
var total = (nodes[nodes.length-1].cumulativeOffset()[0]
|
|
|
|
- nodes[0].cumulativeOffset()[0]);
|
|
|
|
this.dayWidth = total / (nodes.length - 1);
|
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
this.dayWidth = nodes[0].offsetWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.dayWidth;
|
|
|
|
},
|
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
getDayHeight: function() {
|
|
|
|
/* currently only used for monthly view */
|
|
|
|
if (this.dayHeight == -1) {
|
|
|
|
var nodes = this.getEventContainerNodes();
|
|
|
|
if (nodes.length > 1) {
|
|
|
|
var total = (nodes[3*7].cumulativeOffset()[1]
|
|
|
|
- nodes[0].cumulativeOffset()[1]);
|
|
|
|
this.dayHeight = total / 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.dayHeight;
|
|
|
|
},
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
getEventsViewNode: function() {
|
2010-02-11 20:48:09 +01:00
|
|
|
if (!this.eventsViewNode) {
|
|
|
|
if (this.eventType.startsWith("multiday"))
|
|
|
|
this.eventsViewNode = $("daysView");
|
|
|
|
else if (this.eventType.startsWith("multiday-allday")) {
|
|
|
|
this.eventsViewNode = $("calendarHeader");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
this.eventsViewNode = $("monthDaysView");
|
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
return this.eventsViewNode;
|
|
|
|
},
|
|
|
|
|
|
|
|
getEventsViewNodeCumulativeCoordinates: function() {
|
|
|
|
if (!this.eventsViewNodeCumulativeCoordinates) {
|
|
|
|
this.eventsViewNodeCumulativeCoordinates = new SOGoCoordinates();
|
|
|
|
var node = this.getEventsViewNode();
|
|
|
|
var cumulativeOffset = node.cumulativeOffset();
|
|
|
|
this.eventsViewNodeCumulativeCoordinates.x = cumulativeOffset[0];
|
|
|
|
this.eventsViewNodeCumulativeCoordinates.y = cumulativeOffset[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.eventsViewNodeCumulativeCoordinates;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
function SOGoEventDragEventCoordinates() {
|
|
|
|
}
|
|
|
|
|
|
|
|
SOGoEventDragEventCoordinates.prototype = {
|
|
|
|
dayNumber: -1,
|
|
|
|
start: -1,
|
|
|
|
duration: -1,
|
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
eventType: null,
|
|
|
|
|
|
|
|
setEventType: function(eventType) {
|
|
|
|
this.eventType = eventType;
|
|
|
|
this._prepareEventType();
|
|
|
|
},
|
|
|
|
_prepareEventType: function() {
|
|
|
|
var methods
|
|
|
|
= { "multiday": this.initFromEventCellMultiDay,
|
|
|
|
"multiday-allday": this.initFromEventCellMultiDayAllDay,
|
|
|
|
"monthly": this.initFromEventCellMonthly,
|
|
|
|
"unknown": null };
|
|
|
|
this.initFromEventCell = methods[this.eventType];
|
|
|
|
},
|
|
|
|
|
|
|
|
initFromEventCellMultiDay: function(eventCell) {
|
2014-07-16 16:30:48 +02:00
|
|
|
var classNames = eventCell.className.split(" ");
|
2014-07-09 22:47:13 +02:00
|
|
|
for (var i = 0; (this.start == -1 || this.duration == -1) && i < classNames.length; i++) {
|
2014-07-16 16:30:48 +02:00
|
|
|
var className = classNames[i];
|
2010-02-11 03:36:43 +01:00
|
|
|
if (className.startsWith("starts")) {
|
2014-07-16 16:30:48 +02:00
|
|
|
this.start = parseInt(className.substr(6));
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
else if (className.startsWith("lasts")) {
|
|
|
|
this.duration = parseInt(className.substr(5));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var dayNumber = -1;
|
2014-07-16 16:30:48 +02:00
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
var dayNode = eventCell.parentNode.parentNode;
|
2014-07-09 22:47:13 +02:00
|
|
|
if (currentView == "multicolumndayview") {
|
2014-07-16 16:30:48 +02:00
|
|
|
calendarID[0] = dayNode.getAttribute("calendar");
|
|
|
|
var dayNumber = this._updateMulticolumnViewDayNumber(calendarID);
|
2014-07-09 22:47:13 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-07-16 16:30:48 +02:00
|
|
|
var classNames = dayNode.className.split(" ");
|
|
|
|
for (var i = 0; dayNumber == -1 && i < classNames.length; i++) {
|
|
|
|
var className = classNames[i];
|
|
|
|
if (className.startsWith("day") && className.length > 3) {
|
|
|
|
dayNumber = parseInt(className.substr(3));
|
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
this.dayNumber = dayNumber;
|
|
|
|
},
|
2010-02-11 20:48:09 +01:00
|
|
|
initFromEventCellMultiDayAllDay: function(eventCell) {
|
|
|
|
this.start = 0;
|
|
|
|
this.duration = SOGoEventDragDayLength;
|
2014-07-16 16:30:48 +02:00
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
var dayNode = eventCell.parentNode;
|
2014-07-09 22:47:13 +02:00
|
|
|
if (currentView == "multicolumndayview") {
|
2014-07-16 16:30:48 +02:00
|
|
|
calendarID[0] = dayNode.getAttribute("calendar");
|
|
|
|
var dayNumber = this._updateMulticolumnViewDayNumber(calendarID);
|
2014-07-09 22:47:13 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-07-16 16:30:48 +02:00
|
|
|
var classNames = dayNode.className.split(" ");
|
|
|
|
var dayNumber = -1;
|
|
|
|
for (var i = 0; dayNumber == -1 && i < classNames.length; i++) {
|
|
|
|
var className = classNames[i];
|
|
|
|
if (className.startsWith("day") && className.length > 3) {
|
|
|
|
dayNumber = parseInt(className.substr(3));
|
|
|
|
}
|
2010-02-11 20:48:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
this.dayNumber = dayNumber;
|
|
|
|
},
|
|
|
|
initFromEventCellMonthly: function(eventCell) {
|
|
|
|
this.start = 0;
|
|
|
|
this.duration = SOGoEventDragDayLength;
|
|
|
|
|
|
|
|
var dayNumber = -1;
|
|
|
|
|
|
|
|
var week = -1;
|
|
|
|
var day = -1;
|
|
|
|
|
|
|
|
var dayNode = eventCell.parentNode;
|
|
|
|
var classNames = dayNode.className.split(" ");
|
|
|
|
for (var i = 0;
|
|
|
|
(day == -1 || week == -1)
|
|
|
|
&& i < classNames.length;
|
|
|
|
i++) {
|
|
|
|
var className = classNames[i];
|
|
|
|
if (className.startsWith("day") && className.length > 3) {
|
|
|
|
day = parseInt(className.substr(3));
|
|
|
|
} else if (className.startsWith("week")
|
|
|
|
&& !className.startsWith("weekOf")
|
|
|
|
&& className != "weekEndDay") {
|
|
|
|
var ofIndex = className.indexOf("of");
|
|
|
|
if (ofIndex > -1) {
|
|
|
|
var len = ofIndex - 4;
|
|
|
|
week = parseInt(className.substr(4, len));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.dayNumber = week * 7 + day;
|
|
|
|
},
|
2010-02-11 03:36:43 +01:00
|
|
|
|
|
|
|
initFromEventCells: function(eventCells) {
|
|
|
|
this.duration = 0;
|
|
|
|
for (var i = 0; i < eventCells.length; i++) {
|
|
|
|
var current = new SOGoEventDragEventCoordinates();
|
2010-02-11 20:48:09 +01:00
|
|
|
current.setEventType(this.eventType);
|
2010-02-11 03:36:43 +01:00
|
|
|
current.initFromEventCell(eventCells[i]);
|
|
|
|
if (this.dayNumber == -1 || current.dayNumber < this.dayNumber) {
|
2014-07-09 22:47:13 +02:00
|
|
|
this.dayNumber = current.dayNumber;
|
|
|
|
this.start = current.start;
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
this.duration += current.duration;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getDelta: function(otherCoordinates) {
|
|
|
|
var delta = new SOGoEventDragEventCoordinates();
|
|
|
|
delta.dayNumber = (this.dayNumber - otherCoordinates.dayNumber);
|
|
|
|
delta.start = (this.start - otherCoordinates.start);
|
|
|
|
delta.duration = (this.duration - otherCoordinates.duration);
|
|
|
|
|
|
|
|
return delta;
|
|
|
|
},
|
|
|
|
|
|
|
|
_quartersToHM: function(quarters) {
|
|
|
|
var minutes = quarters * 15;
|
|
|
|
var hours = Math.floor(minutes / 60);
|
|
|
|
if (hours < 10)
|
|
|
|
hours = "0" + hours;
|
|
|
|
var mins = minutes % 60;
|
|
|
|
if (mins < 10)
|
|
|
|
mins = "0" + mins;
|
|
|
|
|
|
|
|
return "" + hours + ":" + mins;
|
|
|
|
},
|
2014-07-09 22:47:13 +02:00
|
|
|
|
|
|
|
_updateMulticolumnViewDayNumber: function(calendarID) {
|
2014-07-16 16:30:48 +02:00
|
|
|
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));
|
2014-07-09 22:47:13 +02:00
|
|
|
}
|
2014-07-16 16:30:48 +02:00
|
|
|
for (var k = 0; k < activeCalendars.length; k++) {
|
|
|
|
if (activeCalendars[k] == calendarID[0]) {
|
|
|
|
return k;
|
|
|
|
}
|
2014-07-09 22:47:13 +02:00
|
|
|
}
|
|
|
|
},
|
2010-02-11 03:36:43 +01:00
|
|
|
|
|
|
|
getStartTime: function() {
|
|
|
|
return this._quartersToHM(this.start);
|
|
|
|
},
|
|
|
|
|
|
|
|
getEndTime: function() {
|
|
|
|
var end = (this.start + this.duration) % SOGoEventDragDayLength;
|
|
|
|
return this._quartersToHM(end);
|
|
|
|
},
|
|
|
|
|
|
|
|
clone: function() {
|
|
|
|
var coordinates = new SOGoEventDragEventCoordinates();
|
|
|
|
coordinates.dayNumber = this.dayNumber;
|
|
|
|
coordinates.start = this.start;
|
|
|
|
coordinates.duration = this.duration;
|
|
|
|
|
|
|
|
return coordinates;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var SOGoDragGhostInterface = {
|
|
|
|
visible: true,
|
|
|
|
|
|
|
|
title: null,
|
|
|
|
folderClass: null,
|
2010-02-15 15:20:30 +01:00
|
|
|
inside: null,
|
2010-02-11 03:36:43 +01:00
|
|
|
|
|
|
|
currentStart: -1,
|
|
|
|
currentDuration: -1,
|
|
|
|
isStartGhost: false,
|
|
|
|
isEndGhost: false,
|
|
|
|
|
|
|
|
show: function SDGI_show() {
|
|
|
|
if (!this.visible) {
|
|
|
|
this.removeClassName("hidden");
|
2010-02-15 15:20:30 +01:00
|
|
|
if (this.inside)
|
|
|
|
this.inside.removeClassName("hidden");
|
2010-02-11 03:36:43 +01:00
|
|
|
this.visible = true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
hide: function SDGI_hide() {
|
|
|
|
if (this.visible) {
|
|
|
|
this.addClassName("hidden");
|
2010-02-15 15:20:30 +01:00
|
|
|
if (this.inside)
|
|
|
|
this.inside.addClassName("hidden");
|
2010-02-11 03:36:43 +01:00
|
|
|
this.visible = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setTitle: function SDGI_setTitle(title) {
|
|
|
|
if (this.title != title) {
|
2010-02-15 15:20:30 +01:00
|
|
|
while (this.inside.childNodes.length) {
|
|
|
|
this.inside.removeChild(this.inside.firstChild);
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
if (title) {
|
2010-02-15 15:20:30 +01:00
|
|
|
this.inside.appendChild(document.createTextNode(title));
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
this.title = title;
|
|
|
|
}
|
|
|
|
},
|
2010-05-25 20:17:00 +02:00
|
|
|
setLocation: function SDGI_setLocation(location) {
|
|
|
|
if (this.location != location) {
|
|
|
|
var spans = this.inside.select("SPAN.location");
|
|
|
|
if (spans && spans.length > 0) {
|
|
|
|
this.inside.removeChild(spans[0]);
|
|
|
|
}
|
|
|
|
if (location) {
|
|
|
|
this.inside.appendChild(createElement("br"));
|
|
|
|
var span = createElement("span", null, "location");
|
|
|
|
span.appendChild(document.createTextNode(location));
|
|
|
|
this.inside.appendChild(span);
|
|
|
|
}
|
|
|
|
this.location = location;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
setFolderClass: function SDGI_setFolderClass(folderClass) {
|
|
|
|
if (this.folderClass != folderClass) {
|
|
|
|
this.removeClassName(this.folderClass);
|
|
|
|
this.folderClass = folderClass;
|
|
|
|
this.addClassName(this.folderClass);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setStart: function SDGI_setStart(start) {
|
|
|
|
if (this.currentStart != start) {
|
2010-02-11 20:48:09 +01:00
|
|
|
if (this.cssHandlesPosition)
|
|
|
|
this.removeClassName("starts" + this.currentStart);
|
2010-02-11 03:36:43 +01:00
|
|
|
this.currentStart = start;
|
2010-02-11 20:48:09 +01:00
|
|
|
if (this.cssHandlesPosition)
|
|
|
|
this.addClassName("starts" + this.currentStart);
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
setDuration: function SDGI_setDuration(duration) {
|
|
|
|
if (this.currentDuration != duration) {
|
2010-02-11 20:48:09 +01:00
|
|
|
if (this.cssHandlesPosition)
|
|
|
|
this.removeClassName("lasts" + this.currentDuration);
|
2010-02-11 03:36:43 +01:00
|
|
|
this.currentDuration = duration;
|
2010-02-11 20:48:09 +01:00
|
|
|
if (this.cssHandlesPosition)
|
|
|
|
this.addClassName("lasts" + this.currentDuration);
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setStartGhost: function SDGI_setStartGhost() {
|
|
|
|
if (!this.isStartGhost) {
|
|
|
|
this.addClassName("startGhost");
|
|
|
|
this.isStartGhost = true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
unsetStartGhost: function SDGI_unsetStartGhost() {
|
|
|
|
if (this.isStartGhost) {
|
|
|
|
this.removeClassName("startGhost");
|
|
|
|
this.isStartGhost = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setEndGhost: function SDGI_setEndGhost() {
|
|
|
|
if (!this.isEndGhost) {
|
|
|
|
this.addClassName("endGhost");
|
|
|
|
this.isEndGhost = true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
unsetEndGhost: function SDGI_unsetEndGhost() {
|
|
|
|
if (this.isEndGhost) {
|
|
|
|
this.removeClassName("endGhost");
|
|
|
|
this.isEndGhost = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
function SOGoEventDragGhostController() {
|
|
|
|
}
|
|
|
|
|
|
|
|
SOGoEventDragGhostController.prototype = {
|
|
|
|
originalCoordinates: null,
|
|
|
|
currentCoordinates: null,
|
|
|
|
|
|
|
|
originalPointerCoordinates: null,
|
|
|
|
currentPointerCoordinates: null,
|
|
|
|
|
|
|
|
dragMode: null,
|
|
|
|
|
|
|
|
startHourPara: null,
|
|
|
|
endHourPara: null,
|
|
|
|
ghosts: null,
|
|
|
|
|
|
|
|
initWithCoordinates: function SEDGC_initWithCoordinates(coordinates) {
|
|
|
|
this.originalCoordinates = coordinates;
|
|
|
|
this.currentCoordinates = coordinates.clone();
|
|
|
|
},
|
|
|
|
|
|
|
|
setTitle: function SEDGC_setTitle(title) {
|
|
|
|
this.eventTitle = title;
|
|
|
|
},
|
|
|
|
|
2010-05-25 20:17:00 +02:00
|
|
|
setLocation: function SEDGC_setLocation(location) {
|
|
|
|
this.eventLocation = location;
|
|
|
|
},
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
setFolderClass: function SEDGC_setFolderClass(folderClass) {
|
|
|
|
this.folderClass = folderClass;
|
|
|
|
},
|
|
|
|
|
|
|
|
setDragMode: function SEDGC_setDragMode(dragMode) {
|
|
|
|
this.dragMode = dragMode;
|
|
|
|
},
|
|
|
|
|
|
|
|
setPointerHandler: function SEDGC_setPointerHandler(pointerHandler) {
|
|
|
|
this.pointerHandler = pointerHandler;
|
|
|
|
this.originalPointerCoordinates = null;
|
|
|
|
this.currentPointerCoordinates = null;
|
|
|
|
this.updateFromPointerHandler();
|
|
|
|
this.originalPointerCoordinates = this.currentPointerCoordinates.clone();
|
|
|
|
},
|
|
|
|
|
|
|
|
updateFromPointerHandler: function SEDGC_updateFromPointerHandler() {
|
|
|
|
var newCoordinates = this.pointerHandler.getEventViewCoordinates();
|
|
|
|
if (!this.currentPointerCoordinates
|
2010-02-11 20:48:09 +01:00
|
|
|
|| !newCoordinates
|
2010-02-11 03:36:43 +01:00
|
|
|
|| newCoordinates.x != this.currentPointerCoordinates.x
|
|
|
|
|| newCoordinates.y != this.currentPointerCoordinates.y) {
|
|
|
|
this.currentPointerCoordinates = newCoordinates;
|
|
|
|
if (this.originalPointerCoordinates) {
|
2010-02-11 20:48:09 +01:00
|
|
|
if (!newCoordinates)
|
2014-07-15 23:29:39 +02:00
|
|
|
this.currentPointerCoordinates = this.originalPointerCoordinates.clone();
|
2010-02-11 03:36:43 +01:00
|
|
|
this._updateCoordinates();
|
|
|
|
if (this.ghosts) {
|
|
|
|
this._updateGhosts();
|
2010-02-11 20:48:09 +01:00
|
|
|
if (this.startHourPara)
|
|
|
|
this._updateGhostsParas();
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-07-09 22:47:13 +02:00
|
|
|
|
|
|
|
_updateMulticolumnViewDayNumber_SEDGC: function() {
|
2014-07-16 16:30:48 +02:00
|
|
|
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));
|
2014-07-09 22:47:13 +02:00
|
|
|
}
|
2014-07-16 16:30:48 +02:00
|
|
|
for (var k = 0; k < activeCalendars.length; k++) {
|
|
|
|
if (activeCalendars[k] == calendarID_SEDGC) {
|
|
|
|
this.currentCoordinates.dayNumber = k;
|
|
|
|
break;
|
|
|
|
}
|
2014-07-09 22:47:13 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
_updateCoordinates: function SEDGC__updateCoordinates() {
|
|
|
|
var delta = this.currentPointerCoordinates
|
|
|
|
.getDelta(this.originalPointerCoordinates);
|
|
|
|
var deltaQuarters = delta.x * SOGoEventDragDayLength + delta.y;
|
2014-07-09 22:47:13 +02:00
|
|
|
if (currentView == "multicolumndayview")
|
|
|
|
this._updateMulticolumnViewDayNumber_SEDGC();
|
|
|
|
else
|
|
|
|
this.currentCoordinates.dayNumber = this.originalCoordinates.dayNumber;
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
// log("dragMode: " + this.dragMode);
|
2010-02-11 03:36:43 +01:00
|
|
|
if (this.dragMode == "move-event") {
|
|
|
|
this.currentCoordinates.start
|
|
|
|
= this.originalCoordinates.start + deltaQuarters;
|
|
|
|
this.currentCoordinates.duration
|
|
|
|
= this.originalCoordinates.duration;
|
2010-02-11 20:48:09 +01:00
|
|
|
// log("start: " + this.currentCoordinates.start);
|
|
|
|
// log(" duration: " + this.currentCoordinates.duration);
|
2010-02-11 03:36:43 +01:00
|
|
|
} else {
|
|
|
|
if (this.dragMode == "change-start") {
|
|
|
|
var newDuration = this.originalCoordinates.duration - deltaQuarters;
|
|
|
|
if (newDuration > 0) {
|
|
|
|
this.currentCoordinates.start
|
|
|
|
= this.originalCoordinates.start + deltaQuarters;
|
|
|
|
this.currentCoordinates.duration = newDuration;
|
|
|
|
} else if (newDuration < 0) {
|
|
|
|
this.currentCoordinates.start
|
|
|
|
= (this.originalCoordinates.start
|
|
|
|
+ this.originalCoordinates.duration);
|
|
|
|
this.currentCoordinates.duration = -newDuration;
|
|
|
|
}
|
|
|
|
} else if (this.dragMode == "change-end") {
|
|
|
|
var newDuration = this.originalCoordinates.duration + deltaQuarters;
|
|
|
|
if (newDuration > 0) {
|
|
|
|
this.currentCoordinates.start = this.originalCoordinates.start;
|
|
|
|
this.currentCoordinates.duration = newDuration;
|
|
|
|
} else if (newDuration < 0) {
|
|
|
|
this.currentCoordinates.start
|
|
|
|
= this.originalCoordinates.start + newDuration;
|
|
|
|
this.currentCoordinates.duration = -newDuration;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.currentCoordinates.start < 0) {
|
|
|
|
var deltaDays = Math.ceil(-this.currentCoordinates.start
|
|
|
|
/ SOGoEventDragDayLength);
|
|
|
|
this.currentCoordinates.start += deltaDays * SOGoEventDragDayLength;
|
|
|
|
this.currentCoordinates.dayNumber -= deltaDays;
|
|
|
|
} else if (this.currentCoordinates.start >= SOGoEventDragDayLength) {
|
|
|
|
var deltaDays = Math.floor(this.currentCoordinates.start
|
|
|
|
/ SOGoEventDragDayLength);
|
|
|
|
this.currentCoordinates.start -= deltaDays * SOGoEventDragDayLength;
|
2014-07-09 22:47:13 +02:00
|
|
|
|
|
|
|
// This dayNumber needs to be updated with the calendar number.
|
|
|
|
if (currentView == "multicolumndayview")
|
|
|
|
this._updateMulticolumnViewDayNumber_SEDGC();
|
2010-02-11 03:36:43 +01:00
|
|
|
this.currentCoordinates.dayNumber += deltaDays;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
showGhosts: function SEDGC_showGhosts() {
|
|
|
|
if (!this.ghosts) {
|
|
|
|
this.ghosts = [];
|
|
|
|
var utilities = SOGoEventDragUtilities();
|
2010-02-11 20:48:09 +01:00
|
|
|
var nodes = utilities.getEventContainerNodes();
|
|
|
|
var isMultiday = (utilities.getEventType() == "multiday");
|
2010-02-11 03:36:43 +01:00
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
var newGhost = $(document.createElement("div"));
|
|
|
|
Object.extend(newGhost, SOGoDragGhostInterface);
|
|
|
|
newGhost.className = "event eventDragGhost";
|
2010-02-11 20:48:09 +01:00
|
|
|
newGhost.cssHandlesPosition = isMultiday;
|
2010-02-11 03:36:43 +01:00
|
|
|
newGhost.hide();
|
2010-02-15 15:20:30 +01:00
|
|
|
|
|
|
|
var ghostInside = $(document.createElement("div"));
|
|
|
|
ghostInside.className = "eventInside";
|
|
|
|
newGhost.inside = ghostInside;
|
|
|
|
newGhost.appendChild(ghostInside);
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
nodes[i].appendChild(newGhost);
|
|
|
|
this.ghosts.push(newGhost);
|
|
|
|
}
|
2010-02-11 20:48:09 +01:00
|
|
|
if (isMultiday) {
|
|
|
|
var ghostHourPara = $(document.createElement("div"));
|
|
|
|
ghostHourPara.setAttribute("id", "ghostStartHour");
|
|
|
|
this.startHourPara = ghostHourPara;
|
|
|
|
ghostHourPara = $(document.createElement("div"));
|
|
|
|
ghostHourPara.setAttribute("id", "ghostEndHour");
|
|
|
|
this.endHourPara = ghostHourPara;
|
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
this._updateGhosts();
|
2010-02-11 20:48:09 +01:00
|
|
|
if (this.startHourPara)
|
|
|
|
this._updateGhostsParas();
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
hideGhosts: function SEDGC_hideGhosts() {
|
|
|
|
if (this.ghosts) {
|
2010-02-11 20:48:09 +01:00
|
|
|
if (this.startHourPara && this.startHourPara.parentNode)
|
2010-02-11 03:36:43 +01:00
|
|
|
this.startHourPara.parentNode.removeChild(this.startHourPara);
|
|
|
|
this.startHourPara = null;
|
2010-02-11 20:48:09 +01:00
|
|
|
if (this.endHourPara && this.endHourPara.parentNode)
|
2010-02-11 03:36:43 +01:00
|
|
|
this.endHourPara.parentNode.removeChild(this.endHourPara);
|
|
|
|
this.endHourPara = null;
|
|
|
|
for (var i = 0; i < this.ghosts.length; i++) {
|
|
|
|
var ghost = this.ghosts[i];
|
|
|
|
ghost.parentNode.removeChild(ghost);
|
|
|
|
}
|
|
|
|
this.ghosts = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_updateGhosts: function SEDGC__updateGhosts() {
|
|
|
|
var maxGhosts = this.ghosts.length;
|
|
|
|
var max = this.currentCoordinates.dayNumber;
|
|
|
|
if (max > maxGhosts)
|
|
|
|
max = maxGhosts;
|
|
|
|
for (var i = 0; i < max; i++) {
|
|
|
|
var ghost = this.ghosts[i];
|
|
|
|
ghost.hide();
|
|
|
|
ghost.unsetStartGhost();
|
|
|
|
ghost.unsetEndGhost();
|
|
|
|
}
|
|
|
|
if (this.currentCoordinates.dayNumber < maxGhosts) {
|
|
|
|
var currentDay = this.currentCoordinates.dayNumber;
|
|
|
|
var durationLeft = this.currentCoordinates.duration;
|
|
|
|
var start = this.currentCoordinates.start;
|
|
|
|
var maxDuration = SOGoEventDragDayLength - start;
|
|
|
|
var duration = durationLeft;
|
|
|
|
if (duration > maxDuration)
|
|
|
|
duration = maxDuration;
|
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
var ghost = null;
|
2010-02-11 03:36:43 +01:00
|
|
|
if (currentDay > -1) {
|
|
|
|
ghost = this.ghosts[currentDay];
|
|
|
|
ghost.setStartGhost();
|
|
|
|
ghost.unsetEndGhost();
|
|
|
|
ghost.setTitle(this.eventTitle);
|
2010-05-25 20:17:00 +02:00
|
|
|
ghost.setLocation(this.eventLocation);
|
2010-02-11 03:36:43 +01:00
|
|
|
ghost.setFolderClass(this.folderClass);
|
|
|
|
ghost.setStart(this.currentCoordinates.start);
|
|
|
|
ghost.setDuration(duration);
|
|
|
|
ghost.show();
|
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
if (this.startHourPara) {
|
|
|
|
var parentNode = this.startHourPara.parentNode;
|
|
|
|
if (parentNode && parentNode != ghost)
|
|
|
|
parentNode.removeChild(this.startHourPara);
|
2010-02-11 03:36:43 +01:00
|
|
|
ghost.appendChild(this.startHourPara);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
durationLeft -= duration;
|
|
|
|
currentDay++;
|
|
|
|
while (durationLeft && currentDay < maxGhosts) {
|
|
|
|
duration = durationLeft;
|
|
|
|
if (duration > SOGoEventDragDayLength)
|
|
|
|
duration = SOGoEventDragDayLength;
|
|
|
|
if (currentDay > -1) {
|
|
|
|
ghost = this.ghosts[currentDay];
|
|
|
|
ghost.unsetStartGhost();
|
|
|
|
ghost.unsetEndGhost();
|
|
|
|
ghost.setTitle();
|
|
|
|
ghost.setFolderClass(this.folderClass);
|
|
|
|
ghost.setStart(0);
|
|
|
|
ghost.setDuration(duration);
|
|
|
|
ghost.show();
|
|
|
|
}
|
|
|
|
durationLeft -= duration;
|
|
|
|
currentDay++;
|
|
|
|
}
|
2010-02-11 20:48:09 +01:00
|
|
|
if (!durationLeft) {
|
2010-02-11 03:36:43 +01:00
|
|
|
ghost.setEndGhost();
|
2010-02-11 20:48:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.endHourPara) {
|
|
|
|
var parentNode = this.endHourPara.parentNode;
|
|
|
|
if (parentNode && parentNode != ghost)
|
|
|
|
parentNode.removeChild(this.endHourPara);
|
2010-02-11 03:36:43 +01:00
|
|
|
ghost.appendChild(this.endHourPara);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (currentDay < maxGhosts) {
|
|
|
|
var ghost = this.ghosts[currentDay];
|
|
|
|
ghost.hide();
|
|
|
|
ghost.unsetStartGhost();
|
|
|
|
ghost.unsetEndGhost();
|
|
|
|
currentDay++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_updateGhostsParas: function SEDGC__updateGhostsParas() {
|
|
|
|
var para = this.startHourPara;
|
2010-02-11 20:48:09 +01:00
|
|
|
while (para.childNodes.length)
|
2010-02-11 03:36:43 +01:00
|
|
|
para.removeChild(para.childNodes[0]);
|
|
|
|
var time = this.currentCoordinates.getStartTime();
|
|
|
|
para.appendChild(document.createTextNode(time));
|
|
|
|
|
|
|
|
para = this.endHourPara;
|
2010-02-11 20:48:09 +01:00
|
|
|
while (para.childNodes.length)
|
2010-02-11 03:36:43 +01:00
|
|
|
para.removeChild(para.childNodes[0]);
|
|
|
|
time = this.currentCoordinates.getEndTime();
|
|
|
|
para.appendChild(document.createTextNode(time));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
function SOGoCoordinates() {
|
|
|
|
}
|
|
|
|
|
|
|
|
SOGoCoordinates.prototype = {
|
|
|
|
x: -1,
|
|
|
|
y: -1,
|
|
|
|
|
|
|
|
getDelta: function SC_getDelta(otherCoordinates) {
|
|
|
|
var delta = new SOGoCoordinates();
|
|
|
|
delta.x = this.x - otherCoordinates.x;
|
|
|
|
delta.y = this.y - otherCoordinates.y;
|
|
|
|
|
|
|
|
return delta;
|
|
|
|
},
|
|
|
|
|
|
|
|
getDistance: function SC_getDistance(otherCoordinates) {
|
|
|
|
var delta = this.getDelta(otherCoordinates);
|
|
|
|
|
|
|
|
return Math.sqrt(delta.x * delta.x + delta.y * delta.y);
|
|
|
|
},
|
|
|
|
|
|
|
|
clone: function SC_clone() {
|
|
|
|
var coordinates = new SOGoCoordinates();
|
|
|
|
coordinates.x = this.x;
|
|
|
|
coordinates.y = this.y;
|
|
|
|
|
|
|
|
return coordinates;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
function SOGoEventDragPointerHandler() {
|
|
|
|
}
|
|
|
|
|
|
|
|
SOGoEventDragPointerHandler.prototype = {
|
|
|
|
originalCoordinates: null,
|
|
|
|
currentCoordinates: null,
|
|
|
|
containerCoordinates: null,
|
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
/* return the day and quarter coordinates of the pointer cursor within the
|
|
|
|
day view */
|
|
|
|
getEventViewCoordinates: null,
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
initFromEvent: function SEDPH_initFromEvent(event) {
|
|
|
|
this.currentCoordinates = new SOGoCoordinates();
|
|
|
|
this.updateFromEvent(event);
|
|
|
|
this.originalCoordinates = this.currentCoordinates.clone();
|
|
|
|
|
|
|
|
var utilities = SOGoEventDragUtilities();
|
|
|
|
this.containerCoordinates = utilities.getEventsViewNodeCumulativeCoordinates();
|
2010-02-11 20:48:09 +01:00
|
|
|
if (utilities.getEventType() == "multiday-allday") {
|
|
|
|
/* a hack */
|
|
|
|
this.containerCoordinates.x -= SOGoEventDragVerticalOffset;
|
|
|
|
this.containerCoordinates.y -= 40;
|
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
updateFromEvent: function SEDPH_updateFromEvent(event) {
|
|
|
|
this.currentCoordinates.x = Event.pointerX(event);
|
|
|
|
this.currentCoordinates.y = Event.pointerY(event);
|
|
|
|
},
|
|
|
|
|
|
|
|
getContainerBasedCoordinates: function SEDPH_getCBC() {
|
2010-02-11 20:48:09 +01:00
|
|
|
var coordinates = this.currentCoordinates.getDelta(this.containerCoordinates);
|
|
|
|
var container = SOGoEventDragUtilities().getEventsViewNode();
|
|
|
|
|
2013-01-17 17:21:48 +01:00
|
|
|
if (container.clientWidth == 0)
|
|
|
|
/* a hack for Safari */
|
|
|
|
container = $(container.id);
|
2010-02-11 20:48:09 +01:00
|
|
|
if (coordinates.x < 0 || coordinates.x > container.clientWidth
|
|
|
|
|| coordinates.y < 0 || coordinates.y > container.clientHeight)
|
|
|
|
coordinates = null;
|
|
|
|
|
|
|
|
return coordinates;
|
2010-02-11 03:36:43 +01:00
|
|
|
},
|
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
prepareWithEventType: function SEDPH_prepareWithEventType(eventType) {
|
|
|
|
var methods = { "multiday": this.getEventMultiDayViewCoordinates,
|
|
|
|
"multiday-allday": this.getEventMultiDayAllDayViewCoordinates,
|
|
|
|
"monthly": this.getEventMonthlyViewCoordinates,
|
|
|
|
"unknown": null };
|
|
|
|
var method = methods[eventType];
|
|
|
|
this.getEventViewCoordinates = method;
|
|
|
|
},
|
|
|
|
|
|
|
|
getEventMultiDayViewCoordinates: function SEDPH_gEMultiDayViewC() {
|
|
|
|
var coordinates = this.getEventMultiDayAllDayViewCoordinates();
|
|
|
|
if (coordinates) {
|
|
|
|
var utilities = SOGoEventDragUtilities();
|
|
|
|
var quarterHeight = utilities.getQuarterHeight();
|
|
|
|
var container = utilities.getEventsViewNode();
|
|
|
|
var pxCoordinates = this.getContainerBasedCoordinates();
|
|
|
|
pxCoordinates.y += container.scrollTop;
|
|
|
|
coordinates.y = Math.floor((pxCoordinates.y
|
|
|
|
- SOGoEventDragHorizontalOffset)
|
|
|
|
/ quarterHeight);
|
|
|
|
var maxY = SOGoEventDragDayLength - 1;
|
|
|
|
if (coordinates.y < 0)
|
|
|
|
coordinates.y = 0;
|
|
|
|
else if (coordinates.y > maxY)
|
|
|
|
coordinates.y = maxY;
|
|
|
|
}
|
|
|
|
|
|
|
|
return coordinates;
|
|
|
|
},
|
|
|
|
getEventMultiDayAllDayViewCoordinates: function SEDPH_gEMultiDayADVC() {
|
2010-02-11 03:36:43 +01:00
|
|
|
/* x = day; y = quarter */
|
2010-02-11 20:48:09 +01:00
|
|
|
var coordinates;
|
2010-02-11 03:36:43 +01:00
|
|
|
|
|
|
|
var pxCoordinates = this.getContainerBasedCoordinates();
|
2010-02-11 20:48:09 +01:00
|
|
|
if (pxCoordinates) {
|
|
|
|
coordinates = new SOGoCoordinates();
|
|
|
|
|
|
|
|
var utilities = SOGoEventDragUtilities();
|
|
|
|
var dayWidth = utilities.getDayWidth();
|
|
|
|
var daysOffset = utilities.getDaysOffset();
|
|
|
|
|
|
|
|
coordinates.x = Math.floor((pxCoordinates.x - daysOffset) / dayWidth);
|
|
|
|
var maxX = utilities.getEventContainerNodes().length - 1;
|
|
|
|
if (coordinates.x < 0)
|
|
|
|
coordinates.x = 0;
|
|
|
|
else if (coordinates.x > maxX)
|
|
|
|
coordinates.x = maxX;
|
|
|
|
coordinates.y = 0;
|
|
|
|
} else {
|
|
|
|
coordinates = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
// logOnly("coordinates.x: " + coordinates.x);
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
return coordinates;
|
|
|
|
},
|
|
|
|
getEventMonthlyViewCoordinates: function SEDPH_gEMonthlyViewC() {
|
|
|
|
/* x = day; y = quarter */
|
|
|
|
var coordinates;
|
|
|
|
|
|
|
|
var pxCoordinates = this.getContainerBasedCoordinates();
|
|
|
|
if (pxCoordinates) {
|
|
|
|
coordinates = new SOGoCoordinates();
|
|
|
|
var utilities = SOGoEventDragUtilities();
|
|
|
|
var daysOffset = utilities.getDaysOffset();
|
|
|
|
var daysTopOffset = daysOffset; /* change later */
|
|
|
|
var dayHeight = utilities.getDayHeight();
|
|
|
|
var daysY = Math.floor((pxCoordinates.y - daysTopOffset) / dayHeight);
|
|
|
|
if (daysY < 0)
|
|
|
|
daysY = 0;
|
|
|
|
var dayWidth = utilities.getDayWidth();
|
|
|
|
|
|
|
|
coordinates.x = Math.floor((pxCoordinates.x - daysOffset) / dayWidth);
|
|
|
|
if (coordinates.x < 0)
|
|
|
|
coordinates.x = 0;
|
|
|
|
else if (coordinates.x > 6)
|
|
|
|
coordinates.x = 6;
|
|
|
|
coordinates.x += 7 * daysY;
|
2010-02-11 03:36:43 +01:00
|
|
|
coordinates.y = 0;
|
2010-02-11 20:48:09 +01:00
|
|
|
} else {
|
|
|
|
coordinates = null;
|
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
|
|
|
|
return coordinates;
|
|
|
|
},
|
|
|
|
|
|
|
|
getDistance: function SEDPH_getDistance() {
|
|
|
|
return this.currentCoordinates.getDistance(this.originalCoordinates);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
function SOGoScrollController() {
|
|
|
|
this.init();
|
|
|
|
}
|
|
|
|
|
|
|
|
SOGoScrollController.prototype = {
|
|
|
|
pointerHandler: null,
|
|
|
|
|
|
|
|
scrollView: null,
|
|
|
|
lastScroll: 0,
|
|
|
|
scrollStep: 0,
|
|
|
|
|
|
|
|
init: function SSC_init() {
|
|
|
|
var utilities = SOGoEventDragUtilities();
|
|
|
|
this.scrollView = utilities.getEventsViewNode();
|
2010-02-12 18:23:47 +01:00
|
|
|
this.scrollStep = 6 * utilities.getQuarterHeight();
|
2010-02-11 03:36:43 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
setPointerHandler: function SSC_setPointerHandler(pointerHandler) {
|
|
|
|
this.pointerHandler = pointerHandler;
|
|
|
|
},
|
|
|
|
|
|
|
|
updateFromPointerHandler: function SSC_updateFromPointerHandler() {
|
|
|
|
var pointerCoordinates
|
|
|
|
= this.pointerHandler.getContainerBasedCoordinates();
|
2010-02-11 20:48:09 +01:00
|
|
|
if (pointerCoordinates) {
|
|
|
|
var now = new Date().getTime();
|
|
|
|
if (!this.lastScroll || now > this.lastScroll + 100) {
|
|
|
|
this.lastScroll = now;
|
|
|
|
var scrollY = pointerCoordinates.y - this.scrollStep;
|
|
|
|
if (scrollY < 0) {
|
|
|
|
var minY = -this.scrollView.scrollTop;
|
|
|
|
if (scrollY < minY)
|
|
|
|
scrollY = minY;
|
|
|
|
this.scrollView.scrollTop += scrollY;
|
|
|
|
} else {
|
|
|
|
scrollY = pointerCoordinates.y + this.scrollStep;
|
|
|
|
var delta = scrollY - this.scrollView.clientHeight;
|
|
|
|
if (delta > 0) {
|
|
|
|
this.scrollView.scrollTop += delta;
|
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-07-15 23:29:39 +02:00
|
|
|
function SOGoEventDragLeftPanelController() {
|
|
|
|
}
|
|
|
|
|
|
|
|
SOGoEventDragLeftPanelController.prototype = {
|
2014-07-18 15:23:07 +02:00
|
|
|
updateLeftPanelVisual : null,
|
|
|
|
dropCalendar : null,
|
|
|
|
|
|
|
|
setLeftPanelVisual: function SEDLPC_setLeftPanelVisual() {
|
|
|
|
this.updateLeftPanelVisual = $("leftPanel").on("mousemove", function(e){
|
|
|
|
$("DnDCalendarList").style.left = e.pageX + "px";
|
|
|
|
$("DnDCalendarList").style.top = e.pageY + "px";
|
|
|
|
});
|
|
|
|
},
|
2014-07-16 16:30:48 +02:00
|
|
|
|
|
|
|
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');
|
2014-07-18 15:23:07 +02:00
|
|
|
this.dropCalendar = hoverCalendar;
|
2014-07-15 23:29:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
function SOGoEventDragController() {
|
|
|
|
}
|
|
|
|
|
|
|
|
SOGoEventDragController.prototype = {
|
|
|
|
eventCells: null,
|
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
eventType: null,
|
2010-02-15 18:50:33 +01:00
|
|
|
eventIsInvitation: false,
|
2010-02-11 03:36:43 +01:00
|
|
|
title: null,
|
|
|
|
folderClass: null,
|
|
|
|
|
|
|
|
draggingModeAreas: null,
|
|
|
|
|
|
|
|
ghostController: null,
|
2014-07-17 15:42:32 +02:00
|
|
|
leftPanelController: null,
|
2010-02-11 03:36:43 +01:00
|
|
|
|
|
|
|
hasSelected: false,
|
|
|
|
dragHasStarted: false,
|
|
|
|
dragMode: null,
|
|
|
|
originalDayNumber: -1,
|
|
|
|
|
|
|
|
pointerHandler: null,
|
|
|
|
|
|
|
|
dropCallback: null,
|
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
onDragStartBound: null,
|
2010-02-11 20:48:09 +01:00
|
|
|
onDragStopBound: null,
|
2010-02-13 00:24:24 +01:00
|
|
|
onDragModeBound: null,
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
_determineDragMode: null,
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
attachToEventCells: function SEDC_attachToEventCells(eventCells) {
|
|
|
|
this.eventCells = eventCells;
|
|
|
|
|
|
|
|
this.ghostController = new SOGoEventDragGhostController();
|
2014-07-15 23:29:39 +02:00
|
|
|
this.leftPanelController = new SOGoEventDragLeftPanelController();
|
2010-02-15 18:50:33 +01:00
|
|
|
this._determineEventInvitation(eventCells[0]);
|
2010-02-11 20:48:09 +01:00
|
|
|
this._determineEventType(eventCells[0]);
|
|
|
|
this._prepareEventType();
|
2010-02-11 03:36:43 +01:00
|
|
|
this._determineTitleAndFolderClass();
|
|
|
|
this.ghostController.setTitle(this.title);
|
2010-05-25 20:17:00 +02:00
|
|
|
this.ghostController.setLocation(this.location);
|
2010-02-11 03:36:43 +01:00
|
|
|
this.ghostController.setFolderClass(this.folderClass);
|
2014-07-18 15:23:07 +02:00
|
|
|
this.leftPanelController.setLeftPanelVisual();
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
this.onDragStartBound = this.onDragStart.bindAsEventListener(this);
|
2010-02-11 03:36:43 +01:00
|
|
|
for (var i = 0; i < eventCells.length; i++) {
|
2010-02-13 00:24:24 +01:00
|
|
|
eventCells[i].observe("mousedown", this.onDragStartBound, false);
|
2010-02-15 18:50:33 +01:00
|
|
|
if (eventCells[i].editable && !this.eventIsInvitation) {
|
2010-02-11 20:48:09 +01:00
|
|
|
eventCells[i].addClassName("draggable");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.eventType == "multiday") {
|
|
|
|
var topDragGrip = $(document.createElement("div"));
|
|
|
|
topDragGrip.addClassName("topDragGrip");
|
|
|
|
eventCells[0].appendChild(topDragGrip);
|
|
|
|
|
|
|
|
var bottomDragGrip = $(document.createElement("div"));
|
|
|
|
bottomDragGrip.addClassName("bottomDragGrip");
|
|
|
|
eventCells[eventCells.length-1].appendChild(bottomDragGrip);
|
|
|
|
} else {
|
|
|
|
var leftDragGrip = $(document.createElement("div"));
|
|
|
|
leftDragGrip.addClassName("leftDragGrip");
|
|
|
|
eventCells[0].appendChild(leftDragGrip);
|
|
|
|
|
|
|
|
var rightDragGrip = $(document.createElement("div"));
|
|
|
|
rightDragGrip.addClassName("rightDragGrip");
|
|
|
|
eventCells[eventCells.length-1].appendChild(rightDragGrip);
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
attachToDayNode: function SEDC_attachToDayNode(dayNode) {
|
2010-02-11 20:48:09 +01:00
|
|
|
this._determineEventType(dayNode);
|
|
|
|
this._prepareEventType();
|
2010-02-11 03:36:43 +01:00
|
|
|
this.ghostController = new SOGoEventDragGhostController();
|
2010-06-02 21:11:15 +02:00
|
|
|
this.ghostController.setTitle(_("New Event"));
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
this.onDragStartBound = this.onDragStart.bindAsEventListener(this);
|
|
|
|
dayNode.observe("mousedown", this.onDragStartBound, false);
|
2010-02-11 03:36:43 +01:00
|
|
|
},
|
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
onDragStart: function SEDC_onDragStart(event) {
|
2010-02-11 03:36:43 +01:00
|
|
|
var target = getTarget(event);
|
2010-03-31 22:44:22 +02:00
|
|
|
if (eventIsLeftClick(event) && (target.nodeType == 1)) {
|
2014-01-28 21:36:48 +01:00
|
|
|
if (/minutes\d{2}/.test(target.className))
|
2013-07-11 19:50:44 +02:00
|
|
|
target = target.parentNode;
|
2010-02-11 20:48:09 +01:00
|
|
|
if ((!this.eventCells
|
|
|
|
&& (target.hasClassName("clickableHourCell")
|
2010-03-31 17:27:59 +02:00
|
|
|
|| target.hasClassName("day"))
|
2010-04-03 09:35:28 +02:00
|
|
|
&& (target.scrollHeight - target.clientHeight <= 1))
|
2010-03-15 13:51:57 +01:00
|
|
|
|| (this.eventCells && this.eventCells[0].editable
|
|
|
|
&& !this.eventIsInvitation)) {
|
2010-02-11 03:36:43 +01:00
|
|
|
var utilities = SOGoEventDragUtilities();
|
2010-02-11 20:48:09 +01:00
|
|
|
utilities.setEventType(this.eventType);
|
2010-02-11 03:36:43 +01:00
|
|
|
|
|
|
|
this.pointerHandler = new SOGoEventDragPointerHandler();
|
2010-02-11 20:48:09 +01:00
|
|
|
this.pointerHandler.prepareWithEventType(this.eventType);
|
2010-02-11 03:36:43 +01:00
|
|
|
this.pointerHandler.initFromEvent(event);
|
|
|
|
|
|
|
|
var coordinates = new SOGoEventDragEventCoordinates();
|
2010-02-11 20:48:09 +01:00
|
|
|
coordinates.setEventType(this.eventType);
|
2010-02-11 03:36:43 +01:00
|
|
|
if (this.eventCells) {
|
|
|
|
coordinates.initFromEventCells(this.eventCells);
|
|
|
|
} else {
|
|
|
|
var eventViewCoordinates
|
|
|
|
= this.pointerHandler.getEventViewCoordinates();
|
|
|
|
coordinates.dayNumber = eventViewCoordinates.x;
|
|
|
|
coordinates.start = eventViewCoordinates.y;
|
|
|
|
coordinates.duration = 1;
|
|
|
|
}
|
|
|
|
this.ghostController.initWithCoordinates(coordinates);
|
|
|
|
|
|
|
|
if (!this.eventCells) {
|
2014-07-16 16:30:48 +02:00
|
|
|
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);
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
this.ghostController.setDragMode(this._determineDragMode());
|
|
|
|
this.ghostController.setPointerHandler(this.pointerHandler);
|
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
if (this.eventType == "multiday") {
|
|
|
|
this.scrollController = new SOGoScrollController();
|
|
|
|
this.scrollController.setPointerHandler(this.pointerHandler);
|
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
this.onDragStopBound
|
|
|
|
= this.onDragStop.bindAsEventListener(this);
|
2010-02-11 03:36:43 +01:00
|
|
|
if (Prototype.Browser.IE)
|
|
|
|
Event.observe(document.body,
|
2010-02-11 20:48:09 +01:00
|
|
|
"mouseup", this.onDragStopBound);
|
2010-02-11 03:36:43 +01:00
|
|
|
else
|
2010-02-11 20:48:09 +01:00
|
|
|
Event.observe(window, "mouseup", this.onDragStopBound);
|
|
|
|
this.onDragModeBound = this.onDragMode.bindAsEventListener(this);
|
|
|
|
Event.observe(document.body, "mousemove", this.onDragModeBound);
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2010-02-11 20:48:09 +01:00
|
|
|
|
2010-02-15 18:50:33 +01:00
|
|
|
_determineEventInvitation: function SEDC__determineEventType(node) {
|
|
|
|
var isInvitation = false;
|
|
|
|
for (var i = 0; !isInvitation && i < userStates.length; i++) {
|
|
|
|
var inside = node.select("DIV.eventInside")[0];
|
|
|
|
if (inside.hasClassName(userStates[i]))
|
|
|
|
isInvitation = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.eventIsInvitation = isInvitation;
|
|
|
|
},
|
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
_determineEventType: function SEDC__determineEventType(node) {
|
|
|
|
var type = "unknown";
|
|
|
|
|
|
|
|
var dayNode;
|
|
|
|
var currentNode = node;
|
|
|
|
while (!currentNode.hasClassName("day"))
|
|
|
|
currentNode = currentNode.parentNode;
|
|
|
|
dayNode = currentNode;
|
|
|
|
|
|
|
|
// log("dayNode: " + dayNode.className);
|
|
|
|
var secondParent = dayNode.parentNode;
|
|
|
|
// log("secondParent: " + secondParent.className);
|
|
|
|
if (secondParent.id == "monthDaysView") {
|
|
|
|
type = "monthly";
|
|
|
|
} else {
|
|
|
|
var thirdParent = secondParent.parentNode;
|
|
|
|
// log("thirdParent: " + thirdParent.id);
|
|
|
|
if (thirdParent.id == "calendarHeader")
|
|
|
|
type = "multiday-allday";
|
|
|
|
else if (thirdParent.id == "daysView")
|
|
|
|
type = "multiday";
|
|
|
|
}
|
|
|
|
|
|
|
|
// log("type: " + type);
|
|
|
|
|
|
|
|
this.eventType = type;
|
|
|
|
},
|
|
|
|
_prepareEventType: function SEDC__prepareEventType() {
|
|
|
|
var methods
|
|
|
|
= { "multiday": this._determineDragModeMultiDay,
|
|
|
|
"multiday-allday": this._determineDragModeMultiDayAllDay,
|
|
|
|
"monthly": this._determineDragModeMonthly,
|
|
|
|
"unknown": null };
|
|
|
|
this._determineDragMode = methods[this.eventType];
|
|
|
|
},
|
|
|
|
|
|
|
|
_determineDragModeMultiDay: function SEDC__determineDragModeMultiDay() {
|
2010-02-11 03:36:43 +01:00
|
|
|
var dragMode;
|
|
|
|
|
|
|
|
if (this.eventCells) {
|
|
|
|
var coordinates = this.pointerHandler.currentCoordinates.clone();
|
|
|
|
var utilities = SOGoEventDragUtilities();
|
|
|
|
var scrollView = utilities.getEventsViewNode();
|
|
|
|
coordinates.y += scrollView.scrollTop;
|
|
|
|
coordinates.y -= SOGoEventDragVerticalOffset;
|
|
|
|
|
|
|
|
var firstCell = this.eventCells[0];
|
|
|
|
var handleCoords = firstCell.cumulativeOffset();
|
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
dragMode = "move-event";
|
2010-02-11 03:36:43 +01:00
|
|
|
if ((handleCoords[0] <= coordinates.x
|
|
|
|
&& coordinates.x <= handleCoords[0] + firstCell.clientWidth)
|
|
|
|
&& (handleCoords[1] <= coordinates.y
|
|
|
|
&& coordinates.y <= handleCoords[1] + SOGoEventDragHandleSize))
|
|
|
|
dragMode = "change-start";
|
|
|
|
else {
|
|
|
|
var lastCell = this.eventCells[this.eventCells.length-1];
|
|
|
|
handleCoords = lastCell.cumulativeOffset();
|
|
|
|
handleCoords[1] += (lastCell.clientHeight
|
|
|
|
- SOGoEventDragHandleSize - 1);
|
|
|
|
if ((handleCoords[0] <= coordinates.x
|
|
|
|
&& coordinates.x <= handleCoords[0] + lastCell.clientWidth)
|
|
|
|
&& (handleCoords[1] <= coordinates.y
|
|
|
|
&& coordinates.y <= handleCoords[1] + SOGoEventDragHandleSize))
|
|
|
|
dragMode = "change-end";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dragMode = "change-end";
|
|
|
|
}
|
|
|
|
|
|
|
|
return dragMode;
|
|
|
|
},
|
2010-02-11 20:48:09 +01:00
|
|
|
_determineDragModeMultiDayAllDay: function SEDC__detDMMultiDayAllDay() {
|
|
|
|
var dragMode;
|
|
|
|
|
|
|
|
if (this.eventCells) {
|
|
|
|
var coordinates = this.pointerHandler.currentCoordinates.clone();
|
|
|
|
coordinates.x -= SOGoEventDragHorizontalOffset;
|
|
|
|
coordinates.y -= SOGoEventDragVerticalOffset;
|
|
|
|
|
|
|
|
var firstCell = this.eventCells[0];
|
|
|
|
var handleCoords = firstCell.cumulativeOffset();
|
|
|
|
|
|
|
|
dragMode = "move-event";
|
|
|
|
if (handleCoords[0] <= coordinates.x
|
|
|
|
&& coordinates.x <= handleCoords[0] + SOGoEventDragHandleSize)
|
|
|
|
dragMode = "change-start";
|
|
|
|
else {
|
|
|
|
var lastCell = this.eventCells[this.eventCells.length-1];
|
|
|
|
handleCoords = lastCell.cumulativeOffset();
|
|
|
|
handleCoords[0] += lastCell.clientWidth;
|
|
|
|
if (handleCoords[0] - SOGoEventDragHandleSize <= coordinates.x
|
|
|
|
&& coordinates.x <= handleCoords[0])
|
|
|
|
dragMode = "change-end";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dragMode = "change-end";
|
|
|
|
}
|
|
|
|
|
|
|
|
return dragMode;
|
|
|
|
},
|
|
|
|
_determineDragModeMonthly: function SEDC__determineDragModeMultiDay() {
|
|
|
|
var dragMode;
|
|
|
|
|
|
|
|
if (this.eventCells) {
|
|
|
|
var coordinates = this.pointerHandler.currentCoordinates.clone();
|
|
|
|
coordinates.x -= SOGoEventDragHorizontalOffset;
|
|
|
|
coordinates.y -= SOGoEventDragVerticalOffset;
|
|
|
|
|
|
|
|
var firstCell = this.eventCells[0];
|
|
|
|
var handleCoords = firstCell.cumulativeOffset();
|
|
|
|
|
|
|
|
dragMode = "move-event";
|
|
|
|
var eventHeight = 16; /* arbitrary value */
|
|
|
|
|
|
|
|
if (handleCoords[1] <= coordinates.y
|
|
|
|
&& coordinates.y <= handleCoords[1] + eventHeight
|
|
|
|
&& handleCoords[0] <= coordinates.x
|
|
|
|
&& coordinates.x <= handleCoords[0] + SOGoEventDragHandleSize)
|
|
|
|
dragMode = "change-start";
|
|
|
|
else {
|
|
|
|
var lastCell = this.eventCells[this.eventCells.length-1];
|
|
|
|
handleCoords = lastCell.cumulativeOffset();
|
|
|
|
handleCoords[0] += lastCell.clientWidth;
|
|
|
|
if (handleCoords[1] <= coordinates.y
|
|
|
|
&& coordinates.y <= handleCoords[1] + eventHeight
|
|
|
|
&& handleCoords[0] - SOGoEventDragHandleSize <= coordinates.x
|
|
|
|
&& coordinates.x <= handleCoords[0])
|
|
|
|
dragMode = "change-end";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dragMode = "change-end";
|
|
|
|
}
|
|
|
|
|
|
|
|
return dragMode;
|
|
|
|
},
|
2010-02-11 03:36:43 +01:00
|
|
|
|
|
|
|
_determineTitleAndFolderClass: function SEDC__dTAFC() {
|
|
|
|
var title = "";
|
|
|
|
var folderClass = "";
|
2010-05-25 20:17:00 +02:00
|
|
|
var location = null;
|
2010-02-11 03:36:43 +01:00
|
|
|
if (this.eventCells) {
|
|
|
|
var firstCell = this.eventCells[0];
|
|
|
|
var divs = firstCell.childNodesWithTag("div");
|
|
|
|
for (var i = 0; i < divs.length; i++) {
|
|
|
|
var div = divs[i];
|
|
|
|
if (div.hasClassName("eventInside")) {
|
2010-05-25 20:17:00 +02:00
|
|
|
var titleDIV = this._determineTitleDIV(div);
|
|
|
|
if (titleDIV) {
|
|
|
|
title = this._determineTitleFromDIV(titleDIV);
|
|
|
|
location = this._determineLocationFromDIV(titleDIV);
|
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
folderClass = this._determineFolderClassFromDIV(div);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.title = title;
|
2010-05-25 20:17:00 +02:00
|
|
|
this.location = location;
|
2010-02-11 03:36:43 +01:00
|
|
|
this.folderClass = folderClass;
|
|
|
|
},
|
2010-05-25 20:17:00 +02:00
|
|
|
_determineTitleDIV: function SEDC__determineTitleDIV(div) {
|
|
|
|
var titleDIV = null;
|
2010-02-11 03:36:43 +01:00
|
|
|
var insideDivs = div.childNodesWithTag("div");
|
2010-05-25 20:17:00 +02:00
|
|
|
for (var i = 0; titleDIV == null && i < insideDivs.length; i++) {
|
2010-02-11 03:36:43 +01:00
|
|
|
var insideDiv = insideDivs[i];
|
|
|
|
if (insideDiv.hasClassName("text")) {
|
2010-05-25 20:17:00 +02:00
|
|
|
titleDIV = insideDiv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return titleDIV;
|
|
|
|
},
|
|
|
|
_determineTitleFromDIV: function SEDC__determineTitleFromDIV(titleDIV) {
|
|
|
|
var title = "";
|
|
|
|
|
|
|
|
var currentNode = titleDIV.firstChild;
|
|
|
|
while (currentNode) {
|
|
|
|
if (currentNode.nodeType == Node.TEXT_NODE) {
|
|
|
|
title += currentNode.nodeValue;
|
|
|
|
}
|
|
|
|
currentNode = currentNode.nextSibling;
|
|
|
|
}
|
|
|
|
|
|
|
|
return title.trim();
|
|
|
|
},
|
|
|
|
_determineLocationFromDIV: function SEDC__determineLocationFromDIV(titleDIV) {
|
|
|
|
var location = "";
|
|
|
|
|
|
|
|
var spans = titleDIV.select("span.location");
|
|
|
|
if (spans && spans.length > 0) {
|
|
|
|
var locationSPAN = spans[0];
|
|
|
|
var currentNode = locationSPAN.firstChild;
|
|
|
|
while (currentNode) {
|
|
|
|
if (currentNode.nodeType == Node.TEXT_NODE) {
|
|
|
|
location += currentNode.nodeValue;
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
2010-05-25 20:17:00 +02:00
|
|
|
currentNode = currentNode.nextSibling;
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-25 20:17:00 +02:00
|
|
|
return location.trim();
|
2010-02-11 03:36:43 +01:00
|
|
|
},
|
|
|
|
_determineFolderClassFromDIV: function SEDC__detFolderClassFromDIV(div) {
|
|
|
|
var folderClass = null;
|
|
|
|
|
|
|
|
var classes = div.className.split(" ");
|
|
|
|
for (var i = 0; folderClass == null && i < classes.length; i++) {
|
|
|
|
var currentClass = classes[i];
|
|
|
|
if (currentClass.startsWith("calendarFolder")) {
|
|
|
|
folderClass = currentClass;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return folderClass;
|
|
|
|
},
|
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
onDragStop: function SEDC_onDragStop(event) {
|
2010-02-11 03:36:43 +01:00
|
|
|
if (Prototype.Browser.IE)
|
2010-02-11 20:48:09 +01:00
|
|
|
Event.stopObserving(document.body, "mouseup", this.onDragStopBound);
|
2010-02-11 03:36:43 +01:00
|
|
|
else
|
2010-02-11 20:48:09 +01:00
|
|
|
Event.stopObserving(window, "mouseup", this.onDragStopBound);
|
|
|
|
Event.stopObserving(document.body, "mousemove", this.onDragModeBound);
|
|
|
|
this.onDragStopBound = null;
|
|
|
|
this.onDragModeBound = null;
|
2014-07-18 15:23:07 +02:00
|
|
|
$("DnDCalendarList").style.visibility = 'hidden';
|
|
|
|
this.leftPanelController.updateLeftPanelVisual.stop();
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
var utilities = SOGoEventDragUtilities();
|
2010-02-11 03:36:43 +01:00
|
|
|
if (this.dragHasStarted) {
|
|
|
|
this.ghostController.hideGhosts();
|
|
|
|
this.dragHasStarted = false;
|
|
|
|
|
|
|
|
if (this.eventCells) {
|
|
|
|
for (var i = 0; i < this.eventCells.length; i++) {
|
|
|
|
var currentCell = this.eventCells[i];
|
|
|
|
currentCell.removeClassName("dragging");
|
|
|
|
}
|
|
|
|
var delta = this.ghostController
|
|
|
|
.currentCoordinates
|
|
|
|
.getDelta(this.ghostController
|
|
|
|
.originalCoordinates);
|
2014-07-15 23:29:39 +02:00
|
|
|
|
2014-07-18 15:23:07 +02:00
|
|
|
if (this.leftPanelController.dropCalendar != null) {
|
2014-07-17 15:42:32 +02:00
|
|
|
$$('#calendarList li').each(function(e) {
|
|
|
|
e.removeClassName('genericHoverClass');
|
|
|
|
});
|
2014-07-16 16:30:48 +02:00
|
|
|
calendarID[0] = this.folderClass.substr(14);
|
2014-07-18 15:23:07 +02:00
|
|
|
calendarID[1] = this.leftPanelController.dropCalendar.getAttribute("id").substr(1);
|
2014-07-17 15:42:32 +02:00
|
|
|
delta.start = 0;
|
|
|
|
if (calendarID[0] != calendarID[1])
|
|
|
|
this.updateDropCallback(this, this.eventCells, delta, calendarID);
|
2014-07-15 23:29:39 +02:00
|
|
|
}
|
|
|
|
else if (currentView == "multicolumndayview" && delta.dayNumber != 0) {
|
2014-07-16 16:30:48 +02:00
|
|
|
var position = activeCalendars.indexOf(calendarID[0]);
|
|
|
|
position += delta.dayNumber;
|
|
|
|
calendarID[1] = activeCalendars[position];
|
|
|
|
this.updateDropCallback(this, this.eventCells, delta, calendarID);
|
2014-07-09 22:47:13 +02:00
|
|
|
}
|
|
|
|
else
|
2014-07-16 16:30:48 +02:00
|
|
|
this.updateDropCallback(this, this.eventCells, delta, 0);
|
2010-02-11 03:36:43 +01:00
|
|
|
} else {
|
2010-02-11 20:48:09 +01:00
|
|
|
var eventContainerNodes = utilities.getEventContainerNodes();
|
|
|
|
var dayNode = eventContainerNodes[this.ghostController
|
|
|
|
.currentCoordinates
|
|
|
|
.dayNumber];
|
|
|
|
if (dayNode.hasClassName("events"))
|
|
|
|
dayNode = dayNode.parentNode;
|
2010-02-11 03:36:43 +01:00
|
|
|
this.createDropCallback(this,
|
|
|
|
dayNode.readAttribute("day"),
|
|
|
|
this.ghostController.currentCoordinates);
|
|
|
|
}
|
|
|
|
}
|
2010-02-13 00:24:24 +01:00
|
|
|
utilities.reset();
|
2010-02-11 03:36:43 +01:00
|
|
|
|
|
|
|
Event.stop(event);
|
|
|
|
},
|
|
|
|
|
|
|
|
_coordinateToTime: function SEDC_coordinateToTime(coordinate) {
|
|
|
|
var hours = Math.floor(coordinate / 4);
|
|
|
|
var minutes = (coordinate % 4) * 15;
|
|
|
|
if (minutes < 10)
|
|
|
|
minutes = "0" + minutes;
|
|
|
|
var time = hours + ":" + minutes;
|
|
|
|
|
|
|
|
return time;
|
|
|
|
},
|
|
|
|
|
2010-02-11 20:48:09 +01:00
|
|
|
onDragMode: function SEDC_onDragMode(event) {
|
2014-07-16 16:30:48 +02:00
|
|
|
this.pointerHandler.updateFromEvent(event);
|
|
|
|
if (this.scrollController)
|
|
|
|
this.scrollController.updateFromPointerHandler();
|
|
|
|
|
|
|
|
if (this.dragHasStarted) {
|
|
|
|
var newCoordinates = this.ghostController.pointerHandler.getEventViewCoordinates();
|
2014-07-17 15:42:32 +02:00
|
|
|
if (newCoordinates == null && this.leftPanelController != null) {
|
2014-07-18 15:23:07 +02:00
|
|
|
if (this.ghostController.ghosts) {
|
2014-07-16 16:30:48 +02:00
|
|
|
this.ghostController.hideGhosts();
|
2014-07-18 15:23:07 +02:00
|
|
|
$("DnDCalendarList").style.visibility = 'visible';
|
|
|
|
this.leftPanelController.updateLeftPanelVisual.start();
|
|
|
|
|
|
|
|
}
|
2014-07-16 16:30:48 +02:00
|
|
|
this.leftPanelController.updateFromPointerHandler();
|
|
|
|
}
|
|
|
|
else {
|
2014-07-18 15:23:07 +02:00
|
|
|
if (this.ghostController.ghosts == null) {
|
2014-07-16 16:30:48 +02:00
|
|
|
this.ghostController.showGhosts();
|
2014-07-18 15:23:07 +02:00
|
|
|
$("DnDCalendarList").style.visibility = 'hidden';
|
|
|
|
this.leftPanelController.updateLeftPanelVisual.stop();
|
|
|
|
}
|
2014-07-16 16:30:48 +02:00
|
|
|
this.ghostController.updateFromPointerHandler();
|
|
|
|
}
|
2014-07-15 23:29:39 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-07-16 16:30:48 +02:00
|
|
|
var distance = this.pointerHandler.getDistance();
|
|
|
|
if (distance > 3) {
|
|
|
|
$("eventDialog").hide();
|
|
|
|
this.dragHasStarted = true;
|
|
|
|
if (this.eventCells) {
|
|
|
|
for (var i = 0; i < this.eventCells.length; i++) {
|
|
|
|
var currentCell = this.eventCells[i];
|
|
|
|
currentCell.addClassName("dragging");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.ghostController.showGhosts();
|
|
|
|
this.ghostController.updateFromPointerHandler();
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
}
|
2014-07-16 16:30:48 +02:00
|
|
|
Event.stop(event);
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
};
|