diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d8fe4fa
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/.project
diff --git a/jquery.weekcalendar.js b/jquery.weekcalendar.js
index 681715b..19a6724 100644
--- a/jquery.weekcalendar.js
+++ b/jquery.weekcalendar.js
@@ -1,24 +1,24 @@
/*
- * jQuery.weekCalendar v2.0-dev
- *
- * for support join us at the google group:
- * - http://groups.google.com/group/jquery-week-calendar
- * have a look to the wiki for documentation:
- * - http://wiki.github.com/themouette/jquery-week-calendar/
- * something went bad ? report an issue:
- * - http://github.com/themouette/jquery-week-calendar/issues
- * get the last version on github:
- * - http://github.com/themouette/jquery-week-calendar
- *
- * Copyright (c) 2009 Rob Monie
- * Copyright (c) 2010 Julien MUETTON
- * Dual licensed under the MIT and GPL licenses:
- * http://www.opensource.org/licenses/mit-license.php
- * http://www.gnu.org/licenses/gpl.html
- *
- * If you're after a monthly calendar plugin, check out this one :
- * http://arshaw.com/fullcalendar/
- */
+* jQuery.weekCalendar v2.0-dev
+*
+* for support join us at the google group:
+* - http://groups.google.com/group/jquery-week-calendar
+* have a look to the wiki for documentation:
+* - http://wiki.github.com/themouette/jquery-week-calendar/
+* something went bad ? report an issue:
+* - http://github.com/themouette/jquery-week-calendar/issues
+* get the last version on github:
+* - http://github.com/themouette/jquery-week-calendar
+*
+* Copyright (c) 2009 Rob Monie
+* Copyright (c) 2010 Julien MUETTON
+* Dual licensed under the MIT and GPL licenses:
+* http://www.opensource.org/licenses/mit-license.php
+* http://www.gnu.org/licenses/gpl.html
+*
+* If you're after a monthly calendar plugin, check out this one :
+* http://arshaw.com/fullcalendar/
+*/
(function($) {
// check the jquery version
@@ -29,6 +29,15 @@
var _currentAjaxCall;
return {
options: {
+//** storeCalParamsInSessionFunction - default null or should be an external function to keep temporary cal params in session when user go back to calendar
+ storeCalParamsInSessionFunction: null,
+//** jqueryUI Datepicker - default
+ datepicker: {},
+//** UsersCombo - default
+ showUsersCombo: false,
+ usersComboUser: null,
+ usersComboAllUsersEntry: 'All',
+//**
date: new Date(),
timeFormat: null,
dateFormat: 'M d, Y',
@@ -63,7 +72,7 @@
},
switchDisplay: {},
scrollToHourMillis: 500,
- allowEventDelete: false,
+ allowEventDelete: false,
allowCalEventOverlap: false,
overlapEventsSeparate: false,
totalEventsWidthPercentInOneColumn : 100,
@@ -78,7 +87,7 @@
resizable: function(calEvent, element) {
return true;
},
- eventClick: function(calEvent, element, dayFreeBusyManager,
+ eventClick: function(calEvent, element, dayFreeBusyManager,
calendar, clickEvent) {
},
eventRender: function(calEvent, element) {
@@ -96,17 +105,17 @@
},
eventResize: function(calEvent, element) {
},
- eventNew: function(calEvent, element, dayFreeBusyManager,
+ eventNew: function(calEvent, element, dayFreeBusyManager,
calendar, mouseupEvent) {
},
eventMouseover: function(calEvent, $event) {
},
eventMouseout: function(calEvent, $event) {
},
- eventDelete: function(calEvent, element, dayFreeBusyManager,
+ eventDelete: function(calEvent, element, dayFreeBusyManager,
calendar, clickEvent) {
calendar.weekCalendar('removeEvent',calEvent.id);
- },
+ },
calendarBeforeLoad: function(calendar) {
},
calendarAfterLoad: function(calendar) {
@@ -138,89 +147,89 @@
longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
/* multi-users options */
/**
- * the available users for calendar.
- * if you want to display users separately, enable the
- * showAsSeparateUsers option.
- * if you provide a list of user and do not enable showAsSeparateUsers
- * option, then only the events that belongs to one or several of
- * given users will be displayed
- * @type {array}
- */
+ * the available users for calendar.
+ * if you want to display users separately, enable the
+ * showAsSeparateUsers option.
+ * if you provide a list of user and do not enable showAsSeparateUsers
+ * option, then only the events that belongs to one or several of
+ * given users will be displayed
+ * @type {array}
+ */
users: [],
/**
- * should the calendar be displayed with separate column for each
- * users.
- * note that this option does nothing if you do not provide at least
- * one user.
- * @type {boolean}
- */
+ * should the calendar be displayed with separate column for each
+ * users.
+ * note that this option does nothing if you do not provide at least
+ * one user.
+ * @type {boolean}
+ */
showAsSeparateUsers: true,
/**
- * callback used to read user id from a user object.
- * @param {Object} user the user to retrieve the id from.
- * @param {number} index the user index from user list.
- * @param {jQuery} calendar the calendar object.
- * @return {int|String} the user id.
- */
+ * callback used to read user id from a user object.
+ * @param {Object} user the user to retrieve the id from.
+ * @param {number} index the user index from user list.
+ * @param {jQuery} calendar the calendar object.
+ * @return {int|String} the user id.
+ */
getUserId: function(user, index, calendar) {
return index;
},
/**
- * callback used to read user name from a user object.
- * @param {Object} user the user to retrieve the name from.
- * @param {number} index the user index from user list.
- * @param {jQuery} calendar the calendar object.
- * @return {String} the user name.
- */
+ * callback used to read user name from a user object.
+ * @param {Object} user the user to retrieve the name from.
+ * @param {number} index the user index from user list.
+ * @param {jQuery} calendar the calendar object.
+ * @return {String} the user name.
+ */
getUserName: function(user, index, calendar) {
return user;
},
/**
- * reads the id(s) of user(s) for who the event should be displayed.
- * @param {Object} calEvent the calEvent to read informations from.
- * @param {jQuery} calendar the calendar object.
- * @return {number|String|Array} the user id(s) to appened events for.
- */
+ * reads the id(s) of user(s) for who the event should be displayed.
+ * @param {Object} calEvent the calEvent to read informations from.
+ * @param {jQuery} calendar the calendar object.
+ * @return {number|String|Array} the user id(s) to appened events for.
+ */
getEventUserId: function(calEvent, calendar) {
return calEvent.userId;
},
/**
- * sets user id(s) to the calEvent
- * @param {Object} calEvent the calEvent to set informations to.
- * @param {jQuery} calendar the calendar object.
- * @return {Object} the calEvent with modified user id.
- */
+ * sets user id(s) to the calEvent
+ * @param {Object} calEvent the calEvent to set informations to.
+ * @param {jQuery} calendar the calendar object.
+ * @return {Object} the calEvent with modified user id.
+ */
setEventUserId: function(userId, calEvent, calendar) {
calEvent.userId = userId;
return calEvent;
},
/* freeBusy options */
/**
- * should the calendar display freebusys ?
- * @type {boolean}
- */
+ * should the calendar display freebusys ?
+ * @type {boolean}
+ */
displayFreeBusys: false,
/**
- * read the id(s) for who the freebusy is available
- * @param {Object} calEvent the calEvent to read informations from.
- * @param {jQuery} calendar the calendar object.
- * @return {number|String|Array} the user id(s) to appened events for.
- */
+ * read the id(s) for who the freebusy is available
+ * @param {Object} calEvent the calEvent to read informations from.
+ * @param {jQuery} calendar the calendar object.
+ * @return {number|String|Array} the user id(s) to appened events for.
+ */
getFreeBusyUserId: function(calFreeBusy, calendar) {
return calFreeBusy.userId;
},
/**
- * the default freeBusy object, used to manage default state
- * @type {Object}
- */
+ * the default freeBusy object, used to manage default state
+ * @type {Object}
+ */
defaultFreeBusy: {free: false},
/**
- * function used to display the freeBusy element
- * @type {Function}
- * @param {Object} freeBusy the freeBusy timeslot to render.
- * @param {jQuery} $freeBusy the freeBusy HTML element.
- * @param {jQuery} calendar the calendar element.
- */
+ * function used to display the freeBusy element
+ * @type {Function}
+ * @param {Object} freeBusy the freeBusy timeslot to render.
+ * @param {jQuery} $freeBusy the freeBusy HTML element.
+ * @param {jQuery} calendar the calendar element.
+ */
freeBusyRender: function(freeBusy, $freeBusy, calendar) {
if (!freeBusy.free) {
$freeBusy.addClass('free-busy-busy');
@@ -232,160 +241,173 @@
},
/* other options */
/**
- * true means start on first day of week, false means starts on
- * startDate.
- * @param {jQuery} calendar the calendar object.
- * @type {Function|bool}
- */
+ * true means start on first day of week, false means starts on
+ * startDate.
+ * @param {jQuery} calendar the calendar object.
+ * @type {Function|bool}
+ */
startOnFirstDayOfWeek: function(calendar) {
return $(calendar).weekCalendar('option', 'daysToShow') >= 5;
},
/**
- * should the columns be rendered alternatively using odd/even
- * class
- * @type {boolean}
- */
+ * should the columns be rendered alternatively using odd/even
+ * class
+ * @type {boolean}
+ */
displayOddEven: false,
textSize: 13,
/**
- * the title attribute for the calendar. possible placeholders are:
- *
- *
%start%
- *
%end%
- *
%date%
- *
- * @type {Function|string}
- * @param {number} option daysToShow.
- * @return {String} the title attribute for the calendar.
- */
+ * the title attribute for the calendar. possible placeholders are:
+ *
+ *
%start%
+ *
%end%
+ *
%date%
+ *
+ * @type {Function|string}
+ * @param {number} option daysToShow.
+ * @return {String} the title attribute for the calendar.
+ */
title: '%start% - %end%',
/**
- * default options to pass to callback
- * you can pass a function returning an object or a litteral object
- * @type {object|function(#calendar)}
- */
+ * default options to pass to callback
+ * you can pass a function returning an object or a litteral object
+ * @type {object|function(#calendar)}
+ */
jsonOptions: {},
headerSeparator: ' ',
/**
- * returns formatted header for day display
- * @type {function(date,calendar)}
- */
+ * returns formatted header for day display
+ * @type {function(date,calendar)}
+ */
getHeaderDate: null,
preventDragOnEventCreation: false,
/**
- * the event on which to bind calendar resize
- * @type {string}
- */
+ * the event on which to bind calendar resize
+ * @type {string}
+ */
resizeEvent: 'resize.weekcalendar'
},
/***********************
- * Initialise calendar *
- ***********************/
+ * Initialise calendar *
+ ***********************/
_create: function() {
var self = this;
+//** storeCalParamsInSessionFunction - initialize default values if function while calendar is initialized
+ if ($.isFunction(self.options.storeCalParamsInSessionFunction)) {
+ self.options.storeCalParamsInSessionFunction(0, null, self);
+ }
+//**
self._computeOptions();
self._setupEventDelegation();
- self._renderCalendar();
- self._loadCalEvents();
- self._resizeCalendar();
- self._scrollToHour(self.options.date.getHours(), true);
-
- if (this.options.resizeEvent) {
- $(window).unbind(this.options.resizeEvent);
- $(window).bind(this.options.resizeEvent, function() {
- self._resizeCalendar();
- });
- }
-
+//** Rebuild calendar refactoring
+ self._rebuildCalendar(self.options.date.getHours(), true); //this function has been added and replaced a set of functions as reuse refactoring
+//**
},
/********************
- * public functions *
- ********************/
+ * public functions *
+ ********************/
/*
- * Refresh the events for the currently displayed week.
- */
+ * Refresh the events for the currently displayed week.
+ */
refresh: function() {
//reload with existing week
this._loadCalEvents(this.element.data('startDate'));
},
/*
- * Clear all events currently loaded into the calendar
- */
+ * Clear all events currently loaded into the calendar
+ */
clear: function() {
this._clearCalendar();
},
/*
- * Go to this week
- */
+ * Go to this week
+ */
today: function() {
this._clearCalendar();
this._loadCalEvents(new Date());
+//** jqueryUI Datepicker - fill input with correct date
+ this.element.find('#wc-datepicker-date').val(this._formatDate(this.options.date, "Y-m-d"));
+//**
},
/*
- * Go to the previous week relative to the currently displayed week
- */
+ * Go to the previous week relative to the currently displayed week
+ */
prevWeek: function() {
//minus more than 1 day to be sure we're in previous week - account for daylight savings or other anomolies
var newDate = new Date(this.element.data('startDate').getTime() - (MILLIS_IN_WEEK / 6));
this._clearCalendar();
this._loadCalEvents(newDate);
+//** jqueryUI Datepicker - fill input with correct date
+ this.element.find('#wc-datepicker-date').val(this._formatDate(this.options.date, "Y-m-d"));
+//**
},
/*
- * Go to the next week relative to the currently displayed week
- */
+ * Go to the next week relative to the currently displayed week
+ */
nextWeek: function() {
//add 8 days to be sure of being in prev week - allows for daylight savings or other anomolies
var newDate = new Date(this.element.data('startDate').getTime() + MILLIS_IN_WEEK + MILLIS_IN_DAY);
this._clearCalendar();
this._loadCalEvents(newDate);
+//** jqueryUI Datepicker - fill input with correct date
+ this.element.find('#wc-datepicker-date').val(this._formatDate(this.options.date, "Y-m-d"));
+//**
},
/*
- * Reload the calendar to whatever week the date passed in falls on.
- */
+ * Reload the calendar to whatever week the date passed in falls on.
+ */
gotoWeek: function(date) {
this._clearCalendar();
this._loadCalEvents(date);
+//** jqueryUI Datepicker - fill input with correct date
+ this.element.find('#wc-datepicker-date').val(this._formatDate(this.options.date, "Y-m-d"));
+//**
},
/*
- * Reload the calendar to whatever week the date passed in falls on.
- */
+ * Reload the calendar to whatever week the date passed in falls on.
+ */
gotoDate: function(date) {
this._clearCalendar();
this._loadCalEvents(date);
+//** jqueryUI Datepicker - fill input with correct date
+ this.element.find('#wc-datepicker-date').val(this._formatDate(this.options.date, "Y-m-d"));
+//**
},
/**
- * change the number of days to show
- */
+ * change the number of days to show
+ */
setDaysToShow: function(daysToShow) {
var self = this;
var hour = self._getCurrentScrollHour();
- self.options.daysToShow = daysToShow;
+//** storeCalParamsInSessionFunction - call a function if present
+ var options = self.options;
+ if ($.isFunction(self.options.storeCalParamsInSessionFunction)) {
+ //if delegate is set, it calls defined function (the function should also set options.daysToShow param)
+ options.storeCalParamsInSessionFunction(daysToShow, self.options.usersComboUser, self);
+ }
+ else {
+ //if no delegate, we set new daysToShow
+ self.options.daysToShow = daysToShow;
+ }
+//**
$(self.element).html('');
- self._renderCalendar();
- self._loadCalEvents();
- self._resizeCalendar();
- self._scrollToHour(hour, false);
-
- if (this.options.resizeEvent) {
- $(window).unbind(this.options.resizeEvent);
- $(window).bind(this.options.resizeEvent, function() {
- self._resizeCalendar();
- });
- }
+//** Rebuild calendar refactoring
+ self._rebuildCalendar(hour, false);
+//**
},
/*
- * Remove an event based on it's id
- */
+ * Remove an event based on it's id
+ */
removeEvent: function(eventId) {
var self = this;
@@ -404,9 +426,9 @@
},
/*
- * Removes any events that have been added but not yet saved (have no id).
- * This is useful to call after adding a freshly saved new event.
- */
+ * Removes any events that have been added but not yet saved (have no id).
+ * This is useful to call after adding a freshly saved new event.
+ */
removeUnsavedEvents: function() {
var self = this;
@@ -422,19 +444,19 @@
},
/*
- * update an event in the calendar. If the event exists it refreshes
- * it's rendering. If it's a new event that does not exist in the calendar
- * it will be added.
- */
+ * update an event in the calendar. If the event exists it refreshes
+ * it's rendering. If it's a new event that does not exist in the calendar
+ * it will be added.
+ */
updateEvent: function(calEvent) {
this._updateEventInCalendar(calEvent);
},
/*
- * Returns an array of timeslot start and end times based on
- * the configured grid of the calendar. Returns in both date and
- * formatted time based on the 'timeFormat' config option.
- */
+ * Returns an array of timeslot start and end times based on
+ * the configured grid of the calendar. Returns in both date and
+ * formatted time based on the 'timeFormat' config option.
+ */
getTimeslotTimes: function(date) {
var options = this.options;
var firstHourDisplayed = options.businessHours.limitDisplay ? options.businessHours.start : 0;
@@ -494,6 +516,9 @@
this._clearCalendar();
this._loadCalEvents(newDate);
+//** jqueryUI Datepicker - fill input with correct date
+ this.element.find('#wc-datepicker-date').val(this._formatDate(this.options.date, "Y-m-d"));
+//**
},
prev: function() {
@@ -505,6 +530,9 @@
this._clearCalendar();
this._loadCalEvents(newDate);
+//** jqueryUI Datepicker - fill input with correct date
+ this.element.find('#wc-datepicker-date').val(this._formatDate(this.options.date, "Y-m-d"));
+//**
},
getCurrentFirstDay: function() {
return this._dateFirstDayOfWeek(this.options.date || new Date());
@@ -514,8 +542,24 @@
},
/*********************
- * private functions *
- *********************/
+ * private functions *
+ *********************/
+//** Rebuild calendar - reuse refactoring
+ _rebuildCalendar: function(hours, scroll) {
+ var self = this;
+ self._renderCalendar();
+ self._loadCalEvents();
+ self._resizeCalendar();
+ self._scrollToHour(hours, scroll);
+
+ if (self.options.resizeEvent) {
+ $(window).unbind(self.options.resizeEvent);
+ $(window).bind(self.options.resizeEvent, function() {
+ self._resizeCalendar();
+ });
+ }
+ },
+//**
_setOption: function(key, value) {
var self = this;
if (self.options[key] != value) {
@@ -554,8 +598,8 @@
},
/*
- * Resize the calendar scrollable height based on the provided function in options.
- */
+ * Resize the calendar scrollable height based on the provided function in options.
+ */
_resizeCalendar: function() {
var options = this.options;
if (options && $.isFunction(options.height)) {
@@ -584,9 +628,9 @@
},
/*
- * configure calendar interaction events that are able to use event
- * delegation for greater efficiency
- */
+ * configure calendar interaction events that are able to use event
+ * delegation for greater efficiency
+ */
_setupEventDelegation: function() {
var self = this;
var options = this.options;
@@ -599,11 +643,11 @@
var $calEvent = $target.hasClass('wc-cal-event') ? $target : $target.parents('.wc-cal-event');
if ($calEvent.length) {
freeBusyManager = self.getFreeBusyManagerForEvent($calEvent.data('calEvent'));
- if (options.allowEventDelete && $target.hasClass('wc-cal-event-delete')) {
- options.eventDelete($calEvent.data('calEvent'), $calEvent, freeBusyManager, self.element, event);
- }else{
- options.eventClick($calEvent.data('calEvent'), $calEvent, freeBusyManager, self.element, event);
- }
+if (options.allowEventDelete && $target.hasClass('wc-cal-event-delete')) {
+options.eventDelete($calEvent.data('calEvent'), $calEvent, freeBusyManager, self.element, event);
+}else{
+options.eventClick($calEvent.data('calEvent'), $calEvent, freeBusyManager, self.element, event);
+}
}
}).mouseover(function(event) {
var $target = $(event.target);
@@ -628,15 +672,15 @@
},
/*
- * check if a ui draggable or resizable is currently being dragged or resized
- */
+ * check if a ui draggable or resizable is currently being dragged or resized
+ */
_isDraggingOrResizing: function($target) {
return $target.hasClass('ui-draggable-dragging') || $target.hasClass('ui-resizable-resizing');
},
/*
- * Render the main calendar layout
- */
+ * Render the main calendar layout
+ */
_renderCalendar: function() {
var $calendarContainer, $weekDayColumns;
var self = this;
@@ -664,8 +708,8 @@
},
/**
- * render the nav buttons on top of the calendar
- */
+ * render the nav buttons on top of the calendar
+ */
_renderCalendarButtons: function($calendarContainer) {
var self = this, options = this.options;
if (options.buttons) {
@@ -678,14 +722,23 @@
calendarNavHtml += '';
calendarNavHtml += '';
calendarNavHtml += '';
+//** jqueryUI Datepicker - input create
+ if(this.options.datepicker != null) {
+ calendarNavHtml += '';
+ }
+//**
calendarNavHtml += '';
calendarNavHtml += '';
$(calendarNavHtml).appendTo($calendarContainer);
$calendarContainer.find('.wc-nav .wc-today')
- .button({
- icons: {primary: 'ui-icon-home'}})
+ .button(
+//** remove ugly home icon on 'today' button
+// {icons: {primary: 'ui-icon-home'}}
+//**
+ )
.click(function() {
self.today();
return false;
@@ -709,6 +762,26 @@
return false;
});
+//** UsersCombo - create
+ // add users combo
+ if (this.options.showUsersCombo && this.options.users.length) {
+ var $container = $calendarContainer.find('.wc-toolbar');
+ var _input = '';
+ _input += ' ';
+ $container.append(_input);
+ $usersCombo = $calendarContainer.find('#wc-user-combo');
+ $usersCombo.change(function() {
+ self._switchCalViewForUser();
+ });
+ $usersCombo.val(this.options.usersComboUser);
+ }
+//**
+
// now add buttons to switch display
if (this.options.switchDisplay && $.isPlainObject(this.options.switchDisplay)) {
var $container = $calendarContainer.find('.wc-display');
@@ -734,6 +807,19 @@
$calendarContainer.find('.wc-title')
.height(_height)
.css('line-height', _height + 'px');
+//** jqueryUI Datepicker - initialize widged and set isodate filter
+ if(this.options.datepicker != null) {
+ var isoDateRegExp = /^\d{4}\-\d{2}\-\d{2}$/;
+ $.datepicker.setDefaults(this.options.datepicker);
+ $calendarDatepicker = $calendarContainer.find('#wc-datepicker-date');
+ $calendarDatepicker.datepicker();
+ $calendarDatepicker.change(function() {
+ if(isoDateRegExp.test($(this).val())) {
+ self.gotoWeek($(this).val());
+ }
+ });
+ }
+//**
}else{
var calendarNavHtml = '';
calendarNavHtml += '
';
@@ -745,9 +831,17 @@
},
/**
- * render the calendar header, including date and user header
- */
+ * render the calendar header, including date and user header
+ */
_renderCalendarHeader: function($calendarContainer) {
+//** usersComboUser - show user in separate columns depeding on usersComboUser content
+ if(this.options.showUsersCombo && this.options.usersComboUser != 'null' && this.options.usersComboUser !== null) {
+ this.options.showAsSeparateUsers = false;
+ }
+ else {
+ this.options.showAsSeparateUsers = true;
+ }
+//**
var self = this, options = this.options,
showAsSeparatedUser = options.showAsSeparateUsers && options.users && options.users.length,
rowspan = '', colspan = '', calendarHeaderHtml;
@@ -787,9 +881,9 @@
_headerClass = _headerClass.join(' ');
}
calendarHeaderHtml += '
';
}
}
@@ -802,11 +896,11 @@
},
/**
- * render the calendar body.
- * Calendar body is composed of several distinct parts.
- * Each part is displayed in a separated row to ease rendering.
- * for further explanations, see each part rendering function.
- */
+ * render the calendar body.
+ * Calendar body is composed of several distinct parts.
+ * Each part is displayed in a separated row to ease rendering.
+ * for further explanations, see each part rendering function.
+ */
_renderCalendarBody: function($calendarContainer) {
var self = this, options = this.options,
showAsSeparatedUser = options.showAsSeparateUsers && options.users && options.users.length,
@@ -834,8 +928,8 @@
$calendarContainer.find('.wc-time-slot').height(options.timeslotHeight - 1); //account for border
//init the time row header height
/**
- TODO if total height for an hour is less than 11px, there is a display problem.
- Find a way to handle it
+ TODO if total height for an hour is less than 11px, there is a display problem.
+ Find a way to handle it
*/
$calendarContainer.find('.wc-time-header-cell').css({
height: (options.timeslotHeight * options.timeslotsPerHour) - 11,
@@ -853,8 +947,8 @@
},
/**
- * render the timeslots separation
- */
+ * render the timeslots separation
+ */
_renderCalendarBodyTimeSlots: function($calendarTableTbody) {
var options = this.options,
renderRow, i, j,
@@ -895,8 +989,8 @@
},
/**
- * render the odd even columns
- */
+ * render the odd even columns
+ */
_renderCalendarBodyOddEven: function($calendarTableTbody) {
if (this.options.displayOddEven) {
var options = this.options,
@@ -935,8 +1029,8 @@
},
/**
- * render the freebusy placeholders
- */
+ * render the freebusy placeholders
+ */
_renderCalendarBodyFreeBusy: function($calendarTableTbody) {
if (this.options.displayFreeBusys) {
var self = this, options = this.options,
@@ -976,8 +1070,8 @@
},
/**
- * render the calendar body for event placeholders
- */
+ * render the calendar body for event placeholders
+ */
_renderCalendarBodyEvents: function($calendarTableTbody) {
var self = this, options = this.options,
renderRow,
@@ -1039,8 +1133,8 @@
},
/*
- * setup mouse events for capturing new events
- */
+ * setup mouse events for capturing new events
+ */
_setupEventCreationForWeekDay: function($weekDay) {
var self = this;
var options = this.options;
@@ -1122,19 +1216,19 @@
'createdFromSingleClick': createdFromSingleClick,
'calendar': self.element
});
- if (proceed) {
- options.eventNew(newCalEvent, $renderedCalEvent, freeBusyManager, self.element, event);
- }
- else {
- $($renderedCalEvent).remove();
- }
+ if (proceed) {
+ options.eventNew(newCalEvent, $renderedCalEvent, freeBusyManager, self.element, event);
+ }
+ else {
+ $($renderedCalEvent).remove();
+ }
}
});
},
/*
- * load calendar events for the week based on the date provided
- */
+ * load calendar events for the week based on the date provided
+ */
_loadCalEvents: function(dateWithinWeek) {
var date, weekStartDate, weekEndDate, $weekDayColumns;
@@ -1225,13 +1319,11 @@
}
self._disableTextSelect($weekDayColumns);
-
-
},
/*
- * update the display of each day column header based on the calendar week
- */
+ * update the display of each day column header based on the calendar week
+ */
_updateDayColumnHeader: function($weekDayColumns) {
var self = this;
var options = this.options;
@@ -1311,8 +1403,8 @@
},
/*
- * gets the calendar title options
- */
+ * gets the calendar title options
+ */
_getCalendarTitle: function() {
if ($.isFunction(this.options.title)) {
return this.options.title(this.options.daysToShow);
@@ -1320,14 +1412,58 @@
return this.options.title;
},
+//** UsersCombo - function called from selector's onchange
+ _switchCalViewForUser: function() {
+ var self = this;
+ var comboUserValue = self.element.find('#wc-user-combo').val();
+ if (comboUserValue != 'null' && comboUserValue !== null) {
+ self.options.showAsSeparateUsers = false;
+ }
+ else {
+ self.options.showAsSeparateUsers = true;
+ }
+ self.options.usersComboUser = comboUserValue;
+ $(self.element).html('');
+ self._rebuildCalendar(self._getCurrentScrollHour(), false);
+ },
+//**
+
/*
- * Render the events into the calendar
- */
+ * Render the events into the calendar
+ */
_renderEvents: function(data, $weekDayColumns) {
var self = this;
var options = this.options;
var eventsToRender;
+//** UsersCombo - render events for user
+ var userValue = self.options.usersComboUser;
+ if (self.options.showUsersCombo && $.isArray(data)) {
+ //if event comes from UsersCombo
+ if (userValue != 'null' && userValue !== null) {
+ var arrayIndex = 0;
+ while(arrayIndex < data.length) {
+ if(data[arrayIndex].userId != userValue) {
+ data.splice(arrayIndex, 1);
+ }
+ else {
+ arrayIndex++;
+ }
+ }
+ //if function is defined to store calendar params in session
+ if ($.isFunction(self.options.storeCalParamsInSessionFunction)) {
+ self.options.storeCalParamsInSessionFunction(self.options.daysToShow, userValue, self);
+ }
+ }
+ //if event comes from refeshing calendar (and session parameter)
+ else {
+ if ($.isFunction(self.options.storeCalParamsInSessionFunction)) {
+ self.options.storeCalParamsInSessionFunction(self.options.daysToShow, userValue, self);
+ }
+ }
+ }
+//**
+
if (data.options) {
var updateLayout = false;
//update options
@@ -1417,9 +1553,9 @@
},
/*
- * Render a specific event into the day provided. Assumes correct
- * day for calEvent date
- */
+ * Render a specific event into the day provided. Assumes correct
+ * day for calEvent date
+ */
_renderEvent: function(calEvent, $weekDay) {
var self = this;
var options = this.options;
@@ -1506,8 +1642,8 @@
/*
- * Find groups of overlapping events
- */
+ * Find groups of overlapping events
+ */
_groupOverlappingEventElements: function($weekDay) {
var $events = $weekDay.find('.wc-cal-event:visible');
var sortedEvents = $events.sort(function(a, b) {
@@ -1558,8 +1694,8 @@
/*
- * find the weekday in the current calendar that the calEvent falls within
- */
+ * find the weekday in the current calendar that the calEvent falls within
+ */
_findWeekDayForEvent: function(calEvent, $weekDayColumns) {
var $weekDay,
@@ -1589,8 +1725,8 @@
},
/*
- * update the events rendering in the calendar. Add if does not yet exist.
- */
+ * update the events rendering in the calendar. Add if does not yet exist.
+ */
_updateEventInCalendar: function(calEvent) {
var self = this;
self._cleanEvent(calEvent);
@@ -1599,7 +1735,7 @@
self.element.find('.wc-cal-event').each(function() {
if ($(this).data('calEvent').id === calEvent.id || $(this).hasClass('wc-new-cal-event')) {
$(this).remove();
- // return false;
+ // return false;
}
});
}
@@ -1618,8 +1754,8 @@
},
/*
- * Position the event element within the weekday based on it's start / end dates.
- */
+ * Position the event element within the weekday based on it's start / end dates.
+ */
_positionEvent: function($weekDay, $calEvent) {
var options = this.options;
var calEvent = $calEvent.data('calEvent');
@@ -1634,10 +1770,10 @@
},
/*
- * Determine the actual start and end times of a calevent based on it's
- * relative position within the weekday column and the starting hour of the
- * displayed calendar.
- */
+ * Determine the actual start and end times of a calevent based on it's
+ * relative position within the weekday column and the starting hour of the
+ * displayed calendar.
+ */
_getEventDurationFromPositionedEventElement: function($weekDay, $calEvent, top) {
var options = this.options;
var startOffsetMillis = options.businessHours.limitDisplay ? options.businessHours.start * 3600000 : 0;
@@ -1647,11 +1783,11 @@
},
/*
- * If the calendar does not allow event overlap, adjust the start or end date if necessary to
- * avoid overlapping of events. Typically, shortens the resized / dropped event to it's max possible
- * duration based on the overlap. If no satisfactory adjustment can be made, the event is reverted to
- * it's original location.
- */
+ * If the calendar does not allow event overlap, adjust the start or end date if necessary to
+ * avoid overlapping of events. Typically, shortens the resized / dropped event to it's max possible
+ * duration based on the overlap. If no satisfactory adjustment can be made, the event is reverted to
+ * it's original location.
+ */
_adjustForEventCollisions: function($weekDay, $calEvent, newCalEvent, oldCalEvent, maintainEventDuration) {
var options = this.options;
@@ -1711,8 +1847,8 @@
},
/*
- * Add draggable capabilities to an event
- */
+ * Add draggable capabilities to an event
+ */
_addDraggableToCalEvent: function(calEvent, $calEvent) {
var options = this.options;
$calEvent.draggable({
@@ -1732,8 +1868,8 @@
},
/*
- * Add droppable capabilites to weekdays to allow dropping of calEvents only
- */
+ * Add droppable capabilites to weekdays to allow dropping of calEvents only
+ */
_addDroppableToWeekDay: function($weekDay) {
var self = this;
var options = this.options;
@@ -1749,9 +1885,9 @@
if (showAsSeparatedUser) {
// we may have dragged the event on column with a new user.
// nice way to handle that is:
- // - get the newly dragged on user
- // - check if user is part of the event
- // - if yes, nothing changes, if not, find the old owner to remove it and add new one
+ // - get the newly dragged on user
+ // - check if user is part of the event
+ // - if yes, nothing changes, if not, find the old owner to remove it and add new one
var newUserId = $weekDay.data('wcUserId');
var userIdList = self._getEventUserId(calEvent);
var oldUserId = $(ui.draggable.parents('.wc-day-column-inner').get(0)).data('wcUserId');
@@ -1796,8 +1932,8 @@
},
/*
- * Add resizable capabilities to a calEvent
- */
+ * Add resizable capabilities to a calEvent
+ */
_addResizableToCalEvent: function(calEvent, $calEvent, $weekDay) {
var self = this;
var options = this.options;
@@ -1829,15 +1965,15 @@
},
/*
- * Refresh the displayed details of a calEvent in the calendar
- */
+ * Refresh the displayed details of a calEvent in the calendar
+ */
_refreshEventDetails: function(calEvent, $calEvent) {
- var suffix = '';
- if (!this.options.readonly &&
- this.options.allowEventDelete &&
- this.options.deletable(calEvent,$calEvent)) {
- suffix = '';
- }
+ var suffix = '';
+ if (!this.options.readonly &&
+ this.options.allowEventDelete &&
+ this.options.deletable(calEvent,$calEvent)) {
+ suffix = '';
+ }
$calEvent.find('.wc-time').html(this.options.eventHeader(calEvent, this.element) + suffix);
$calEvent.find('.wc-title').html(this.options.eventBody(calEvent, this.element));
$calEvent.data('calEvent', calEvent);
@@ -1845,16 +1981,16 @@
},
/*
- * Clear all cal events from the calendar
- */
+ * Clear all cal events from the calendar
+ */
_clearCalendar: function() {
this.element.find('.wc-day-column-inner div').remove();
this._clearFreeBusys();
},
/*
- * Scroll the calendar to a specific hour
- */
+ * Scroll the calendar to a specific hour
+ */
_scrollToHour: function(hour, animate) {
var self = this;
var options = this.options;
@@ -1885,8 +2021,8 @@
},
/*
- * find the hour (12 hour day) for a given hour index
- */
+ * find the hour (12 hour day) for a given hour index
+ */
_hourForIndex: function(index) {
if (index === 0) { //midnight
return 12;
@@ -1908,7 +2044,10 @@
},
_amOrPm: function(hourOfDay) {
- return hourOfDay < 12 ? 'AM' : 'PM';
+//** changed upper case AM/PM to lower case
+// return hourOfDay < 12 ? 'AM' : 'PM';
+ return hourOfDay < 12 ? 'am' : 'pm';
+//**
},
_isToday: function(date) {
@@ -1920,8 +2059,8 @@
},
/*
- * Clean events to ensure correct format
- */
+ * Clean events to ensure correct format
+ */
_cleanEvents: function(events) {
var self = this;
$.each(events, function(i, event) {
@@ -1931,8 +2070,8 @@
},
/*
- * Clean specific event
- */
+ * Clean specific event
+ */
_cleanEvent: function(event) {
if (event.date) {
event.start = event.date;
@@ -1945,8 +2084,8 @@
},
/*
- * Disable text selection of the elements in different browsers
- */
+ * Disable text selection of the elements in different browsers
+ */
_disableTextSelect: function($elements) {
$elements.each(function() {
if ($.browser.mozilla) {//Firefox
@@ -1964,8 +2103,8 @@
},
/*
- * returns the date on the first millisecond of the week
- */
+ * returns the date on the first millisecond of the week
+ */
_dateFirstDayOfWeek: function(date) {
var self = this;
var midnightCurrentDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
@@ -1976,8 +2115,8 @@
},
/*
- * returns the date on the first millisecond of the last day of the week
- */
+ * returns the date on the first millisecond of the last day of the week
+ */
_dateLastDayOfWeek: function(date) {
var self = this;
var midnightCurrentDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
@@ -1989,9 +2128,9 @@
},
/**
- * fix the date if it is not within given options
- * minDate and maxDate
- */
+ * fix the date if it is not within given options
+ * minDate and maxDate
+ */
_fixMinMaxDate: function(date) {
var minDate, maxDate;
date = this._cleanDate(date);
@@ -2029,8 +2168,8 @@
},
/*
- * gets the index of the current day adjusted based on options
- */
+ * gets the index of the current day adjusted based on options
+ */
_getAdjustedDayIndex: function(date) {
if (!this._startOnFirstDayOfWeek()) {
return 0;
@@ -2051,8 +2190,8 @@
},
/*
- * returns the date on the last millisecond of the week
- */
+ * returns the date on the last millisecond of the week
+ */
_dateLastMilliOfWeek: function(date) {
var lastDayOfWeek = this._dateLastDayOfWeek(date);
lastDayOfWeek = this._cloneDate(lastDayOfWeek);
@@ -2062,9 +2201,9 @@
},
/*
- * Clear the time components of a date leaving the date
- * of the first milli of day
- */
+ * Clear the time components of a date leaving the date
+ * of the first milli of day
+ */
_clearTime: function(d) {
d.setHours(0);
d.setMinutes(0);
@@ -2074,8 +2213,8 @@
},
/*
- * add specific number of days to date
- */
+ * add specific number of days to date
+ */
_addDays: function(d, n, keepTime) {
d.setDate(d.getDate() + n);
if (keepTime) {
@@ -2085,8 +2224,8 @@
},
/*
- * Rotate an array by specified number of places.
- */
+ * Rotate an array by specified number of places.
+ */
_rotate: function(a /*array*/, p /* integer, positive integer rotate to the right, negative to the left... */) {
for (var l = a.length, p = (Math.abs(p) >= l && (p %= l), p < 0 && (p += l), p), i, x; p; p = (Math.ceil(l / p) - 1) * p - l + (l = p)) {
for (i = l; i > p; x = a[--i], a[i] = a[i - p], a[i - p] = x) {}
@@ -2099,8 +2238,8 @@
},
/*
- * return a date for different representations
- */
+ * return a date for different representations
+ */
_cleanDate: function(d) {
if (typeof d == 'string') {
// if is numeric
@@ -2117,9 +2256,9 @@
},
/*
- * date formatting is adapted from
- * http://jacwright.com/projects/javascript/date_format
- */
+ * date formatting is adapted from
+ * http://jacwright.com/projects/javascript/date_format
+ */
_formatDate: function(date, format) {
var returnStr = '';
for (var i = 0; i < format.length; i++) {
@@ -2155,7 +2294,7 @@
n: function(date) { return date.getMonth() + 1; },
t: function(date) { var d = date; return new Date(d.getFullYear(), d.getMonth() + 1, 0).getDate() }, // Fixed now, gets #days of date
// Year
- L: function(date) { var year = date.getFullYear(); return (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)); }, // Fixed now
+ L: function(date) { var year = date.getFullYear(); return (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)); }, // Fixed now
o: function(date) { var d = new Date(date.valueOf()); d.setDate(d.getDate() - ((date.getDay() + 6) % 7) + 3); return d.getFullYear();}, //Fixed now
Y: function(date) { return date.getFullYear(); },
y: function(date) { return ('' + date.getFullYear()).substr(2); },
@@ -2190,8 +2329,8 @@
},
/**
- * return the user name for header
- */
+ * return the user name for header
+ */
_getUserName: function(index) {
var self = this;
var options = this.options;
@@ -2204,8 +2343,8 @@
}
},
/**
- * return the user id for given index
- */
+ * return the user id for given index
+ */
_getUserIdFromIndex: function(index) {
var self = this;
var options = this.options;
@@ -2215,8 +2354,8 @@
return index;
},
/**
- * returns the associated user index for given ID
- */
+ * returns the associated user index for given ID
+ */
_getUserIndexFromId: function(id) {
var self = this;
var options = this.options;
@@ -2228,9 +2367,9 @@
return 0;
},
/**
- * return the user ids for given calEvent.
- * default is calEvent.userId field.
- */
+ * return the user ids for given calEvent.
+ * default is calEvent.userId field.
+ */
_getEventUserId: function(calEvent) {
var self = this;
var options = this.options;
@@ -2243,9 +2382,9 @@
return [];
},
/**
- * sets the event user id on given calEvent
- * default is calEvent.userId field.
- */
+ * sets the event user id on given calEvent
+ * default is calEvent.userId field.
+ */
_setEventUserId: function(calEvent, userId) {
var self = this;
var options = this.options;
@@ -2256,9 +2395,9 @@
return calEvent;
},
/**
- * return the user ids for given freeBusy.
- * default is freeBusy.userId field.
- */
+ * return the user ids for given freeBusy.
+ * default is freeBusy.userId field.
+ */
_getFreeBusyUserId: function(freeBusy) {
var self = this;
var options = this.options;
@@ -2271,8 +2410,8 @@
/* FREEBUSY MANAGEMENT */
/**
- * ckean the free busy managers and remove all the freeBusy
- */
+ * ckean the free busy managers and remove all the freeBusy
+ */
_clearFreeBusys: function() {
if (this.options.displayFreeBusys) {
var self = this,
@@ -2289,8 +2428,8 @@
}
},
/**
- * retrieve placeholders for given freebusy
- */
+ * retrieve placeholders for given freebusy
+ */
_findWeekDaysForFreeBusy: function(freeBusy, $weekDays) {
var $returnWeekDays,
options = this.options,
@@ -2318,8 +2457,8 @@
},
/**
- * used to render all freeBusys
- */
+ * used to render all freeBusys
+ */
_renderFreeBusys: function(freeBusys) {
if (this.options.displayFreeBusys) {
var self = this,
@@ -2346,13 +2485,13 @@
}
});
- //now display freebusys on place holders
+ //now display freebusys on place holders
self._refreshFreeBusys($freeBusyPlaceholders);
}
},
/**
- * refresh freebusys for given placeholders
- */
+ * refresh freebusys for given placeholders
+ */
_refreshFreeBusys: function($freeBusyPlaceholders) {
if (this.options.displayFreeBusys && $freeBusyPlaceholders) {
var self = this,
@@ -2374,8 +2513,8 @@
}
},
/**
- * render a freebusy item on dedicated placeholders
- */
+ * render a freebusy item on dedicated placeholders
+ */
_renderFreeBusy: function(freeBusy, $freeBusyPlaceholder) {
if (this.options.displayFreeBusys) {
var self = this,
@@ -2392,8 +2531,8 @@
}
},
/*
- * Position the freebusy element within the weekday based on it's start / end dates.
- */
+ * Position the freebusy element within the weekday based on it's start / end dates.
+ */
_positionFreeBusy: function($placeholder, $freeBusy) {
var options = this.options;
var freeBusy = $freeBusy.data('wcFreeBusy');
@@ -2406,8 +2545,8 @@
$freeBusy.css({top: pxTop, height: pxHeight});
},
/*
- * Clean freebusys to ensure correct format
- */
+ * Clean freebusys to ensure correct format
+ */
_cleanFreeBusys: function(freebusys) {
var self = this,
freeBusyToReturn = [];
@@ -2421,8 +2560,8 @@
},
/*
- * Clean specific freebusy
- */
+ * Clean specific freebusy
+ */
_cleanFreeBusy: function(freebusy) {
if (freebusy.date) {
freebusy.start = freebusy.date;
@@ -2433,8 +2572,8 @@
},
/**
- * retrives the first freebusy manager matching demand.
- */
+ * retrives the first freebusy manager matching demand.
+ */
getFreeBusyManagersFor: function(date, users) {
var calEvent = {
start: date,
@@ -2444,8 +2583,8 @@
return this.getFreeBusyManagerForEvent(calEvent);
},
/**
- * retrives the first freebusy manager for given event.
- */
+ * retrives the first freebusy manager for given event.
+ */
getFreeBusyManagerForEvent: function(newCalEvent) {
var self = this,
options = this.options,
@@ -2473,9 +2612,9 @@
return freeBusyManager;
},
/**
- * appends the freebusys to replace the old ones.
- * @param {array|object} freeBusys freebusy(s) to apply.
- */
+ * appends the freebusys to replace the old ones.
+ * @param {array|object} freeBusys freebusy(s) to apply.
+ */
updateFreeBusy: function(freeBusys) {
var self = this,
options = this.options;
@@ -2504,15 +2643,15 @@
/* NEW OPTIONS MANAGEMENT */
/**
- * checks wether or not the calendar should be displayed starting on first day of week
- */
+ * checks wether or not the calendar should be displayed starting on first day of week
+ */
_startOnFirstDayOfWeek: function() {
return jQuery.isFunction(this.options.startOnFirstDayOfWeek) ? this.options.startOnFirstDayOfWeek(this.element) : this.options.startOnFirstDayOfWeek;
},
/**
- * finds out the current scroll to apply it when changing the view
- */
+ * finds out the current scroll to apply it when changing the view
+ */
_getCurrentScrollHour: function() {
var self = this;
var options = this.options;
@@ -2545,8 +2684,8 @@
/**
- * returns corrected date related to DST problem
- */
+ * returns corrected date related to DST problem
+ */
_getDSTdayShift: function(date, shift) {
var start = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0);
var offset1 = start.getTimezoneOffset();
@@ -2623,9 +2762,9 @@
};
/**
- * @constructor
- * single user freebusy manager.
- */
+ * @constructor
+ * single user freebusy manager.
+ */
var FreeBusy = function(options) {
this.options = $.extend({}, options || {});
};
@@ -2643,14 +2782,14 @@
};
$.extend(FreeBusyManager.prototype, FreeBusyProto, {
/**
- * return matching freeBusys.
- * if you do not pass any argument, returns all freebusys.
- * if you only pass a start date, only matchinf freebusy will be returned.
- * if you pass 2 arguments, then all freebusys available within the time period will be returned
- * @param {Date} start [optionnal] if you do not pass end date, will return the freeBusy within which this date falls.
- * @param {Date} end [optionnal] the date where to stop the search.
- * @return {Array} an array of FreeBusy matching arguments.
- */
+ * return matching freeBusys.
+ * if you do not pass any argument, returns all freebusys.
+ * if you only pass a start date, only matchinf freebusy will be returned.
+ * if you pass 2 arguments, then all freebusys available within the time period will be returned
+ * @param {Date} start [optionnal] if you do not pass end date, will return the freeBusy within which this date falls.
+ * @param {Date} end [optionnal] the date where to stop the search.
+ * @return {Array} an array of FreeBusy matching arguments.
+ */
getFreeBusys: function() {
switch (arguments.length) {
case 0:
@@ -2727,31 +2866,31 @@
var curFreeBusyItem = this;
if (curFreeBusyItem.isWithin(start) && curFreeBusyItem.isWithin(end)) {
/*
- we are in case where inserted freebusy fits in curFreeBusyItem:
- curFreeBusyItem: *-----------------------------*
- freeBusy: *-------------*
- obviously, start and end indexes are this item.
+ we are in case where inserted freebusy fits in curFreeBusyItem:
+ curFreeBusyItem: *-----------------------------*
+ freeBusy: *-------------*
+ obviously, start and end indexes are this item.
*/
startIndex = index;
endIndex = index;
if (start.getTime() == curFreeBusyItem.getStart().getTime() && end.getTime() == curFreeBusyItem.getEnd().getTime()) {
/*
- in this case, inserted freebusy is exactly curFreeBusyItem:
- curFreeBusyItem: *-----------------------------*
- freeBusy: *-----------------------------*
-
- just replace curFreeBusyItem with freeBusy.
+ in this case, inserted freebusy is exactly curFreeBusyItem:
+ curFreeBusyItem: *-----------------------------*
+ freeBusy: *-----------------------------*
+
+ just replace curFreeBusyItem with freeBusy.
*/
var _f1 = new FreeBusy(freeBusy.getOption());
pushNewFreeBusy(_f1);
}
else if (start.getTime() == curFreeBusyItem.getStart().getTime()) {
/*
- in this case inserted freebusy starts with curFreeBusyItem:
- curFreeBusyItem: *-----------------------------*
- freeBusy: *--------------*
-
- just replace curFreeBusyItem with freeBusy AND the rest.
+ in this case inserted freebusy starts with curFreeBusyItem:
+ curFreeBusyItem: *-----------------------------*
+ freeBusy: *--------------*
+
+ just replace curFreeBusyItem with freeBusy AND the rest.
*/
var _f1 = new FreeBusy(freeBusy.getOption());
var _f2 = new FreeBusy(curFreeBusyItem.getOption());
@@ -2761,11 +2900,11 @@
}
else if (end.getTime() == curFreeBusyItem.getEnd().getTime()) {
/*
- in this case inserted freebusy ends with curFreeBusyItem:
- curFreeBusyItem: *-----------------------------*
- freeBusy: *--------------*
-
- just replace curFreeBusyItem with before part AND freeBusy.
+ in this case inserted freebusy ends with curFreeBusyItem:
+ curFreeBusyItem: *-----------------------------*
+ freeBusy: *--------------*
+
+ just replace curFreeBusyItem with before part AND freeBusy.
*/
var _f1 = new FreeBusy(curFreeBusyItem.getOption());
_f1.setOption('end', start);
@@ -2775,11 +2914,11 @@
}
else {
/*
- in this case inserted freebusy is within curFreeBusyItem:
- curFreeBusyItem: *-----------------------------*
- freeBusy: *--------------*
-
- just replace curFreeBusyItem with before part AND freeBusy AND the rest.
+ in this case inserted freebusy is within curFreeBusyItem:
+ curFreeBusyItem: *-----------------------------*
+ freeBusy: *--------------*
+
+ just replace curFreeBusyItem with before part AND freeBusy AND the rest.
*/
var _f1 = new FreeBusy(curFreeBusyItem.getOption());
var _f2 = new FreeBusy(freeBusy.getOption());
@@ -2791,18 +2930,18 @@
pushNewFreeBusy(_f3);
}
/*
- as work is done, no need to go further.
- return false
+ as work is done, no need to go further.
+ return false
*/
return false;
}
else if (curFreeBusyItem.isWithin(start) && curFreeBusyItem.getEnd().getTime() != start.getTime()) {
/*
- in this case, inserted freebusy starts within curFreeBusyItem:
- curFreeBusyItem: *----------*
- freeBusy: *-------------------*
-
- set start index AND insert before part, we'll insert freebusy later
+ in this case, inserted freebusy starts within curFreeBusyItem:
+ curFreeBusyItem: *----------*
+ freeBusy: *-------------------*
+
+ set start index AND insert before part, we'll insert freebusy later
*/
if (curFreeBusyItem.getStart().getTime() != start.getTime()) {
var _f1 = new FreeBusy(curFreeBusyItem.getOption());
@@ -2813,11 +2952,11 @@
}
else if (curFreeBusyItem.isWithin(end) && curFreeBusyItem.getStart().getTime() != end.getTime()) {
/*
- in this case, inserted freebusy starts within curFreeBusyItem:
- curFreeBusyItem: *----------*
- freeBusy: *-------------------*
-
- set end index AND insert freebusy AND insert after part if needed
+ in this case, inserted freebusy starts within curFreeBusyItem:
+ curFreeBusyItem: *----------*
+ freeBusy: *-------------------*
+
+ set end index AND insert freebusy AND insert after part if needed
*/
pushNewFreeBusy(new FreeBusy(freeBusy.getOption()));
if (end.getTime() < curFreeBusyItem.getEnd().getTime()) {
@@ -2840,25 +2979,25 @@
if (endIndex < tmpFB.length) {
this.freeBusys = this.freeBusys.concat(tmpFB.slice(endIndex + 1));
}
-/* if(start.getDate() == 1){
+ /* if(start.getDate() == 1){
console.info('insert from '+freeBusy.getStart() +' to '+freeBusy.getEnd());
- console.log('index from '+ startIndex + ' to ' + endIndex);
- var str = [];
- $.each(tmpFB, function(i){str.push(i + ": " + this.getStart().getHours() + ' > ' + this.getEnd().getHours() + ' ' + (this.getOption('free') ? 'free' : 'busy'))});
- console.log(str.join('\n'));
-
- console.log('insert');
- var str = [];
- $.each(newFreeBusys, function(i){str.push(this.getStart().getHours() + ' > ' + this.getEnd().getHours())});
- console.log(str.join(', '));
-
- console.log('results');
- var str = [];
- $.each(this.freeBusys, function(i){str.push(i + ": " + this.getStart().getHours() + ' > ' + this.getEnd().getHours() + ' ' + (this.getOption('free') ? 'free' :'busy'))});
- console.log(str.join('\n'));
+ console.log('index from '+ startIndex + ' to ' + endIndex);
+ var str = [];
+ $.each(tmpFB, function(i){str.push(i + ": " + this.getStart().getHours() + ' > ' + this.getEnd().getHours() + ' ' + (this.getOption('free') ? 'free' : 'busy'))});
+ console.log(str.join('\n'));
+
+ console.log('insert');
+ var str = [];
+ $.each(newFreeBusys, function(i){str.push(this.getStart().getHours() + ' > ' + this.getEnd().getHours())});
+ console.log(str.join(', '));
+
+ console.log('results');
+ var str = [];
+ $.each(this.freeBusys, function(i){str.push(i + ": " + this.getStart().getHours() + ' > ' + this.getEnd().getHours() + ' ' + (this.getOption('free') ? 'free' :'busy'))});
+ console.log(str.join('\n'));
}*/
return this;
}
});
-})(jQuery);
+})(jQuery);
\ No newline at end of file
diff --git a/kamileczek123_demo/demo.css b/kamileczek123_demo/demo.css
new file mode 100755
index 0000000..506cbfa
--- /dev/null
+++ b/kamileczek123_demo/demo.css
@@ -0,0 +1,344 @@
+.wc-container {
+ font-size: 14px;
+ font-family: arial, helvetica;
+ border: 1px solid #ccc;
+}
+
+.wc-toolbar {
+ font-size: 12px;
+ padding: 2px 5px;
+ margin: 0;
+}
+
+.wc-toolbar .wc-nav {
+ float:left;
+}
+
+/* calendar navigaion button fix */
+.wc-nav .ui-button-icon-only .ui-icon {
+ left: 1em;
+}
+
+.wc-toolbar .wc-display {
+ float: right;
+}
+
+.wc-toolbar button {
+ margin-top: 0;
+ margin-bottom: 0;
+}
+
+.wc-toolbar .ui-buttonset {
+ font-size: 0.8em;
+}
+
+.wc-toolbar .wc-title {
+ text-align: center;
+ padding: 0;
+ margin: 0 0 0 100px;
+}
+
+.wc-toolbar h1{
+ font-size: 14px;
+ font-weight: bold;
+ display: inline;
+}
+
+.wc-container table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+
+.wc-container table td {
+ margin: 0;
+ padding: 0;
+}
+
+.wc-header{
+ background: #eee;
+ border-width:1px 0;
+ border-style:solid;
+ font-size: 9px;
+}
+
+.wc-header table{
+ width: 100%;
+ table-layout:fixed;
+}
+
+.wc-grid-timeslot-header, .wc-header .wc-time-column-header {
+ width: 45px;
+}
+
+.wc-header .wc-scrollbar-shim {
+ width: 16px;
+}
+
+.wc-header .wc-day-column-header {
+ text-align: center;
+ padding: 1px;
+}
+
+.wc-header .wc-user-header{
+ text-align: center;
+ padding: 1px 0;
+ overflow:hidden;
+}
+
+.wc-grid-timeslot-header {
+ background: #eee;
+}
+
+.wc-scrollable-grid {
+ overflow: auto;
+ overflow-x: hidden !important;
+ overflow-y: auto !important;
+ position: relative;
+ background-color: #fff;
+ width: 100%;
+}
+
+table.wc-time-slots {
+ width: 100%;
+ table-layout: fixed;
+ cursor: default;
+ overflow:hidden;
+}
+
+.wc-day-column {
+ width: 13.5%;
+ overflow: visible;
+ vertical-align: top;
+}
+
+.wc-day-column-header{
+ border-width: 0 0 1px 3px;
+ border-style: solid;
+ border-color:transparent;
+}
+
+.wc-scrollable-grid .wc-day-column-last, .wc-scrollable-grid .wc-day-column-middle{
+ border-width: 0 0 0 1px;
+ border-style: dashed;
+}
+
+.wc-scrollable-grid .wc-day-column-first{
+ border-width: 0 0 0 3px;
+ border-style: ridge;
+ border-color: #444;
+}
+
+.wc-day-column-inner {
+ width: 100%;
+ position:relative;
+}
+
+.wc-no-height-wrapper{
+ position:relative;
+ overflow: visible;
+ height: 0px;
+}
+
+.wc-time-slot-wrapper {
+ /* top: 3px;*/
+}
+.wc-oddeven-wrapper .wc-full-height-column{
+ /* top: 2px; */
+ /* Modern Browsers */ opacity: 0.4;
+ /* IE 8 */ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=40)";
+ /* IE 5-7 */ filter: alpha(opacity=40);
+ /* Netscape */ -moz-opacity: 0.4;
+ /* Safari 1 */ -khtml-opacity: 0.4;
+}
+.wc-freebusy-wrapper .wc-freebusy{
+ /* top: 1px;*/
+ /* Modern Browsers */ opacity: 0.4;
+ /* IE 8 */ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=40)";
+ /* IE 5-7 */ filter: alpha(opacity=40);
+ /* Netscape */ -moz-opacity: 0.4;
+ /* Safari 1 */ -khtml-opacity: 0.4;
+}
+
+.wc-time-slots {
+ position: absolute;
+ width: 100%;
+}
+
+.wc-column-odd, .wc-column-even.ui-state-hover {
+ background-image: none;
+ border: none;
+}
+
+.wc-column-even {
+ background-color: #ffff99;
+}
+.wc-header .wc-today.ui-state-active{
+ background-image:none;
+ background-color: #ff9900;
+}
+.ui-state-active.wc-today {
+ background-color: #ff9900;
+}
+
+.wc-header .wc-today.wc-day-column-header{
+ border-width:0 1px;
+ border-style: solid;
+}
+
+.wc-header .wc-user-header{
+ border-width: 0;
+}
+
+.wc-time-slots .wc-day-column.ui-state-default{
+ background: transparent;
+}
+
+.wc-time-slots .wc-today.ui-state-active{
+ background-image: none;
+}
+
+.wc-header .wc-today.ui-state-active.wc-day-column-middle{
+ border-width: 0;
+}
+
+.wc-header .wc-today.ui-state-active.wc-day-column-first{
+ border-left-width: 1px;
+}
+
+.wc-header .wc-today.ui-state-active.wc-day-column-last{
+ border-right-width: 1px;
+}
+
+.wc-full-height-column{
+ display:block;
+ /* width:100%;*/
+}
+
+.wc-time-header-cell {
+ padding: 5px;
+ height: 80px; /* reference height */
+ font-size: 11px;
+ font-weight: bold;
+}
+
+.wc-time-slot {
+ border-bottom: 1px dotted #ddd;
+}
+
+.wc-hour-header {
+ text-align: right;
+}
+.wc-hour-header.ui-state-active, .wc-hour-header.ui-state-default{
+ border-width:0 0 1px 0;
+ background-image: none;
+}
+
+.wc-hour-end, .wc-hour-header {
+ border-bottom: 1px solid #ccc;
+ color: #999;
+}
+
+.wc-business-hours {
+ background-color: #E6EEF1;
+ border-bottom: 1px solid #ccc;
+ color: #333;
+ font-size: 12px;
+ font-weight: bold;
+}
+
+.wc-day-header-cell {
+ text-align: center;
+ vertical-align: middle;
+ padding: 5px;
+}
+
+.wc-time-slot-header .wc-header-cell {
+ text-align: right;
+ padding-right: 10px;
+}
+
+.wc-cal-event {
+ background-color: #68a1e5;
+ /* Modern Browsers */ opacity: 0.8;
+ /* IE 8 */ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";
+ /* IE 5-7 */ filter: alpha(opacity=80);
+ /* Netscape */ -moz-opacity: 0.8;
+ /* Safari 1 */ -khtml-opacity: 0.8;
+ position: absolute;
+ text-align: center;
+ overflow: hidden;
+ cursor: pointer;
+ color: #fff;
+ width: 100%;
+ display: none;
+}
+
+.wc-cal-event.ui-resizable-resizing {
+ cursor: s-resize;
+}
+
+.wc-cal-event .wc-time {
+ background-color: #2b72d0;
+ border: 1px solid #1b62c0;
+ color: #fff;
+ padding: 0;
+ font-weight: normal;
+ font-size: 8px;
+ line-height: 10px;
+ text-align: left;
+}
+
+.wc-container .ui-draggable .wc-time {
+ cursor: move;
+}
+
+.wc-cal-event .wc-title {
+ position: relative;
+ font-size: 8px;
+ padding: 0px;
+ margin: 0px;
+ line-height: 10px;
+
+}
+
+.wc-container .ui-resizable-s {
+ height: 10px;
+ line-height: 10px;
+ bottom: -2px;
+ font-size: .75em;
+}
+
+
+.wc-container .ui-draggable-dragging {
+ z-index: 1000;
+}
+
+.wc-title hr {
+ border: 0;
+ width: 90%;
+ color: #0080FF;
+ background-color: #0080FF;
+ height: 1px;
+ margin-top: 1px;
+ margin-bottom: 1px;
+}
+
+.free-busy-free{
+}
+
+.free-busy-busy{
+ background:url("./libs/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png") repeat scroll 50% 50% #666666;
+}
+
+/* IE6 hacks */
+* html .wc-no-height-wrapper{position:absolute;}
+* html .wc-time-slot-wrapper{top:3px;}
+* html .wc-grid-row-oddeven{top:2px;}
+* html .wc-grid-row-freebusy{top:1px;}
+
+/* IE7 hacks */
+*:first-child+html .wc-no-height-wrapper{position:relative;}
+*:first-child+html .wc-time-slot-wrapper{top:3px;}
+*:first-child+html .wc-grid-row-oddeven{top:2px;}
+*:first-child+html .wc-grid-row-freebusy{top:1px;}
+*:first-child+html .wc-time-slots .wc-today{/* due to rendering issues, no background */background:none;}
diff --git a/kamileczek123_demo/demo.html b/kamileczek123_demo/demo.html
new file mode 100644
index 0000000..3a16e33
--- /dev/null
+++ b/kamileczek123_demo/demo.html
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
jQuery Week Calendar (kamileczek123 demo)
+
+
+
diff --git a/kamileczek123_demo/demo.js b/kamileczek123_demo/demo.js
new file mode 100644
index 0000000..e13a445
--- /dev/null
+++ b/kamileczek123_demo/demo.js
@@ -0,0 +1,542 @@
+$(document).ready(function() {
+
+ //example user objects array which would come from web container
+ var usersJsonArray = {
+ "jsonStaffArray":[
+ {"staffId":3,"userId":0,"userShortName":"BobBoo"},
+ {"staffId":6,"userId":1,"userShortName":"MarSmi"},
+ {"staffId":2,"userId":2,"userShortName":"MelDoe"}
+ ]}.jsonStaffArray;
+ //prepare staff mapping object
+ $staffIdMappingHash = doStaffIdMapping(usersJsonArray);
+ //display google calendar like events headers
+ var googleCalendarLikeEventHeader = true;
+ var $calendar = $('#calendar');
+
+ $calendar.weekCalendar({
+ eventNew : function(calEvent, $event) {
+ $('')
+ .html(
+ "
" +
+ "" +
+ "
" +
+ "
" +
+ "" +
+ "
" +
+ "
" +
+ "" +
+ "
"
+ )
+ .dialog({
+ autoOpen: false,
+ dialogClass: 'alert',
+ resizable: false,
+ modal: true,
+ width: 460,
+ open: function(event, ui){
+ $('.ui-dialog .ui-dialog-content').css('overflow','hidden');
+ $('.ui-widget-overlay').css('width','100%');
+
+ $('.alert').css('background', 'none');
+ $('.alert').css('background-color', '#fff');
+ },
+ close: function(event, ui){
+ $('.ui-dialog .ui-dialog-content').css('overflow','auto');
+ $('#calendar').weekCalendar('removeUnsavedEvents');
+ $(this).remove();
+ },
+ show: 'fade',
+ hide: 'fade'
+ });
+ $('#newEventDialog').dialog('open');
+
+//example of ajax call how to use calendar user mapping on objects existing at server side
+/*
+ $.ajax({
+ //url to your web server method which will handle calendar's event params and send eg. some event details in
+ //response - like list of possible tasks, etc.
+ url: "",
+ type: "POST",
+ dataType: "json",
+ contentType: "application/x-www-form-urlencoded;charset=utf-8",
+ data: {
+ //send some event data to server - especially user id mapped from calendar
+ isoDateStart: calEvent.start.toString('yyyy-MM-dd HH:mm'),
+ userId: function() {
+ var usersComboUser = $calendar.weekCalendar("option", "usersComboUser");
+ var result = null;
+ if(usersComboUser != 'null' && usersComboUser !== null) {
+ result = $staffIdMappingHash.getItem(usersComboUser);
+ }
+ else {
+ result = $staffIdMappingHash.getItem(calEvent.userId);
+ }
+ return result;
+ }
+ },
+ success: function(data) {
+ //data should return some parameters from server related to new event, it depends what you want to add
+ //to the event and what logic your event at server side has
+ $('')
+ .html(
+ "
" +
+ "" +
+ "
" +
+ "
" +
+ "" +
+ "
" +
+ "
" +
+ "" +
+ "
"
+ )
+ .dialog({
+ autoOpen: false,
+ dialogClass: 'alert',
+ resizable: false,
+ modal: true,
+ width: 460,
+ open: function(event, ui){
+ $('.ui-dialog .ui-dialog-content').css('overflow','hidden');
+ $('.ui-widget-overlay').css('width','100%');
+
+ $('.alert').css('background', 'none');
+ $('.alert').css('background-color', '#fff');
+ },
+ close: function(event, ui){
+ $('.ui-dialog .ui-dialog-content').css('overflow','auto');
+ $('#calendar').weekCalendar('removeUnsavedEvents');
+ $(this).remove();
+ },
+ show: 'fade',
+ hide: 'fade'
+ });
+ $('#newEventDialog').dialog('open');
+ },
+ error: function() {
+ alert("Server connection error: getParamsForCalendarEvent.");
+ },
+ statusCode: httpStatusCodes
+ })
+*/
+ },
+ date: new Date(),
+ height: function($calendar){
+ return (24 - 6) * 2 * 25 + (3 * 25);
+ },
+ showAsSeparateUsers: true,
+ timeslotsPerHour: 2,
+ displayOddEven: true,
+ timeslotHeight: 25,
+ firstDayOfWeek: 1,
+ businessHours: {start: 6, end: 24, limitDisplay: true},
+ startOnFirstDayOfWeek: false,
+ timeFormat: "h:i a",
+ dateFormat: "d F Y",
+ use24Hour: false,
+//body of this function can store some param from calendar in your web application session object, thus if you
+//refresh calendar or go back to it from other page its view will like previously when you left it
+ storeCalParamsInSessionFunction: function(daysToShow, calendarUser, calendar) {
+/*
+//example of callback function to store calendar params in web container session
+ var initDate = 0;
+ if(daysToShow == 0) {
+ initDate = calendar.options.date.getTime();
+ }
+ $.ajax({
+ async: false,
+ //url to your web server method which will handle calendar params and put it into session
+ url: "",
+ type: "POST",
+ dataType: "json",
+ contentType: "application/x-www-form-urlencoded;charset=utf-8",
+ data: {
+ calDaysToShowInSession: daysToShow,
+ calDateInSession: initDate,
+ calUserToShowInSession: calendar.options.usersComboUser
+ },
+ success: function(data) {
+ calendar.options.daysToShow = data.calDaysToShowInSession;
+ calendar.options.date = new Date(data.calDateInSession);
+ calendar.options.usersComboUser = data.calUserToShowInSession;
+ },
+ error: function() {
+ alert("Server connection error: setSessionCalendarParameters.");
+ },
+ statusCode: httpStatusCodes
+ });
+*/
+ },
+ daysToShow: 7,
+ data: function(start, end, callback) {
+ callback(getWrappedEventsArray(getEventData(), usersJsonArray));
+/*
+//example of function which retrieves data for event through ajax from web container
+ $.ajax({
+ //block calendar while data for events is retrieved from web server
+ beforeSend: function() {
+ $.blockUI({
+ css: {
+ border: 'none',
+ padding: '15px',
+ backgroundColor: '#000',
+ '-webkit-border-radius': '10px',
+ '-moz-border-radius': '10px',
+ opacity: .5,
+ color: '#fff'
+ },
+ message: '
Please wait...
',
+ fadeIn: 200,
+ fadeOut: 200,
+ blockMsgClass: 'blockMsg ui-corner-all'
+ });
+ },
+ complete: function() {
+ $.unblockUI();
+ },
+ //url to your web server method which will send in response your calendar events based on requested dates
+ url: "",
+ type: "POST",
+ dataType: "json",
+ contentType: "application/x-www-form-urlencoded;charset=utf-8",
+ data: {
+ calStartTimestamp: start.getTime(),
+ calEndTimestamp: end.getTime()
+ },
+ success: function(data) {
+ var eventsJsonArray = data.jsonEventsArray;
+ //remapping events and users from web server into calendar users index
+ callback(getWrappedEventsArray(eventsJsonArray, usersJsonArray));
+ },
+ error: function() {
+ alert("Server connection error: getCalendarEvents.");
+ },
+ statusCode: httpStatusCodes
+ });
+*/
+ },
+ //example on how web servers users are remapped into calendar users
+ users: getWrappedUserNamesArray(usersJsonArray),
+ showUsersCombo: true,
+ //initial user in users combo for who the calendar is rendered (mostly taken from session, when calendar is reopen)
+ //it should replaced at server side on something like this:
+ //if(usersComboUser != null) {set usersComboUser} else {"null"}
+ usersComboUser: "null",
+ //starting element in users combo description
+ usersComboAllUsersEntry: 'All',
+ buttons: true,
+ buttonText: {today : 'today', lastWeek : '<', nextWeek : '>'},
+ shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
+ longMonths: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
+ shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
+ longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
+ headerSeparator: "",
+ //definition of google calendar like event header
+ eventHeader: function(calEvent, calendar) {
+ var header;
+ if(googleCalendarLikeEventHeader) {
+ if($("#calendar").weekCalendar("option", "use24Hour")){
+ if(new Date(calEvent.start.getTime()).toString('mm') == '00'){
+ header = new Date(calEvent.start.getTime()).toString('H');
+ }
+ else {
+ header = new Date(calEvent.start.getTime()).toString('H:mm');
+ }
+ if(calEvent.start.getTime() != calEvent.end.getTime()) {
+ header += " - ";
+ if(new Date(calEvent.end.getTime()).toString('mm') == '00'){
+ header += new Date(calEvent.end.getTime()).toString('H');
+ }
+ else {
+ header += new Date(calEvent.end.getTime()).toString('H:mm');
+ }
+ }
+ }
+ else {
+ header = new Date(calEvent.start.getTime()).toString('h');
+ if(new Date(calEvent.start.getTime()).toString('mm') != '00'){
+ header += ":" + new Date(calEvent.start.getTime()).toString('mm');
+ }
+ if(new Date(calEvent.start.getTime()).toString('tt') == 'PM'){
+ header += "p";
+ }
+ if(calEvent.start.getTime() != calEvent.end.getTime()) {
+ header += " - ";
+ header += new Date(calEvent.end.getTime()).toString('h');
+ if(new Date(calEvent.end.getTime()).toString('mm') != '00'){
+ header += ":" + new Date(calEvent.end.getTime()).toString('mm');
+ }
+ if(new Date(calEvent.end.getTime()).toString('tt') == 'PM'){
+ header += "p";
+ }
+ }
+ }
+ }
+ else {
+ header = calendar.weekCalendar('formatTime', calEvent.start) + " - " + calendar.weekCalendar('formatTime', calEvent.end);
+ }
+ return header;
+ },
+ newEventText: "",
+ timeSeparator: " ",
+ allowCalEventOverlap: true,
+ overlapEventsSeparate: true,
+ useShortDayNames: false,
+ title: function(date, calendar) {
+ return "%date%";
+ },
+ //datepicker reginal translation
+ datepicker: $.datepicker.regional['en'],
+ resizable: function(calEvent, $event) {
+ return false;
+ },
+ draggable: function(calEvent, $event) {
+ var d1 = new Date(calEvent.end).clearTime();
+ var d2 = new Date().clearTime();
+ if(d1 < d2) {
+ return false;
+ }
+ return true;
+ },
+ eventRender: function(calEvent, $event) {
+ var d1 = new Date(calEvent.end).clearTime();
+ var d2 = new Date().clearTime();
+ if(d1 < d2) {
+ $event.find(".wc-time").css({"backgroundColor": "#FF5C55", "border":"1px solid #FF5C55"});
+ }
+ },
+ eventClick: function(calEvent, element, freeBusyManager, $calendar, DomEvent) {
+ $properties = { title: calEvent.title };
+ var d1 = new Date(calEvent.end).clearTime();
+ var d2 = new Date().clearTime();
+ if(d1 < d2) {
+ $properties = "Non-editable";
+ }
+ else {
+ $properties = "Editable";
+ }
+ $('')
+ .html(
+ "
" +
+ "" +
+ "
" +
+ "
" +
+ "" +
+ "
" +
+ "
" +
+ "" +
+ "
"
+ )
+ .dialog({
+ autoOpen: false,
+ dialogClass: 'alert',
+ resizable: false,
+ modal: true,
+ width: 460,
+ open: function(event, ui){
+ $('.ui-dialog .ui-dialog-content').css('overflow','hidden');
+ $('.ui-widget-overlay').css('width','100%');
+
+ $('.alert').css('background', 'none');
+ $('.alert').css('background-color', '#fff');
+ },
+ close: function(event, ui){
+ $('.ui-dialog .ui-dialog-content').css('overflow','auto');
+ $('#calendar').weekCalendar('removeUnsavedEvents');
+ $(this).remove();
+ },
+ show: 'fade',
+ hide: 'fade'
+ });
+ $('#editEventDialog').dialog('open');
+ },
+ eventDrop: function(calEvent, $event) {
+//example how to save moved and dropped event through ajax
+/*
+ $.ajax({
+ async: false,
+ //url to your web server method which will store new calendar's event params
+ url: "",
+ type: "POST",
+ dataType: "json",
+ contentType: "application/x-www-form-urlencoded;charset=utf-8",
+ data: {
+ id: calEvent.id,
+ isoDateStart: calEvent.start.toString('yyyy-MM-dd HH:mm'),
+ userId: $staffIdMappingHash.getItem(calEvent.userId)
+ },
+ success: function(data) {
+ //tweak for response content
+ data = "OK";
+ if(data == 'OK') {
+ $('#calendar').weekCalendar('refresh');
+ }
+ else {
+ $('#calendar').weekCalendar('removeUnsavedEvents');
+ }
+ },
+ error: function() {
+ alert("Server connection error: updateCalendarVisit.");
+ },
+ statusCode: httpStatusCodes
+ });
+*/
+ }
+ });
+});
+
+//example events data
+function getEventData() {
+ var year = new Date().getFullYear();
+ var month = new Date().getMonth();
+ var day = new Date().getDate();
+
+ return {
+ jsonEventArray : [
+ {
+ "id":1,
+ "userId":6,
+ "start": new Date(year, month, day, 8),
+ "end": new Date(year, month, day, 10, 30),
+ "title":"Event 1Name 1Description 1"
+ },
+ {
+ "id":2,
+ "userId":2,
+ "start": new Date(year, month, day, 14),
+ "end": new Date(year, month, day, 14, 45),
+ "title":"Event 2Name 2Description 2"
+ },
+ {
+ "id":3,
+ "userId":2,
+ "start": new Date(year, month, day + 1, 10),
+ "end": new Date(year, month, day + 1, 11),
+ "title":"Event 3Name 3Description 3"
+ },
+ {
+ "id":4,
+ "userId":3,
+ "start": new Date(year, month, day + 1, 14),
+ "end": new Date(year, month, day + 1, 14, 30),
+ "title":"Event 4Name 4Description 4"
+ },
+ {
+ "id":5,
+ "userId":3,
+ "start": new Date(year, month, day + 2, 15),
+ "end": new Date(year, month, day + 2, 16),
+ "title":"Event 5Name 5Description 5"
+ },
+ {
+ "id":6,
+ "userId":6,
+ "start": new Date(year, month, day + 2, 9),
+ "end": new Date(year, month, day + 2, 11),
+ "title":"Event 6Name 6Description 6"
+ }
+ ]
+ }.jsonEventArray;
+}
+
+function getWrappedUserNamesArray(jsonUsers) {
+ var usersArray = new Array();
+ for(var i=0; i < jsonUsers.length; i++) {
+ usersArray.push(jsonUsers[i].userShortName);
+ }
+ return usersArray;
+}
+
+function getWrappedEventsArray(jsonEvents, jsonUsers) {
+ var staffIdMappingHash = doStaffIdMapping(jsonUsers);
+ for(var i=0; i < jsonEvents.length; i++) {
+ for(var j=0; j < staffIdMappingHash.size(); j++) {
+ if(staffIdMappingHash.getItem(j) == jsonEvents[i].userId) {
+ jsonEvents[i].userId = j;
+ break;
+ }
+ }
+ }
+ return jsonEvents;
+}
+
+function doStaffIdMapping(jsonUsers) {
+ var mappedUsersHash = new Hash();
+ for(i=0; i < jsonUsers.length; i++) {
+ mappedUsersHash.setItem(jsonUsers[i].userId, jsonUsers[i].staffId);
+ }
+ return mappedUsersHash;
+}
+
+var httpStatusCodes = {
+ 505: function() { alert('Error 505: HTTP Version Not Supported'); },
+ 504: function() { alert('Error 504: Gateway Timeout'); },
+ 503: function() { alert('Error 503: Service Unavailable'); },
+ 502: function() { alert('Error 502: Bad Gateway'); },
+ 501: function() { alert('Error 501: Not Implemented'); },
+ 500: function() { alert('Error 500: Internal Server Error'); },
+ 408: function() { alert('Error 408: Request Timeout'); },
+ 404: function() { alert('Error 404: Page Not Found'); },
+ 403: function() { alert('Error 403: Forbidden'); },
+ 401: function() { alert('Error 401: Unauthorized'); },
+ 400: function() { alert('Error 400: Bad Request'); }
+ }
+
+function Hash() {
+ this.length = 0;
+ this.items = new Array();
+ for (var i = 0; i < arguments.length; i += 2) {
+ if (typeof(arguments[i + 1]) != 'undefined') {
+ this.items[arguments[i]] = arguments[i + 1];
+ this.length++;
+ }
+ }
+
+ this.removeItem = function(in_key) {
+ var tmp_previous;
+ if (typeof(this.items[in_key]) != 'undefined') {
+ this.length--;
+ var tmp_previous = this.items[in_key];
+ delete this.items[in_key];
+ }
+ return tmp_previous;
+ }
+
+ this.getItem = function(in_key) {
+ return this.items[in_key];
+ }
+
+ this.setItem = function(in_key, in_value) {
+ var tmp_previous;
+ if (typeof(in_value) != 'undefined') {
+ if (typeof(this.items[in_key]) == 'undefined') {
+ this.length++;
+ }
+ else {
+ tmp_previous = this.items[in_key];
+ }
+ this.items[in_key] = in_value;
+ }
+ return tmp_previous;
+ }
+
+ this.hasItem = function(in_key) {
+ return typeof(this.items[in_key]) != 'undefined';
+ }
+
+ this.clear = function() {
+ for (var i in this.items) {
+ delete this.items[i];
+ }
+ this.length = 0;
+ }
+
+ this.size = function() {
+ return this.items.length;
+ }
+}
\ No newline at end of file
diff --git a/kamileczek123_demo/jquery-blockUI-2.39.js b/kamileczek123_demo/jquery-blockUI-2.39.js
new file mode 100755
index 0000000..55b52a9
--- /dev/null
+++ b/kamileczek123_demo/jquery-blockUI-2.39.js
@@ -0,0 +1,499 @@
+/*!
+ * jQuery blockUI plugin
+ * Version 2.39 (23-MAY-2011)
+ * @requires jQuery v1.2.3 or later
+ *
+ * Examples at: http://malsup.com/jquery/block/
+ * Copyright (c) 2007-2010 M. Alsup
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * Thanks to Amir-Hossein Sobhi for some excellent contributions!
+ */
+
+;(function($) {
+
+if (/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery) || /^1.1/.test($.fn.jquery)) {
+ alert('blockUI requires jQuery v1.2.3 or later! You are using v' + $.fn.jquery);
+ return;
+}
+
+$.fn._fadeIn = $.fn.fadeIn;
+
+var noOp = function() {};
+
+// this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle
+// retarded userAgent strings on Vista)
+var mode = document.documentMode || 0;
+var setExpr = $.browser.msie && (($.browser.version < 8 && !mode) || mode < 8);
+var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent) && !mode;
+
+// global $ methods for blocking/unblocking the entire page
+$.blockUI = function(opts) { install(window, opts); };
+$.unblockUI = function(opts) { remove(window, opts); };
+
+// convenience method for quick growl-like notifications (http://www.google.com/search?q=growl)
+$.growlUI = function(title, message, timeout, onClose) {
+ var $m = $('');
+ if (title) $m.append('
'+title+'
');
+ if (message) $m.append('
'+message+'
');
+ if (timeout == undefined) timeout = 3000;
+ $.blockUI({
+ message: $m, fadeIn: 700, fadeOut: 1000, centerY: false,
+ timeout: timeout, showOverlay: false,
+ onUnblock: onClose,
+ css: $.blockUI.defaults.growlCSS
+ });
+};
+
+// plugin method for blocking element content
+$.fn.block = function(opts) {
+ return this.unblock({ fadeOut: 0 }).each(function() {
+ if ($.css(this,'position') == 'static')
+ this.style.position = 'relative';
+ if ($.browser.msie)
+ this.style.zoom = 1; // force 'hasLayout'
+ install(this, opts);
+ });
+};
+
+// plugin method for unblocking element content
+$.fn.unblock = function(opts) {
+ return this.each(function() {
+ remove(this, opts);
+ });
+};
+
+$.blockUI.version = 2.39; // 2nd generation blocking at no extra cost!
+
+// override these in your code to change the default behavior and style
+$.blockUI.defaults = {
+ // message displayed when blocking (use null for no message)
+ message: '
Please wait...
',
+
+ title: null, // title string; only used when theme == true
+ draggable: true, // only used when theme == true (requires jquery-ui.js to be loaded)
+
+ theme: false, // set to true to use with jQuery UI themes
+
+ // styles for the message when blocking; if you wish to disable
+ // these and use an external stylesheet then do this in your code:
+ // $.blockUI.defaults.css = {};
+ css: {
+ padding: 0,
+ margin: 0,
+ width: '30%',
+ top: '40%',
+ left: '35%',
+ textAlign: 'center',
+ color: '#000',
+ border: '3px solid #aaa',
+ backgroundColor:'#fff',
+ cursor: 'wait'
+ },
+
+ // minimal style set used when themes are used
+ themedCSS: {
+ width: '30%',
+ top: '40%',
+ left: '35%'
+ },
+
+ // styles for the overlay
+ overlayCSS: {
+ backgroundColor: '#000',
+ opacity: 0.6,
+ cursor: 'wait'
+ },
+
+ // styles applied when using $.growlUI
+ growlCSS: {
+ width: '350px',
+ top: '10px',
+ left: '',
+ right: '10px',
+ border: 'none',
+ padding: '5px',
+ opacity: 0.6,
+ cursor: 'default',
+ color: '#fff',
+ backgroundColor: '#000',
+ '-webkit-border-radius': '10px',
+ '-moz-border-radius': '10px',
+ 'border-radius': '10px'
+ },
+
+ // IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w
+ // (hat tip to Jorge H. N. de Vasconcelos)
+ iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank',
+
+ // force usage of iframe in non-IE browsers (handy for blocking applets)
+ forceIframe: false,
+
+ // z-index for the blocking overlay
+ baseZ: 1000,
+
+ // set these to true to have the message automatically centered
+ centerX: true, // <-- only effects element blocking (page block controlled via css above)
+ centerY: true,
+
+ // allow body element to be stetched in ie6; this makes blocking look better
+ // on "short" pages. disable if you wish to prevent changes to the body height
+ allowBodyStretch: true,
+
+ // enable if you want key and mouse events to be disabled for content that is blocked
+ bindEvents: true,
+
+ // be default blockUI will supress tab navigation from leaving blocking content
+ // (if bindEvents is true)
+ constrainTabKey: true,
+
+ // fadeIn time in millis; set to 0 to disable fadeIn on block
+ fadeIn: 200,
+
+ // fadeOut time in millis; set to 0 to disable fadeOut on unblock
+ fadeOut: 400,
+
+ // time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock
+ timeout: 0,
+
+ // disable if you don't want to show the overlay
+ showOverlay: true,
+
+ // if true, focus will be placed in the first available input field when
+ // page blocking
+ focusInput: true,
+
+ // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
+ applyPlatformOpacityRules: true,
+
+ // callback method invoked when fadeIn has completed and blocking message is visible
+ onBlock: null,
+
+ // callback method invoked when unblocking has completed; the callback is
+ // passed the element that has been unblocked (which is the window object for page
+ // blocks) and the options that were passed to the unblock call:
+ // onUnblock(element, options)
+ onUnblock: null,
+
+ // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
+ quirksmodeOffsetHack: 4,
+
+ // class name of the message block
+ blockMsgClass: 'blockMsg'
+};
+
+// private data and functions follow...
+
+var pageBlock = null;
+var pageBlockEls = [];
+
+function install(el, opts) {
+ var full = (el == window);
+ var msg = opts && opts.message !== undefined ? opts.message : undefined;
+ opts = $.extend({}, $.blockUI.defaults, opts || {});
+ opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
+ var css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
+ var themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {});
+ msg = msg === undefined ? opts.message : msg;
+
+ // remove the current block (if there is one)
+ if (full && pageBlock)
+ remove(window, {fadeOut:0});
+
+ // if an existing element is being used as the blocking content then we capture
+ // its current place in the DOM (and current display style) so we can restore
+ // it when we unblock
+ if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
+ var node = msg.jquery ? msg[0] : msg;
+ var data = {};
+ $(el).data('blockUI.history', data);
+ data.el = node;
+ data.parent = node.parentNode;
+ data.display = node.style.display;
+ data.position = node.style.position;
+ if (data.parent)
+ data.parent.removeChild(node);
+ }
+
+ $(el).data('blockUI.onUnblock', opts.onUnblock);
+ var z = opts.baseZ;
+
+ // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
+ // layer1 is the iframe layer which is used to supress bleed through of underlying content
+ // layer2 is the overlay layer which has opacity and a wait cursor (by default)
+ // layer3 is the message content that is displayed while blocking
+
+ var lyr1 = ($.browser.msie || opts.forceIframe)
+ ? $('')
+ : $('');
+
+ var lyr2 = opts.theme
+ ? $('')
+ : $('');
+
+ var lyr3, s;
+ if (opts.theme && full) {
+ s = '