mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-10-12 15:27:12 +00:00
Monotone-Parent: ebe63ce53628359dd83606f2bb756f112a053f66
Monotone-Revision: 49a09455a4649cc47dfc143047a9635ce2974e57 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-02-11T19:48:09 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
1 parent
d8a541ab8d
commit
dab684f8aa
6 files changed
+608
-193
No files matched your search
@@ -1,3 +1,15 @@
|
|||||||
|
2010-02-11 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* UI/WebServerResources/SchedulerUIDnD.js: adapted code for
|
||||||
|
all-day events and monthly view. Added code to avoid modifying
|
||||||
|
events when the pointer is out of the draggable zone.
|
||||||
|
|
||||||
|
* UI/WebServerResources/SchedulerUI.js: adapted code for
|
||||||
|
all-day events and monthly view.
|
||||||
|
|
||||||
|
* UI/Scheduler/UIxAppointmentActions.m (-adjustAction): we now
|
||||||
|
handle all-day events.
|
||||||
|
|
||||||
2010-02-10 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2010-02-10 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
* UI/WebServerResources/SOGoRootPage.js (initLogin): discard the
|
* UI/WebServerResources/SOGoRootPage.js (initLogin): discard the
|
||||||
|
|||||||
@@ -67,20 +67,34 @@
|
|||||||
tz = [ud timeZone];
|
tz = [ud timeZone];
|
||||||
start = [event startDate];
|
start = [event startDate];
|
||||||
[start setTimeZone: tz];
|
[start setTimeZone: tz];
|
||||||
|
|
||||||
newStart = [start dateByAddingYears: 0 months: 0
|
|
||||||
days: [daysDelta intValue]
|
|
||||||
hours: 0 minutes: [startDelta intValue]
|
|
||||||
seconds: 0];
|
|
||||||
end = [event endDate];
|
end = [event endDate];
|
||||||
[end setTimeZone: tz];
|
[end setTimeZone: tz];
|
||||||
|
|
||||||
newDuration = ([end timeIntervalSinceDate: start]
|
if ([event isAllDay])
|
||||||
+ [durationDelta intValue] * 60);
|
{
|
||||||
newEnd = [newStart addTimeInterval: newDuration];
|
newStart = [start dateByAddingYears: 0 months: 0
|
||||||
|
days: [daysDelta intValue]
|
||||||
|
hours: 0 minutes: 0
|
||||||
|
seconds: 0];
|
||||||
|
newDuration = (((float) abs ([end timeIntervalSinceDate: start])
|
||||||
|
+ [durationDelta intValue] * 60)
|
||||||
|
/ 86400);
|
||||||
|
[event setAllDayWithStartDate: newStart duration: newDuration];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newStart = [start dateByAddingYears: 0 months: 0
|
||||||
|
days: [daysDelta intValue]
|
||||||
|
hours: 0 minutes: [startDelta intValue]
|
||||||
|
seconds: 0];
|
||||||
|
|
||||||
[event setStartDate: newStart];
|
newDuration = ([end timeIntervalSinceDate: start]
|
||||||
[event setEndDate: newEnd];
|
+ [durationDelta intValue] * 60);
|
||||||
|
newEnd = [newStart addTimeInterval: newDuration];
|
||||||
|
|
||||||
|
[event setStartDate: newStart];
|
||||||
|
[event setEndDate: newEnd];
|
||||||
|
}
|
||||||
[co saveComponent: event];
|
[co saveComponent: event];
|
||||||
|
|
||||||
response = [self responseWith204];
|
response = [self responseWith204];
|
||||||
|
|||||||
@@ -555,6 +555,7 @@ DIV.dayOfAnotherMonth
|
|||||||
|
|
||||||
DIV.monthView DIV.dayHeader
|
DIV.monthView DIV.dayHeader
|
||||||
{ margin-right: 0px;
|
{ margin-right: 0px;
|
||||||
|
height: 16px;
|
||||||
padding-right: 2px;
|
padding-right: 2px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@@ -854,34 +855,6 @@ DIV.events > DIV.event
|
|||||||
margin-top: 0px;
|
margin-top: 0px;
|
||||||
padding: 1px; }
|
padding: 1px; }
|
||||||
|
|
||||||
DIV.event DIV.topDragGrip,
|
|
||||||
DIV.event DIV.bottomDragGrip
|
|
||||||
{ position: absolute;
|
|
||||||
border: 0px;
|
|
||||||
left: 1px;
|
|
||||||
right: 1px;
|
|
||||||
height: 4px;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: center; }
|
|
||||||
|
|
||||||
DIV.event.dragging DIV.topDragGrip,
|
|
||||||
DIV.event.dragging DIV.bottomDragGrip
|
|
||||||
{ display: none; }
|
|
||||||
|
|
||||||
DIV.event DIV.topDragGrip
|
|
||||||
{ top: 1px; }
|
|
||||||
|
|
||||||
DIV.event.draggable:hover DIV.topDragGrip
|
|
||||||
{ cursor: n-resize;
|
|
||||||
background-image: url(event-grippy-top.png); }
|
|
||||||
|
|
||||||
DIV.event DIV.bottomDragGrip
|
|
||||||
{ bottom: 1px; }
|
|
||||||
|
|
||||||
DIV.event.draggable:hover DIV.bottomDragGrip
|
|
||||||
{ cursor: s-resize;
|
|
||||||
background-image: url(event-grippy-bottom.png); }
|
|
||||||
|
|
||||||
DIV.event > DIV.eventInside
|
DIV.event > DIV.eventInside
|
||||||
{ position: absolute;
|
{ position: absolute;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@@ -946,6 +919,61 @@ DIV.event.alarm DIV.text
|
|||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: top right; }
|
background-position: top right; }
|
||||||
|
|
||||||
|
/* event DnD */
|
||||||
|
DIV.event DIV.topDragGrip,
|
||||||
|
DIV.event DIV.bottomDragGrip
|
||||||
|
{ position: absolute;
|
||||||
|
border: 0px;
|
||||||
|
left: 1px;
|
||||||
|
right: 1px;
|
||||||
|
height: 4px;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: center; }
|
||||||
|
|
||||||
|
DIV.event DIV.topDragGrip
|
||||||
|
{ top: 1px; }
|
||||||
|
|
||||||
|
DIV.event DIV.bottomDragGrip
|
||||||
|
{ bottom: 1px; }
|
||||||
|
|
||||||
|
DIV.event DIV.leftDragGrip,
|
||||||
|
DIV.event DIV.rightDragGrip
|
||||||
|
{ position: absolute;
|
||||||
|
border: 0px;
|
||||||
|
top: 3px;
|
||||||
|
height: 11px;
|
||||||
|
width: 3px;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: center; }
|
||||||
|
|
||||||
|
DIV.event DIV.leftDragGrip
|
||||||
|
{ left: 1px; }
|
||||||
|
|
||||||
|
DIV.event DIV.rightDragGrip
|
||||||
|
{ right: 1px; }
|
||||||
|
|
||||||
|
DIV.event.dragging DIV.topDragGrip,
|
||||||
|
DIV.event.dragging DIV.bottomDragGrip,
|
||||||
|
DIV.event.dragging DIV.leftDragGrip,
|
||||||
|
DIV.event.dragging DIV.rightDragGrip
|
||||||
|
{ display: none; }
|
||||||
|
|
||||||
|
DIV.event.draggable:hover DIV.topDragGrip
|
||||||
|
{ cursor: n-resize;
|
||||||
|
background-image: url(event-grippy-top.png); }
|
||||||
|
|
||||||
|
DIV.event.draggable:hover DIV.bottomDragGrip
|
||||||
|
{ cursor: s-resize;
|
||||||
|
background-image: url(event-grippy-bottom.png); }
|
||||||
|
|
||||||
|
DIV.event.draggable:hover DIV.leftDragGrip
|
||||||
|
{ cursor: w-resize;
|
||||||
|
background-image: url(event-grippy-vertical.png); }
|
||||||
|
|
||||||
|
DIV.event.draggable:hover DIV.rightDragGrip
|
||||||
|
{ cursor: e-resize;
|
||||||
|
background-image: url(event-grippy-vertical.png); }
|
||||||
|
|
||||||
DIV.event.dragging
|
DIV.event.dragging
|
||||||
{ left: 0px !important;
|
{ left: 0px !important;
|
||||||
width: 100% !important; }
|
width: 100% !important; }
|
||||||
@@ -962,19 +990,43 @@ DIV.event.dragging DIV.text
|
|||||||
DIV.event.dragging IMG
|
DIV.event.dragging IMG
|
||||||
{ display: none; }
|
{ display: none; }
|
||||||
|
|
||||||
DIV.eventDragGhost
|
#daysView DIV.eventDragGhost
|
||||||
{ border-top: 0px;
|
{ color: #fff;
|
||||||
color: #fff;
|
border-top: 0px;
|
||||||
border-bottom: 0px;
|
border-bottom: 0px;
|
||||||
border-left: 1px solid #555;
|
border-left: 1px solid #555;
|
||||||
border-right: 1px solid #555; }
|
border-right: 1px solid #555; }
|
||||||
|
|
||||||
DIV.eventDragGhost.startGhost
|
#daysView DIV.eventDragGhost.startGhost
|
||||||
{ border-top: 1px solid #555; }
|
{ border-top: 1px solid #555; }
|
||||||
|
|
||||||
DIV.eventDragGhost.endGhost
|
#daysView DIV.eventDragGhost.endGhost
|
||||||
{ border-bottom: 1px solid #555; }
|
{ border-bottom: 1px solid #555; }
|
||||||
|
|
||||||
|
#monthDaysView DIV.eventDragGhost,
|
||||||
|
#calendarHeader DIV.eventDragGhost
|
||||||
|
{ position: absolute !important;
|
||||||
|
color: #fff;
|
||||||
|
width: 100%;
|
||||||
|
border-top: 1px solid #555;
|
||||||
|
border-bottom: 1px solid #555;
|
||||||
|
border-left: 0px;
|
||||||
|
border-right: 0px; }
|
||||||
|
|
||||||
|
#monthDaysView DIV.eventDragGhost
|
||||||
|
{ top: 16px; }
|
||||||
|
|
||||||
|
#calendarHeader DIV.eventDragGhost
|
||||||
|
{ top: 0px; }
|
||||||
|
|
||||||
|
#monthDaysView DIV.eventDragGhost.startGhost,
|
||||||
|
#calendarHeader DIV.eventDragGhost.startGhost
|
||||||
|
{ border-left: 1px solid #555; }
|
||||||
|
|
||||||
|
#monthDaysView DIV.eventDragGhost.endGhost,
|
||||||
|
#calendarHeader DIV.eventDragGhost.endGhost
|
||||||
|
{ border-right: 1px solid #555; }
|
||||||
|
|
||||||
DIV.eventDragGhost > DIV
|
DIV.eventDragGhost > DIV
|
||||||
{ position: absolute;
|
{ position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -64,7 +64,11 @@ function minutesToHM(minutes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function newEventFromDragging(controller, day, coordinates) {
|
function newEventFromDragging(controller, day, coordinates) {
|
||||||
var startHm = minutesToHM(coordinates.start * 15);
|
var startHm;
|
||||||
|
if (controller.eventType == "multiday")
|
||||||
|
startHm = minutesToHM(coordinates.start * 15);
|
||||||
|
else
|
||||||
|
startHm = "allday";
|
||||||
var lengthHm = minutesToHM(coordinates.duration * 15);
|
var lengthHm = minutesToHM(coordinates.duration * 15);
|
||||||
newEvent("event", day, startHm, lengthHm);
|
newEvent("event", day, startHm, lengthHm);
|
||||||
}
|
}
|
||||||
@@ -1180,14 +1184,6 @@ function _setupEventsDragAndDrop(events) {
|
|||||||
var occurrences = calendarEvents[calendar][cname];
|
var occurrences = calendarEvents[calendar][cname];
|
||||||
for (var j = 0; j < occurrences.length; j++) {
|
for (var j = 0; j < occurrences.length; j++) {
|
||||||
var blocks = occurrences[j].blocks;
|
var blocks = occurrences[j].blocks;
|
||||||
var topDragGrip = $(document.createElement("div"));
|
|
||||||
topDragGrip.addClassName("topDragGrip");
|
|
||||||
blocks[0].appendChild(topDragGrip);
|
|
||||||
|
|
||||||
var bottomDragGrip = $(document.createElement("div"));
|
|
||||||
bottomDragGrip.addClassName("bottomDragGrip");
|
|
||||||
blocks[blocks.length-1].appendChild(bottomDragGrip);
|
|
||||||
|
|
||||||
var dragController = new SOGoEventDragController();
|
var dragController = new SOGoEventDragController();
|
||||||
dragController.updateDropCallback = updateEventFromDragging;
|
dragController.updateDropCallback = updateEventFromDragging;
|
||||||
dragController.attachToEventCells(blocks);
|
dragController.attachToEventCells(blocks);
|
||||||
@@ -1209,8 +1205,8 @@ function refreshCalendarEventsCallback(http) {
|
|||||||
else {
|
else {
|
||||||
_drawCalendarAllDayEvents(eventsBlocks[1], eventsBlocks[0]);
|
_drawCalendarAllDayEvents(eventsBlocks[1], eventsBlocks[0]);
|
||||||
_drawCalendarEvents(eventsBlocks[2], eventsBlocks[0]);
|
_drawCalendarEvents(eventsBlocks[2], eventsBlocks[0]);
|
||||||
_setupEventsDragAndDrop(eventsBlocks[0]);
|
|
||||||
}
|
}
|
||||||
|
_setupEventsDragAndDrop(eventsBlocks[0]);
|
||||||
onWindowResize(null);
|
onWindowResize(null);
|
||||||
}
|
}
|
||||||
if (http.callbackData["scrollEvent"])
|
if (http.callbackData["scrollEvent"])
|
||||||
@@ -1327,10 +1323,6 @@ function _drawCalendarEvents(events, eventsData) {
|
|||||||
var nbr = eventRep.nbr;
|
var nbr = eventRep.nbr;
|
||||||
var eventCell = newEventDIV(eventRep, eventsData[nbr]);
|
var eventCell = newEventDIV(eventRep, eventsData[nbr]);
|
||||||
parentDiv.appendChild(eventCell);
|
parentDiv.appendChild(eventCell);
|
||||||
|
|
||||||
if (eventCell.editable) {
|
|
||||||
eventCell.addClassName("draggable");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1376,19 +1368,13 @@ function newMonthEventDIV(eventRep, event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function attachDragControllers(contentView) {
|
function attachDragControllers(contentView) {
|
||||||
var contentNodes = contentView.childNodesWithTag("div");
|
var dayNodes = contentView.select("DIV.day");
|
||||||
for (var i = 0; i < contentNodes.length; i++) {
|
for (var j = 0; j < dayNodes.length; j++) {
|
||||||
var contentNode = contentNodes[i];
|
var dayNode = dayNodes[j];
|
||||||
if (contentNode.hasClassName("days")) {
|
if (dayNode.hasClassName("day")) {
|
||||||
var dayNodes = contentNode.childNodesWithTag("div");
|
var dragController = new SOGoEventDragController();
|
||||||
for (var j = 0; j < dayNodes.length; j++) {
|
dragController.createDropCallback = newEventFromDragging;
|
||||||
var dayNode = dayNodes[j];
|
dragController.attachToDayNode(dayNode);
|
||||||
if (dayNode.hasClassName("day")) {
|
|
||||||
var dragController = new SOGoEventDragController();
|
|
||||||
dragController.createDropCallback = newEventFromDragging;
|
|
||||||
dragController.attachToDayNode(dayNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1460,9 +1446,10 @@ function calendarDisplayCallback(http) {
|
|||||||
contentView = $("calendarContent");
|
contentView = $("calendarContent");
|
||||||
else {
|
else {
|
||||||
contentView = $("daysView");
|
contentView = $("daysView");
|
||||||
attachDragControllers(contentView);
|
|
||||||
contentView.observe("scroll", onBodyClickHandler);
|
contentView.observe("scroll", onBodyClickHandler);
|
||||||
|
attachDragControllers($("calendarHeader"));
|
||||||
}
|
}
|
||||||
|
attachDragControllers(contentView);
|
||||||
|
|
||||||
refreshCalendarEvents(http.callbackData.scrollEvent);
|
refreshCalendarEvents(http.callbackData.scrollEvent);
|
||||||
|
|
||||||
|
|||||||
@@ -18,31 +18,49 @@ function _SOGoEventDragUtilities() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_SOGoEventDragUtilities.prototype = {
|
_SOGoEventDragUtilities.prototype = {
|
||||||
dayEventNodes: null,
|
eventType: null,
|
||||||
|
eventContainerNodes: null,
|
||||||
|
_prepareEventContainerNodes: null,
|
||||||
quarterHeight: -1,
|
quarterHeight: -1,
|
||||||
dayWidth: -1,
|
dayWidth: -1,
|
||||||
|
dayHeight: -1,
|
||||||
daysOffset: -1,
|
daysOffset: -1,
|
||||||
eventsViewNode: null,
|
eventsViewNode: null,
|
||||||
eventsViewNodeCumulativeCoordinates: null,
|
eventsViewNodeCumulativeCoordinates: null,
|
||||||
|
|
||||||
reset: function() {
|
reset: function() {
|
||||||
this.dayEventNodes = null;
|
this.eventContainerNodes = null;
|
||||||
|
this._prepareEventContainerNodes = null;
|
||||||
this.quarterHeight = -1;
|
this.quarterHeight = -1;
|
||||||
this.dayWidth = -1;
|
this.dayWidth = -1;
|
||||||
|
this.dayHeight = -1;
|
||||||
this.daysOffset = -1;
|
this.daysOffset = -1;
|
||||||
this.eventsViewNode = null;
|
this.eventsViewNode = null;
|
||||||
this.eventsViewNodeCumulativeCoordinates = null;
|
this.eventsViewNodeCumulativeCoordinates = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
getDayEventNodes: function() {
|
setEventType: function(eventType) {
|
||||||
if (!this.dayEventNodes)
|
var prepareMethods
|
||||||
this._initDayEventNodes();
|
= { "multiday": this._prepareEventMultiDayContainerNodes,
|
||||||
|
"multiday-allday": this._prepareEventMultiDayAllDayContainerNodes,
|
||||||
return this.dayEventNodes;
|
"monthly": this._prepareEventMonthlyContainerNodes,
|
||||||
|
"unknown": null };
|
||||||
|
this._prepareEventContainerNodes = prepareMethods[eventType];
|
||||||
|
this.eventType = eventType;
|
||||||
|
},
|
||||||
|
getEventType: function(eventType) {
|
||||||
|
return this.eventType;
|
||||||
},
|
},
|
||||||
_initDayEventNodes: function() {
|
|
||||||
this.dayEventNodes = [];
|
|
||||||
|
|
||||||
|
getEventContainerNodes: function() {
|
||||||
|
if (!this.eventContainerNodes) {
|
||||||
|
this._prepareEventContainerNodes();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.eventContainerNodes;
|
||||||
|
},
|
||||||
|
_prepareEventMultiDayContainerNodes: function() {
|
||||||
|
this.eventContainerNodes = [];
|
||||||
var daysView = $("daysView");
|
var daysView = $("daysView");
|
||||||
var daysViewSubnodes = daysView.childNodesWithTag("div");
|
var daysViewSubnodes = daysView.childNodesWithTag("div");
|
||||||
for (var i = 0; i < daysViewSubnodes.length; i++) {
|
for (var i = 0; i < daysViewSubnodes.length; i++) {
|
||||||
@@ -59,12 +77,35 @@ _SOGoEventDragUtilities.prototype = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
_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;
|
||||||
|
},
|
||||||
|
|
||||||
_appendDayEventsNode: function(dayNode) {
|
_appendDayEventsNode: function(dayNode) {
|
||||||
var daySubnodes = dayNode.childNodesWithTag("div");
|
var daySubnodes = dayNode.childNodesWithTag("div");
|
||||||
for (var i = 0; i < daySubnodes.length; i++) {
|
for (var i = 0; i < daySubnodes.length; i++) {
|
||||||
var daySubnode = daySubnodes[i];
|
var daySubnode = daySubnodes[i];
|
||||||
if (daySubnode.hasClassName("events")) {
|
if (daySubnode.hasClassName("events")) {
|
||||||
this.dayEventNodes.push(daySubnode);
|
this.eventContainerNodes.push(daySubnode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -82,18 +123,24 @@ _SOGoEventDragUtilities.prototype = {
|
|||||||
|
|
||||||
getDaysOffset: function() {
|
getDaysOffset: function() {
|
||||||
if (this.daysOffset == -1)
|
if (this.daysOffset == -1)
|
||||||
this._initDayEventNodes();
|
this._prepareEventContainerNodes();
|
||||||
|
|
||||||
return this.daysOffset;
|
return this.daysOffset;
|
||||||
},
|
},
|
||||||
|
|
||||||
getDayWidth: function() {
|
getDayWidth: function() {
|
||||||
if (this.dayWidth == -1) {
|
if (this.dayWidth == -1) {
|
||||||
var nodes = this.getDayEventNodes();
|
var nodes = this.getEventContainerNodes();
|
||||||
if (nodes.length > 1) {
|
if (nodes.length > 1) {
|
||||||
var total = (nodes[nodes.length-1].cumulativeOffset()[0]
|
if (this.eventType == "monthly") {
|
||||||
- nodes[0].cumulativeOffset()[0]);
|
var total = (nodes[6].cumulativeOffset()[0]
|
||||||
this.dayWidth = total / (nodes.length - 1);
|
- 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this.dayWidth = nodes[0].offsetWidth;
|
this.dayWidth = nodes[0].offsetWidth;
|
||||||
@@ -102,9 +149,30 @@ _SOGoEventDragUtilities.prototype = {
|
|||||||
return this.dayWidth;
|
return this.dayWidth;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
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;
|
||||||
|
},
|
||||||
|
|
||||||
getEventsViewNode: function() {
|
getEventsViewNode: function() {
|
||||||
if (!this.eventsViewNode)
|
if (!this.eventsViewNode) {
|
||||||
this.eventsViewNode = $("daysView");
|
if (this.eventType.startsWith("multiday"))
|
||||||
|
this.eventsViewNode = $("daysView");
|
||||||
|
else if (this.eventType.startsWith("multiday-allday")) {
|
||||||
|
this.eventsViewNode = $("calendarHeader");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.eventsViewNode = $("monthDaysView");
|
||||||
|
}
|
||||||
return this.eventsViewNode;
|
return this.eventsViewNode;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -129,7 +197,22 @@ SOGoEventDragEventCoordinates.prototype = {
|
|||||||
start: -1,
|
start: -1,
|
||||||
duration: -1,
|
duration: -1,
|
||||||
|
|
||||||
initFromEventCell: function(eventCell) {
|
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) {
|
||||||
var classNames = eventCell.className.split(" ");
|
var classNames = eventCell.className.split(" ");
|
||||||
for (var i = 0;
|
for (var i = 0;
|
||||||
(this.start == -1 || this.duration == -1)
|
(this.start == -1 || this.duration == -1)
|
||||||
@@ -154,11 +237,57 @@ SOGoEventDragEventCoordinates.prototype = {
|
|||||||
}
|
}
|
||||||
this.dayNumber = dayNumber;
|
this.dayNumber = dayNumber;
|
||||||
},
|
},
|
||||||
|
initFromEventCellMultiDayAllDay: function(eventCell) {
|
||||||
|
this.start = 0;
|
||||||
|
this.duration = SOGoEventDragDayLength;
|
||||||
|
|
||||||
|
var dayNode = eventCell.parentNode;
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
},
|
||||||
|
|
||||||
initFromEventCells: function(eventCells) {
|
initFromEventCells: function(eventCells) {
|
||||||
this.duration = 0;
|
this.duration = 0;
|
||||||
for (var i = 0; i < eventCells.length; i++) {
|
for (var i = 0; i < eventCells.length; i++) {
|
||||||
var current = new SOGoEventDragEventCoordinates();
|
var current = new SOGoEventDragEventCoordinates();
|
||||||
|
current.setEventType(this.eventType);
|
||||||
current.initFromEventCell(eventCells[i]);
|
current.initFromEventCell(eventCells[i]);
|
||||||
if (this.dayNumber == -1 || current.dayNumber < this.dayNumber) {
|
if (this.dayNumber == -1 || current.dayNumber < this.dayNumber) {
|
||||||
this.dayNumber = current.dayNumber;
|
this.dayNumber = current.dayNumber;
|
||||||
@@ -253,16 +382,20 @@ var SOGoDragGhostInterface = {
|
|||||||
|
|
||||||
setStart: function SDGI_setStart(start) {
|
setStart: function SDGI_setStart(start) {
|
||||||
if (this.currentStart != start) {
|
if (this.currentStart != start) {
|
||||||
this.removeClassName("starts" + this.currentStart);
|
if (this.cssHandlesPosition)
|
||||||
|
this.removeClassName("starts" + this.currentStart);
|
||||||
this.currentStart = start;
|
this.currentStart = start;
|
||||||
this.addClassName("starts" + this.currentStart);
|
if (this.cssHandlesPosition)
|
||||||
|
this.addClassName("starts" + this.currentStart);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setDuration: function SDGI_setDuration(duration) {
|
setDuration: function SDGI_setDuration(duration) {
|
||||||
if (this.currentDuration != duration) {
|
if (this.currentDuration != duration) {
|
||||||
this.removeClassName("lasts" + this.currentDuration);
|
if (this.cssHandlesPosition)
|
||||||
|
this.removeClassName("lasts" + this.currentDuration);
|
||||||
this.currentDuration = duration;
|
this.currentDuration = duration;
|
||||||
this.addClassName("lasts" + this.currentDuration);
|
if (this.cssHandlesPosition)
|
||||||
|
this.addClassName("lasts" + this.currentDuration);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -336,14 +469,19 @@ SOGoEventDragGhostController.prototype = {
|
|||||||
updateFromPointerHandler: function SEDGC_updateFromPointerHandler() {
|
updateFromPointerHandler: function SEDGC_updateFromPointerHandler() {
|
||||||
var newCoordinates = this.pointerHandler.getEventViewCoordinates();
|
var newCoordinates = this.pointerHandler.getEventViewCoordinates();
|
||||||
if (!this.currentPointerCoordinates
|
if (!this.currentPointerCoordinates
|
||||||
|
|| !newCoordinates
|
||||||
|| newCoordinates.x != this.currentPointerCoordinates.x
|
|| newCoordinates.x != this.currentPointerCoordinates.x
|
||||||
|| newCoordinates.y != this.currentPointerCoordinates.y) {
|
|| newCoordinates.y != this.currentPointerCoordinates.y) {
|
||||||
this.currentPointerCoordinates = newCoordinates;
|
this.currentPointerCoordinates = newCoordinates;
|
||||||
if (this.originalPointerCoordinates) {
|
if (this.originalPointerCoordinates) {
|
||||||
|
if (!newCoordinates)
|
||||||
|
this.currentPointerCoordinates
|
||||||
|
= this.originalPointerCoordinates.clone();
|
||||||
this._updateCoordinates();
|
this._updateCoordinates();
|
||||||
if (this.ghosts) {
|
if (this.ghosts) {
|
||||||
this._updateGhosts();
|
this._updateGhosts();
|
||||||
this._updateGhostsParas();
|
if (this.startHourPara)
|
||||||
|
this._updateGhostsParas();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -355,11 +493,14 @@ SOGoEventDragGhostController.prototype = {
|
|||||||
var deltaQuarters = delta.x * SOGoEventDragDayLength + delta.y;
|
var deltaQuarters = delta.x * SOGoEventDragDayLength + delta.y;
|
||||||
this.currentCoordinates.dayNumber = this.originalCoordinates.dayNumber;
|
this.currentCoordinates.dayNumber = this.originalCoordinates.dayNumber;
|
||||||
|
|
||||||
|
// log("dragMode: " + this.dragMode);
|
||||||
if (this.dragMode == "move-event") {
|
if (this.dragMode == "move-event") {
|
||||||
this.currentCoordinates.start
|
this.currentCoordinates.start
|
||||||
= this.originalCoordinates.start + deltaQuarters;
|
= this.originalCoordinates.start + deltaQuarters;
|
||||||
this.currentCoordinates.duration
|
this.currentCoordinates.duration
|
||||||
= this.originalCoordinates.duration;
|
= this.originalCoordinates.duration;
|
||||||
|
// log("start: " + this.currentCoordinates.start);
|
||||||
|
// log(" duration: " + this.currentCoordinates.duration);
|
||||||
} else {
|
} else {
|
||||||
if (this.dragMode == "change-start") {
|
if (this.dragMode == "change-start") {
|
||||||
var newDuration = this.originalCoordinates.duration - deltaQuarters;
|
var newDuration = this.originalCoordinates.duration - deltaQuarters;
|
||||||
@@ -403,31 +544,36 @@ SOGoEventDragGhostController.prototype = {
|
|||||||
if (!this.ghosts) {
|
if (!this.ghosts) {
|
||||||
this.ghosts = [];
|
this.ghosts = [];
|
||||||
var utilities = SOGoEventDragUtilities();
|
var utilities = SOGoEventDragUtilities();
|
||||||
var nodes = utilities.getDayEventNodes();
|
var nodes = utilities.getEventContainerNodes();
|
||||||
|
var isMultiday = (utilities.getEventType() == "multiday");
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
var newGhost = $(document.createElement("div"));
|
var newGhost = $(document.createElement("div"));
|
||||||
Object.extend(newGhost, SOGoDragGhostInterface);
|
Object.extend(newGhost, SOGoDragGhostInterface);
|
||||||
newGhost.className = "event eventDragGhost";
|
newGhost.className = "event eventDragGhost";
|
||||||
|
newGhost.cssHandlesPosition = isMultiday;
|
||||||
newGhost.hide();
|
newGhost.hide();
|
||||||
nodes[i].appendChild(newGhost);
|
nodes[i].appendChild(newGhost);
|
||||||
this.ghosts.push(newGhost);
|
this.ghosts.push(newGhost);
|
||||||
}
|
}
|
||||||
var ghostHourPara = $(document.createElement("div"));
|
if (isMultiday) {
|
||||||
ghostHourPara.setAttribute("id", "ghostStartHour");
|
var ghostHourPara = $(document.createElement("div"));
|
||||||
this.startHourPara = ghostHourPara;
|
ghostHourPara.setAttribute("id", "ghostStartHour");
|
||||||
ghostHourPara = $(document.createElement("div"));
|
this.startHourPara = ghostHourPara;
|
||||||
ghostHourPara.setAttribute("id", "ghostEndHour");
|
ghostHourPara = $(document.createElement("div"));
|
||||||
this.endHourPara = ghostHourPara;
|
ghostHourPara.setAttribute("id", "ghostEndHour");
|
||||||
|
this.endHourPara = ghostHourPara;
|
||||||
|
}
|
||||||
this._updateGhosts();
|
this._updateGhosts();
|
||||||
this._updateGhostsParas();
|
if (this.startHourPara)
|
||||||
|
this._updateGhostsParas();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hideGhosts: function SEDGC_hideGhosts() {
|
hideGhosts: function SEDGC_hideGhosts() {
|
||||||
if (this.ghosts) {
|
if (this.ghosts) {
|
||||||
if (this.startHourPara.parentNode)
|
if (this.startHourPara && this.startHourPara.parentNode)
|
||||||
this.startHourPara.parentNode.removeChild(this.startHourPara);
|
this.startHourPara.parentNode.removeChild(this.startHourPara);
|
||||||
this.startHourPara = null;
|
this.startHourPara = null;
|
||||||
if (this.endHourPara.parentNode)
|
if (this.endHourPara && this.endHourPara.parentNode)
|
||||||
this.endHourPara.parentNode.removeChild(this.endHourPara);
|
this.endHourPara.parentNode.removeChild(this.endHourPara);
|
||||||
this.endHourPara = null;
|
this.endHourPara = null;
|
||||||
for (var i = 0; i < this.ghosts.length; i++) {
|
for (var i = 0; i < this.ghosts.length; i++) {
|
||||||
@@ -449,7 +595,6 @@ SOGoEventDragGhostController.prototype = {
|
|||||||
ghost.unsetStartGhost();
|
ghost.unsetStartGhost();
|
||||||
ghost.unsetEndGhost();
|
ghost.unsetEndGhost();
|
||||||
}
|
}
|
||||||
// logOnly("update");
|
|
||||||
if (this.currentCoordinates.dayNumber < maxGhosts) {
|
if (this.currentCoordinates.dayNumber < maxGhosts) {
|
||||||
var currentDay = this.currentCoordinates.dayNumber;
|
var currentDay = this.currentCoordinates.dayNumber;
|
||||||
var durationLeft = this.currentCoordinates.duration;
|
var durationLeft = this.currentCoordinates.duration;
|
||||||
@@ -459,7 +604,7 @@ SOGoEventDragGhostController.prototype = {
|
|||||||
if (duration > maxDuration)
|
if (duration > maxDuration)
|
||||||
duration = maxDuration;
|
duration = maxDuration;
|
||||||
|
|
||||||
var ghost;
|
var ghost = null;
|
||||||
if (currentDay > -1) {
|
if (currentDay > -1) {
|
||||||
ghost = this.ghosts[currentDay];
|
ghost = this.ghosts[currentDay];
|
||||||
ghost.setStartGhost();
|
ghost.setStartGhost();
|
||||||
@@ -470,10 +615,10 @@ SOGoEventDragGhostController.prototype = {
|
|||||||
ghost.setDuration(duration);
|
ghost.setDuration(duration);
|
||||||
ghost.show();
|
ghost.show();
|
||||||
|
|
||||||
if (this.startHourPara.parentNode != ghost) {
|
if (this.startHourPara) {
|
||||||
if (this.startHourPara.parentNode)
|
var parentNode = this.startHourPara.parentNode;
|
||||||
this.startHourPara.parentNode
|
if (parentNode && parentNode != ghost)
|
||||||
.removeChild(this.startHourPara);
|
parentNode.removeChild(this.startHourPara);
|
||||||
ghost.appendChild(this.startHourPara);
|
ghost.appendChild(this.startHourPara);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -496,12 +641,14 @@ SOGoEventDragGhostController.prototype = {
|
|||||||
durationLeft -= duration;
|
durationLeft -= duration;
|
||||||
currentDay++;
|
currentDay++;
|
||||||
}
|
}
|
||||||
if (!durationLeft)
|
if (!durationLeft) {
|
||||||
ghost.setEndGhost();
|
ghost.setEndGhost();
|
||||||
if (this.endHourPara.parentNode != ghost) {
|
}
|
||||||
if (this.endHourPara.parentNode)
|
|
||||||
this.endHourPara.parentNode
|
if (this.endHourPara) {
|
||||||
.removeChild(this.endHourPara);
|
var parentNode = this.endHourPara.parentNode;
|
||||||
|
if (parentNode && parentNode != ghost)
|
||||||
|
parentNode.removeChild(this.endHourPara);
|
||||||
ghost.appendChild(this.endHourPara);
|
ghost.appendChild(this.endHourPara);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -517,16 +664,14 @@ SOGoEventDragGhostController.prototype = {
|
|||||||
|
|
||||||
_updateGhostsParas: function SEDGC__updateGhostsParas() {
|
_updateGhostsParas: function SEDGC__updateGhostsParas() {
|
||||||
var para = this.startHourPara;
|
var para = this.startHourPara;
|
||||||
while (para.childNodes.length) {
|
while (para.childNodes.length)
|
||||||
para.removeChild(para.childNodes[0]);
|
para.removeChild(para.childNodes[0]);
|
||||||
}
|
|
||||||
var time = this.currentCoordinates.getStartTime();
|
var time = this.currentCoordinates.getStartTime();
|
||||||
para.appendChild(document.createTextNode(time));
|
para.appendChild(document.createTextNode(time));
|
||||||
|
|
||||||
para = this.endHourPara;
|
para = this.endHourPara;
|
||||||
while (para.childNodes.length) {
|
while (para.childNodes.length)
|
||||||
para.removeChild(para.childNodes[0]);
|
para.removeChild(para.childNodes[0]);
|
||||||
}
|
|
||||||
time = this.currentCoordinates.getEndTime();
|
time = this.currentCoordinates.getEndTime();
|
||||||
para.appendChild(document.createTextNode(time));
|
para.appendChild(document.createTextNode(time));
|
||||||
}
|
}
|
||||||
@@ -570,6 +715,10 @@ SOGoEventDragPointerHandler.prototype = {
|
|||||||
currentCoordinates: null,
|
currentCoordinates: null,
|
||||||
containerCoordinates: null,
|
containerCoordinates: null,
|
||||||
|
|
||||||
|
/* return the day and quarter coordinates of the pointer cursor within the
|
||||||
|
day view */
|
||||||
|
getEventViewCoordinates: null,
|
||||||
|
|
||||||
initFromEvent: function SEDPH_initFromEvent(event) {
|
initFromEvent: function SEDPH_initFromEvent(event) {
|
||||||
this.currentCoordinates = new SOGoCoordinates();
|
this.currentCoordinates = new SOGoCoordinates();
|
||||||
this.updateFromEvent(event);
|
this.updateFromEvent(event);
|
||||||
@@ -577,6 +726,11 @@ SOGoEventDragPointerHandler.prototype = {
|
|||||||
|
|
||||||
var utilities = SOGoEventDragUtilities();
|
var utilities = SOGoEventDragUtilities();
|
||||||
this.containerCoordinates = utilities.getEventsViewNodeCumulativeCoordinates();
|
this.containerCoordinates = utilities.getEventsViewNodeCumulativeCoordinates();
|
||||||
|
if (utilities.getEventType() == "multiday-allday") {
|
||||||
|
/* a hack */
|
||||||
|
this.containerCoordinates.x -= SOGoEventDragVerticalOffset;
|
||||||
|
this.containerCoordinates.y -= 40;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateFromEvent: function SEDPH_updateFromEvent(event) {
|
updateFromEvent: function SEDPH_updateFromEvent(event) {
|
||||||
@@ -585,39 +739,98 @@ SOGoEventDragPointerHandler.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getContainerBasedCoordinates: function SEDPH_getCBC() {
|
getContainerBasedCoordinates: function SEDPH_getCBC() {
|
||||||
return this.currentCoordinates.getDelta(this.containerCoordinates);
|
var coordinates = this.currentCoordinates.getDelta(this.containerCoordinates);
|
||||||
|
var container = SOGoEventDragUtilities().getEventsViewNode();
|
||||||
|
|
||||||
|
if (coordinates.x < 0 || coordinates.x > container.clientWidth
|
||||||
|
|| coordinates.y < 0 || coordinates.y > container.clientHeight)
|
||||||
|
coordinates = null;
|
||||||
|
|
||||||
|
return coordinates;
|
||||||
},
|
},
|
||||||
|
|
||||||
/* return the day and quarter coordinates of the pointer cursor within the
|
prepareWithEventType: function SEDPH_prepareWithEventType(eventType) {
|
||||||
day view */
|
var methods = { "multiday": this.getEventMultiDayViewCoordinates,
|
||||||
getEventViewCoordinates: function SEDPH_getEventViewCoordinates() {
|
"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() {
|
||||||
/* x = day; y = quarter */
|
/* x = day; y = quarter */
|
||||||
var coordinates = new SOGoCoordinates();
|
var coordinates;
|
||||||
|
|
||||||
var utilities = SOGoEventDragUtilities();
|
|
||||||
var pxCoordinates = this.getContainerBasedCoordinates();
|
var pxCoordinates = this.getContainerBasedCoordinates();
|
||||||
|
if (pxCoordinates) {
|
||||||
|
coordinates = new SOGoCoordinates();
|
||||||
|
|
||||||
var dayWidth = utilities.getDayWidth();
|
var utilities = SOGoEventDragUtilities();
|
||||||
var daysOffset = utilities.getDaysOffset();
|
var dayWidth = utilities.getDayWidth();
|
||||||
|
var daysOffset = utilities.getDaysOffset();
|
||||||
|
|
||||||
coordinates.x = Math.floor((pxCoordinates.x - daysOffset) / dayWidth);
|
coordinates.x = Math.floor((pxCoordinates.x - daysOffset) / dayWidth);
|
||||||
var maxX = utilities.getDayEventNodes().length - 1;
|
var maxX = utilities.getEventContainerNodes().length - 1;
|
||||||
if (coordinates.x < 0)
|
if (coordinates.x < 0)
|
||||||
coordinates.x = 0;
|
coordinates.x = 0;
|
||||||
else if (coordinates.x > maxX)
|
else if (coordinates.x > maxX)
|
||||||
coordinates.x = maxX;
|
coordinates.x = maxX;
|
||||||
|
|
||||||
var quarterHeight = utilities.getQuarterHeight();
|
|
||||||
var container = utilities.getEventsViewNode();
|
|
||||||
pxCoordinates.y += container.scrollTop;
|
|
||||||
coordinates.y = Math.floor((pxCoordinates.y
|
|
||||||
- SOGoEventDragHorizontalOffset)
|
|
||||||
/ quarterHeight);
|
|
||||||
var maxY = SOGoEventDragDayLength - 1;
|
|
||||||
if (coordinates.y < 0)
|
|
||||||
coordinates.y = 0;
|
coordinates.y = 0;
|
||||||
else if (coordinates.y > maxY)
|
} else {
|
||||||
coordinates.y = maxY;
|
coordinates = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// logOnly("coordinates.x: " + coordinates.x);
|
||||||
|
|
||||||
|
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;
|
||||||
|
coordinates.y = 0;
|
||||||
|
} else {
|
||||||
|
coordinates = null;
|
||||||
|
}
|
||||||
|
|
||||||
return coordinates;
|
return coordinates;
|
||||||
},
|
},
|
||||||
@@ -651,20 +864,22 @@ SOGoScrollController.prototype = {
|
|||||||
updateFromPointerHandler: function SSC_updateFromPointerHandler() {
|
updateFromPointerHandler: function SSC_updateFromPointerHandler() {
|
||||||
var pointerCoordinates
|
var pointerCoordinates
|
||||||
= this.pointerHandler.getContainerBasedCoordinates();
|
= this.pointerHandler.getContainerBasedCoordinates();
|
||||||
var now = new Date().getTime();
|
if (pointerCoordinates) {
|
||||||
if (!this.lastScroll || now > this.lastScroll + 100) {
|
var now = new Date().getTime();
|
||||||
this.lastScroll = now;
|
if (!this.lastScroll || now > this.lastScroll + 100) {
|
||||||
var scrollY = pointerCoordinates.y - this.scrollStep;
|
this.lastScroll = now;
|
||||||
if (scrollY < 0) {
|
var scrollY = pointerCoordinates.y - this.scrollStep;
|
||||||
var minY = -this.scrollView.scrollTop;
|
if (scrollY < 0) {
|
||||||
if (scrollY < minY)
|
var minY = -this.scrollView.scrollTop;
|
||||||
scrollY = minY;
|
if (scrollY < minY)
|
||||||
this.scrollView.scrollTop += scrollY;
|
scrollY = minY;
|
||||||
} else {
|
this.scrollView.scrollTop += scrollY;
|
||||||
scrollY = pointerCoordinates.y + this.scrollStep;
|
} else {
|
||||||
var delta = scrollY - this.scrollView.clientHeight;
|
scrollY = pointerCoordinates.y + this.scrollStep;
|
||||||
if (delta > 0) {
|
var delta = scrollY - this.scrollView.clientHeight;
|
||||||
this.scrollView.scrollTop += delta;
|
if (delta > 0) {
|
||||||
|
this.scrollView.scrollTop += delta;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -677,6 +892,7 @@ function SOGoEventDragController() {
|
|||||||
SOGoEventDragController.prototype = {
|
SOGoEventDragController.prototype = {
|
||||||
eventCells: null,
|
eventCells: null,
|
||||||
|
|
||||||
|
eventType: null,
|
||||||
title: null,
|
title: null,
|
||||||
folderClass: null,
|
folderClass: null,
|
||||||
|
|
||||||
@@ -693,45 +909,77 @@ SOGoEventDragController.prototype = {
|
|||||||
|
|
||||||
dropCallback: null,
|
dropCallback: null,
|
||||||
|
|
||||||
stopEventDraggingBound: null,
|
onDragStopBound: null,
|
||||||
moveBound: null,
|
moveBound: null,
|
||||||
|
|
||||||
|
_determineDragMode: null,
|
||||||
|
|
||||||
attachToEventCells: function SEDC_attachToEventCells(eventCells) {
|
attachToEventCells: function SEDC_attachToEventCells(eventCells) {
|
||||||
this.eventCells = eventCells;
|
this.eventCells = eventCells;
|
||||||
|
|
||||||
this.ghostController = new SOGoEventDragGhostController();
|
this.ghostController = new SOGoEventDragGhostController();
|
||||||
|
this._determineEventType(eventCells[0]);
|
||||||
|
this._prepareEventType();
|
||||||
this._determineTitleAndFolderClass();
|
this._determineTitleAndFolderClass();
|
||||||
this.ghostController.setTitle(this.title);
|
this.ghostController.setTitle(this.title);
|
||||||
this.ghostController.setFolderClass(this.folderClass);
|
this.ghostController.setFolderClass(this.folderClass);
|
||||||
|
|
||||||
var startEventDraggingBound = this.startEventDragging.bindAsEventListener(this);
|
var onDragStartBound = this.onDragStart.bindAsEventListener(this);
|
||||||
for (var i = 0; i < eventCells.length; i++) {
|
for (var i = 0; i < eventCells.length; i++) {
|
||||||
eventCells[i].observe("mousedown", startEventDraggingBound,
|
eventCells[i].observe("mousedown", onDragStartBound,
|
||||||
false);
|
false);
|
||||||
|
if (eventCells[i].editable) {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
attachToDayNode: function SEDC_attachToDayNode(dayNode) {
|
attachToDayNode: function SEDC_attachToDayNode(dayNode) {
|
||||||
|
this._determineEventType(dayNode);
|
||||||
|
this._prepareEventType();
|
||||||
this.ghostController = new SOGoEventDragGhostController();
|
this.ghostController = new SOGoEventDragGhostController();
|
||||||
this.ghostController.setTitle(getLabel("New Event"));
|
this.ghostController.setTitle(getLabel("New Event"));
|
||||||
|
|
||||||
var startEventDraggingBound
|
var onDragStartBound
|
||||||
= this.startEventDragging.bindAsEventListener(this);
|
= this.onDragStart.bindAsEventListener(this);
|
||||||
dayNode.observe("mousedown", startEventDraggingBound, false);
|
dayNode.observe("mousedown", onDragStartBound, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
startEventDragging: function SEDC_startEventDragging(event) {
|
onDragStart: function SEDC_onDragStart(event) {
|
||||||
var target = getTarget(event);
|
var target = getTarget(event);
|
||||||
if (target.nodeType == 1) {
|
if (target.nodeType == 1) {
|
||||||
if ((!this.eventCells && target.hasClassName("clickableHourCell"))
|
if ((!this.eventCells
|
||||||
|| (this.eventCells && this.eventCells[0].editable)) {
|
&& (target.hasClassName("clickableHourCell")
|
||||||
|
|| target.hasClassName("day"))
|
||||||
|
|| (this.eventCells && this.eventCells[0].editable))) {
|
||||||
var utilities = SOGoEventDragUtilities();
|
var utilities = SOGoEventDragUtilities();
|
||||||
utilities.reset();
|
utilities.reset();
|
||||||
|
utilities.setEventType(this.eventType);
|
||||||
|
|
||||||
this.pointerHandler = new SOGoEventDragPointerHandler();
|
this.pointerHandler = new SOGoEventDragPointerHandler();
|
||||||
|
this.pointerHandler.prepareWithEventType(this.eventType);
|
||||||
this.pointerHandler.initFromEvent(event);
|
this.pointerHandler.initFromEvent(event);
|
||||||
|
|
||||||
var coordinates = new SOGoEventDragEventCoordinates();
|
var coordinates = new SOGoEventDragEventCoordinates();
|
||||||
|
coordinates.setEventType(this.eventType);
|
||||||
if (this.eventCells) {
|
if (this.eventCells) {
|
||||||
coordinates.initFromEventCells(this.eventCells);
|
coordinates.initFromEventCells(this.eventCells);
|
||||||
} else {
|
} else {
|
||||||
@@ -751,28 +999,64 @@ SOGoEventDragController.prototype = {
|
|||||||
this.ghostController.setDragMode(this._determineDragMode());
|
this.ghostController.setDragMode(this._determineDragMode());
|
||||||
this.ghostController.setPointerHandler(this.pointerHandler);
|
this.ghostController.setPointerHandler(this.pointerHandler);
|
||||||
|
|
||||||
this.scrollController = new SOGoScrollController();
|
if (this.eventType == "multiday") {
|
||||||
this.scrollController.setPointerHandler(this.pointerHandler);
|
this.scrollController = new SOGoScrollController();
|
||||||
|
this.scrollController.setPointerHandler(this.pointerHandler);
|
||||||
|
}
|
||||||
|
|
||||||
// if (!this.eventCell)
|
this.onDragStopBound
|
||||||
// this.originalStart = Math.floor(this.origY / this.quarterHeight);
|
= this.onDragStop.bindAsEventListener(this);
|
||||||
|
|
||||||
this.stopEventDraggingBound
|
|
||||||
= this.stopEventDragging.bindAsEventListener(this);
|
|
||||||
if (Prototype.Browser.IE)
|
if (Prototype.Browser.IE)
|
||||||
Event.observe(document.body,
|
Event.observe(document.body,
|
||||||
"mouseup", this.stopEventDraggingBound);
|
"mouseup", this.onDragStopBound);
|
||||||
else
|
else
|
||||||
Event.observe(window, "mouseup", this.stopEventDraggingBound);
|
Event.observe(window, "mouseup", this.onDragStopBound);
|
||||||
this.moveBound = this.move.bindAsEventListener(this);
|
this.onDragModeBound = this.onDragMode.bindAsEventListener(this);
|
||||||
Event.observe(document.body, "mousemove", this.moveBound);
|
Event.observe(document.body, "mousemove", this.onDragModeBound);
|
||||||
}
|
}
|
||||||
Event.stop(event);
|
Event.stop(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
_determineDragMode: function SEDC__determineDragMode() {
|
|
||||||
|
_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() {
|
||||||
var dragMode;
|
var dragMode;
|
||||||
|
|
||||||
if (this.eventCells) {
|
if (this.eventCells) {
|
||||||
@@ -785,7 +1069,7 @@ SOGoEventDragController.prototype = {
|
|||||||
var firstCell = this.eventCells[0];
|
var firstCell = this.eventCells[0];
|
||||||
var handleCoords = firstCell.cumulativeOffset();
|
var handleCoords = firstCell.cumulativeOffset();
|
||||||
|
|
||||||
var dragMode = "move-event";
|
dragMode = "move-event";
|
||||||
if ((handleCoords[0] <= coordinates.x
|
if ((handleCoords[0] <= coordinates.x
|
||||||
&& coordinates.x <= handleCoords[0] + firstCell.clientWidth)
|
&& coordinates.x <= handleCoords[0] + firstCell.clientWidth)
|
||||||
&& (handleCoords[1] <= coordinates.y
|
&& (handleCoords[1] <= coordinates.y
|
||||||
@@ -808,6 +1092,70 @@ SOGoEventDragController.prototype = {
|
|||||||
|
|
||||||
return dragMode;
|
return dragMode;
|
||||||
},
|
},
|
||||||
|
_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;
|
||||||
|
},
|
||||||
|
|
||||||
_determineTitleAndFolderClass: function SEDC__dTAFC() {
|
_determineTitleAndFolderClass: function SEDC__dTAFC() {
|
||||||
var title = "";
|
var title = "";
|
||||||
@@ -857,14 +1205,14 @@ SOGoEventDragController.prototype = {
|
|||||||
return folderClass;
|
return folderClass;
|
||||||
},
|
},
|
||||||
|
|
||||||
stopEventDragging: function SEDC_stopEventDragging(event) {
|
onDragStop: function SEDC_onDragStop(event) {
|
||||||
if (Prototype.Browser.IE)
|
if (Prototype.Browser.IE)
|
||||||
Event.stopObserving(document.body, "mouseup", this.stopEventDraggingBound);
|
Event.stopObserving(document.body, "mouseup", this.onDragStopBound);
|
||||||
else
|
else
|
||||||
Event.stopObserving(window, "mouseup", this.stopEventDraggingBound);
|
Event.stopObserving(window, "mouseup", this.onDragStopBound);
|
||||||
Event.stopObserving(document.body, "mousemove", this.moveBound);
|
Event.stopObserving(document.body, "mousemove", this.onDragModeBound);
|
||||||
this.stopEventDraggingBound = null;
|
this.onDragStopBound = null;
|
||||||
this.moveBound = null;
|
this.onDragModeBound = null;
|
||||||
|
|
||||||
if (this.dragHasStarted) {
|
if (this.dragHasStarted) {
|
||||||
this.ghostController.hideGhosts();
|
this.ghostController.hideGhosts();
|
||||||
@@ -882,11 +1230,12 @@ SOGoEventDragController.prototype = {
|
|||||||
this.updateDropCallback(this, this.eventCells, delta);
|
this.updateDropCallback(this, this.eventCells, delta);
|
||||||
} else {
|
} else {
|
||||||
var utilities = SOGoEventDragUtilities();
|
var utilities = SOGoEventDragUtilities();
|
||||||
var dayEventNodes = utilities.getDayEventNodes();
|
var eventContainerNodes = utilities.getEventContainerNodes();
|
||||||
var dayNode = dayEventNodes[this.ghostController
|
var dayNode = eventContainerNodes[this.ghostController
|
||||||
.currentCoordinates
|
.currentCoordinates
|
||||||
.dayNumber]
|
.dayNumber];
|
||||||
.parentNode;
|
if (dayNode.hasClassName("events"))
|
||||||
|
dayNode = dayNode.parentNode;
|
||||||
this.createDropCallback(this,
|
this.createDropCallback(this,
|
||||||
dayNode.readAttribute("day"),
|
dayNode.readAttribute("day"),
|
||||||
this.ghostController.currentCoordinates);
|
this.ghostController.currentCoordinates);
|
||||||
@@ -906,9 +1255,10 @@ SOGoEventDragController.prototype = {
|
|||||||
return time;
|
return time;
|
||||||
},
|
},
|
||||||
|
|
||||||
move: function SEDC_move(event) {
|
onDragMode: function SEDC_onDragMode(event) {
|
||||||
this.pointerHandler.updateFromEvent(event);
|
this.pointerHandler.updateFromEvent(event);
|
||||||
this.scrollController.updateFromPointerHandler();
|
if (this.scrollController)
|
||||||
|
this.scrollController.updateFromPointerHandler();
|
||||||
|
|
||||||
if (this.dragHasStarted) {
|
if (this.dragHasStarted) {
|
||||||
this.ghostController.updateFromPointerHandler();
|
this.ghostController.updateFromPointerHandler();
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 170 B |
Reference in new issue
Block a user