summaryrefslogtreecommitdiffstats
path: root/jquery.weekcalendar.js
diff options
context:
space:
mode:
Diffstat (limited to 'jquery.weekcalendar.js')
-rw-r--r--jquery.weekcalendar.js86
1 files changed, 64 insertions, 22 deletions
diff --git a/jquery.weekcalendar.js b/jquery.weekcalendar.js
index 8e42f76..0c3e634 100644
--- a/jquery.weekcalendar.js
+++ b/jquery.weekcalendar.js
@@ -56,6 +56,7 @@
timeslotsPerHour: 4,
minDate: null,
maxDate: null,
+ showHeader: true,
buttons: true,
buttonText: {
today: 'today',
@@ -531,7 +532,7 @@
// events array locally in a store but this should be done in conjunction
// with a proper binding model.
- var currentEvents = $.map(self.element.find('.wc-cal-event'), function() {
+ var currentEvents = self.element.find('.wc-cal-event').map(function() {
return $(this).data('calEvent');
});
@@ -692,6 +693,7 @@
*/
_renderCalendarButtons: function($calendarContainer) {
var self = this, options = this.options;
+ if ( !options.showHeader ) return;
if (options.buttons) {
var calendarNavHtml = '';
@@ -862,7 +864,7 @@
Find a way to handle it
*/
$calendarContainer.find('.wc-time-header-cell').css({
- height: (options.timeslotHeight * options.timeslotsPerHour) - 11,
+ height: (options.timeslotHeight * options.timeslotsPerHour) - 1,
padding: 5
});
//add the user data to every impacted column
@@ -1320,6 +1322,14 @@
$weekDayColumns.each(function(i, val) {
$(this).data('startDate', self._cloneDate(currentDay));
+
+ var endDate = self._cloneDate(currentDay);
+ endDate.setTime(currentDay.getTime() + MILLIS_IN_DAY);
+
+ if(endDate.getTimezoneOffset() != currentDay.getTimezoneOffset()) {
+ endDate.setTime(endDate.getTime()+(endDate.getTimezoneOffset()-currentDay.getTimezoneOffset())*60000);
+ }
+
$(this).data('endDate', new Date(currentDay.getTime() + (MILLIS_IN_DAY)));
if (self._isToday(currentDay)) {
$(this).parent()
@@ -1431,6 +1441,7 @@
while (startDate < endDate) {
calEvent.start = start;
+ calEvent.end = newDate(0, 0, 0);
// end of this virual calEvent is set to the end of the day
calEvent.end.setFullYear(start.getFullYear());
@@ -1729,6 +1740,35 @@
var adjustedStart, adjustedEnd;
var self = this;
+ var freeBusyManager = self.getFreeBusyManagerForEvent(newCalEvent);
+ $.each(freeBusyManager.getFreeBusys(newCalEvent.start, newCalEvent.end), function() {
+ if (!this.getOption('free')) {
+
+ if (newCalEvent.start.getTime() == this.getStart().getTime() &&
+ newCalEvent.end.getTime() > this.getEnd().getTime()) {
+
+ adjustedStart = this.getEnd();
+ }
+
+ if (newCalEvent.end.getTime() == this.getEnd().getTime() &&
+ newCalEvent.start.getTime() < this.getStart().getTime()) {
+
+ adjustedEnd = this.getStart();
+ }
+
+ if (oldCalEvent.resizable == false ||
+ (newCalEvent.end.getTime() > this.getEnd().getTime() &&
+ newCalEvent.start.getTime() < this.getStart().getTime()) ||
+ (newCalEvent.end.getTime() == this.getEnd().getTime() &&
+ newCalEvent.start.getTime() == this.getStart().getTime())) {
+
+ adjustedStart = oldCalEvent.start;
+ adjustedEnd = oldCalEvent.end;
+ newCalEvent.userId = oldCalEvent.userId;
+ }
+ }
+ });
+
$weekDay.find('.wc-cal-event').not($calEvent).each(function() {
var currentCalEvent = $(this).data('calEvent');
@@ -1753,6 +1793,7 @@
adjustedStart = oldCalEvent.start;
adjustedEnd = oldCalEvent.end;
+ newCalEvent.userId = oldCalEvent.userId;
return false;
}
@@ -1778,25 +1819,26 @@
$calEvent.data('calEvent', newCalEvent);
},
- /*
- * Add draggable capabilities to an event
- */
+ /**
+ * Add draggable capabilities to an event
+ */
_addDraggableToCalEvent: function(calEvent, $calEvent) {
- var options = this.options;
- $calEvent.draggable({
- handle: '.wc-time',
- containment: 'div.wc-time-slots',
- snap: '.wc-day-column-inner',
- snapMode: 'inner',
- snapTolerance: options.timeslotHeight - 1,
- revert: 'invalid',
- opacity: 0.5,
- grid: [$calEvent.outerWidth() + 1, options.timeslotHeight],
- start: function(event, ui) {
- var $calEvent = ui.draggable;
- options.eventDrag(calEvent, $calEvent);
- }
- });
+ var options = this.options;
+
+ $calEvent.draggable({
+ handle: '.wc-time',
+ containment: 'div.wc-time-slots',
+ snap: '.wc-day-column-inner',
+ snapMode: 'inner',
+ snapTolerance: options.timeslotHeight - 1,
+ revert: 'invalid',
+ opacity: 0.5,
+ grid: [$calEvent.outerWidth() + 1, options.timeslotHeight],
+ start: function(event, ui) {
+ var $calEvent = ui.draggable || ui.helper;
+ options.eventDrag(calEvent, $calEvent);
+ }
+ });
},
/*
@@ -2016,9 +2058,9 @@
*/
_disableTextSelect: function($elements) {
$elements.each(function() {
- if ($.browser.mozilla) {//Firefox
+ if (typeof this.style.MozUserSelect !== 'undefined') {//Firefox
$(this).css('MozUserSelect', 'none');
- } else if ($.browser.msie) {//IE
+ } else if (typeof this.onselectstart !== 'undefined') {//IE
$(this).bind('selectstart', function() {
return false;
});