2011-08-11 13:22:07 +04:00
|
|
|
/*************************************************
|
|
|
|
* ownCloud - Calendar Plugin *
|
|
|
|
* *
|
2011-08-31 22:20:46 +04:00
|
|
|
* (c) Copyright 2011 Georg Ehrke *
|
2011-09-11 18:45:58 +04:00
|
|
|
* (c) Copyright 2011 Bart Visscher *
|
2011-08-11 13:22:07 +04:00
|
|
|
* author: Georg Ehrke *
|
|
|
|
* email: ownclouddev at georgswebsite dot de *
|
|
|
|
* homepage: ownclouddev.georgswebsite.de *
|
|
|
|
* manual: ownclouddev.georgswebsite.de/manual *
|
2011-08-12 16:29:45 +04:00
|
|
|
* License: GNU AFFERO GENERAL PUBLIC LICENSE *
|
2011-08-11 13:22:07 +04:00
|
|
|
* *
|
2011-08-12 16:29:45 +04:00
|
|
|
* <http://www.gnu.org/licenses/> *
|
2011-08-11 13:22:07 +04:00
|
|
|
* If you are not able to view the License, *
|
|
|
|
* <http://www.gnu.org/licenses/> *
|
|
|
|
* <http://ownclouddev.georgswebsite.de/license/> *
|
|
|
|
* please write to the Free Software Foundation. *
|
|
|
|
* Address: *
|
|
|
|
* 59 Temple Place, Suite 330, Boston, *
|
|
|
|
* MA 02111-1307 USA *
|
|
|
|
**************************************************
|
|
|
|
* list of all fx *
|
|
|
|
* calw - Calendarweek *
|
|
|
|
* doy - Day of the year *
|
|
|
|
* checkforleapyear - check for a leap year *
|
|
|
|
* forward_day - switching one day forward *
|
|
|
|
* forward_week - switching one week forward *
|
|
|
|
* forward_month - switching one month forward *
|
|
|
|
* backward_day - switching one day backward *
|
|
|
|
* backward_week - switching one week backward *
|
|
|
|
* backward_month - switching one month backward *
|
2011-08-31 17:59:22 +04:00
|
|
|
* update_view - update the view of the calendar *
|
|
|
|
* onedayview - one day view *
|
|
|
|
* oneweekview - one week view *
|
2011-09-02 18:44:25 +04:00
|
|
|
* fourweekview - four Weeks view *
|
2011-08-31 17:59:22 +04:00
|
|
|
* onemonthview - one Month view *
|
|
|
|
* listview - listview *
|
2011-09-06 16:14:52 +04:00
|
|
|
* generateDates - generate other days for view *
|
2011-08-11 13:22:07 +04:00
|
|
|
* switch2today - switching to today *
|
2011-09-01 17:15:38 +04:00
|
|
|
* removeEvents - remove old events in view *
|
|
|
|
* loadEvents - load the events *
|
2011-08-11 13:22:07 +04:00
|
|
|
*************************************************/
|
2011-08-31 17:59:22 +04:00
|
|
|
Calendar={
|
2011-09-06 17:11:09 +04:00
|
|
|
space:' ',
|
2011-08-31 17:59:22 +04:00
|
|
|
Date:{
|
2011-08-31 18:31:33 +04:00
|
|
|
normal_year_cal: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
|
|
|
|
leap_year_cal: [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
|
2011-08-31 17:59:22 +04:00
|
|
|
calw:function() {
|
2011-09-06 17:11:09 +04:00
|
|
|
var dayofweek = this.current.getDay();
|
2011-09-06 16:14:52 +04:00
|
|
|
if(dayofweek == 0) {
|
|
|
|
dayofweek = 7;
|
2011-08-31 17:59:22 +04:00
|
|
|
}
|
2011-09-06 16:14:52 +04:00
|
|
|
var calw = Math.floor((this.doy() - dayofweek) / 7) + 1;
|
2011-08-31 17:59:22 +04:00
|
|
|
return calw;
|
|
|
|
},
|
2011-08-11 13:22:07 +04:00
|
|
|
|
2011-08-31 17:59:22 +04:00
|
|
|
doy:function() {
|
2011-09-06 17:11:09 +04:00
|
|
|
var cal = this.getnumberofdays(this.current.getFullYear());
|
2011-08-31 17:59:22 +04:00
|
|
|
var doy = 0;
|
2011-09-06 17:11:09 +04:00
|
|
|
for(var i = 0; i < this.current.getMonth(); i++) {
|
|
|
|
doy = doy + cal[i];
|
2011-08-31 17:59:22 +04:00
|
|
|
}
|
2011-09-06 17:11:09 +04:00
|
|
|
doy = doy + this.current.getDate();
|
2011-08-31 17:59:22 +04:00
|
|
|
return doy;
|
|
|
|
},
|
2011-08-11 13:22:07 +04:00
|
|
|
|
2011-08-31 18:31:33 +04:00
|
|
|
getnumberofdays:function(year) {
|
|
|
|
if(this.checkforleapyear(year) == true) {
|
|
|
|
var cal = this.leap_year_cal;
|
|
|
|
} else {
|
|
|
|
var cal = this.normal_year_cal;
|
|
|
|
}
|
|
|
|
return cal;
|
|
|
|
},
|
|
|
|
|
2011-08-31 17:59:22 +04:00
|
|
|
checkforleapyear:function(year2check) {
|
|
|
|
if((year2check / 600) == Math.floor(year2check / 400)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if((year2check / 4) == Math.floor(year2check / 4)) {
|
|
|
|
if((year2check / 100) == Math.floor(year2check / 100)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2011-08-11 13:22:07 +04:00
|
|
|
return false;
|
2011-08-31 17:59:22 +04:00
|
|
|
},
|
|
|
|
|
2011-09-06 17:11:09 +04:00
|
|
|
current:new Date(),
|
2011-08-31 17:59:22 +04:00
|
|
|
forward_day:function(){
|
2011-09-06 17:11:09 +04:00
|
|
|
this.current.setDate(this.current.getDate()+1);
|
2011-08-31 17:59:22 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
forward_week:function(){
|
2011-09-06 17:11:09 +04:00
|
|
|
this.current.setDate(this.current.getDate()+7);
|
2011-08-31 17:59:22 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
forward_month:function(){
|
2011-09-06 17:11:09 +04:00
|
|
|
this.current.setMonth(this.current.getMonth()+1);
|
2011-08-31 17:59:22 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
backward_day:function(){
|
2011-09-06 17:11:09 +04:00
|
|
|
this.current.setDate(this.current.getDate()-1);
|
2011-08-31 17:59:22 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
backward_week:function(){
|
2011-09-06 17:11:09 +04:00
|
|
|
this.current.setDate(this.current.getDate()-7);
|
2011-08-31 17:59:22 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
backward_month:function(){
|
2011-09-06 17:11:09 +04:00
|
|
|
this.current.setMonth(this.current.getMonth()-1);
|
2011-08-31 17:59:22 +04:00
|
|
|
},
|
|
|
|
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
|
|
|
UI:{
|
|
|
|
weekdays: ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"],
|
2011-09-06 17:11:09 +04:00
|
|
|
formatDayShort:function(day){
|
|
|
|
if (typeof(day) == 'undefined'){
|
|
|
|
day = Calendar.Date.current.getDay();
|
|
|
|
}
|
|
|
|
return this.dayshort[day];
|
|
|
|
},
|
|
|
|
formatDayLong:function(day){
|
|
|
|
if (typeof(day) == 'undefined'){
|
|
|
|
day = Calendar.Date.current.getDay();
|
|
|
|
}
|
|
|
|
return this.daylong[day];
|
|
|
|
},
|
|
|
|
formatMonthShort:function(month){
|
|
|
|
if (typeof(month) == 'undefined'){
|
|
|
|
month = Calendar.Date.current.getMonth();
|
|
|
|
}
|
|
|
|
return this.monthshort[month];
|
|
|
|
},
|
|
|
|
formatMonthLong:function(month){
|
|
|
|
if (typeof(month) == 'undefined'){
|
|
|
|
month = Calendar.Date.current.getMonth();
|
|
|
|
}
|
|
|
|
return this.monthlong[month];
|
|
|
|
},
|
2011-09-07 00:07:33 +04:00
|
|
|
formatDate:function(date){
|
|
|
|
return date[0] + '-' + date[1] + '-' + date[2];
|
|
|
|
},
|
|
|
|
formatTime:function(date){
|
|
|
|
return date[3] + ':' + date[4];
|
|
|
|
},
|
2011-09-02 01:27:00 +04:00
|
|
|
updateView:function(task) {
|
2011-09-01 17:15:38 +04:00
|
|
|
this.current.removeEvents();
|
|
|
|
this.current.renderCal();
|
2011-09-02 01:27:00 +04:00
|
|
|
this.current.showEvents();
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
2011-09-06 17:11:09 +04:00
|
|
|
currentview:'none',
|
2011-09-01 17:15:38 +04:00
|
|
|
setCurrentView:function(view){
|
2011-09-06 17:11:09 +04:00
|
|
|
if (view == this.currentview){
|
2011-09-02 01:27:00 +04:00
|
|
|
return;
|
|
|
|
}
|
2011-09-06 17:11:09 +04:00
|
|
|
$('#'+this.currentview).hide();
|
|
|
|
$('#'+this.currentview + "_radio").removeClass('active');
|
|
|
|
this.currentview = view;
|
2011-09-02 12:14:56 +04:00
|
|
|
//sending ajax request on every change view
|
2011-09-02 01:27:00 +04:00
|
|
|
$("#sysbox").load(oc_webroot + "/apps/calendar/ajax/changeview.php?v="+view);
|
|
|
|
//not necessary to check whether the response is true or not
|
2011-09-01 17:15:38 +04:00
|
|
|
switch(view) {
|
|
|
|
case "onedayview":
|
2011-09-06 17:11:09 +04:00
|
|
|
this.current = this.OneDay;
|
2011-09-01 17:15:38 +04:00
|
|
|
break;
|
|
|
|
case "oneweekview":
|
2011-09-06 17:11:09 +04:00
|
|
|
this.current = this.OneWeek;
|
2011-09-01 17:15:38 +04:00
|
|
|
break;
|
|
|
|
case "fourweeksview":
|
2011-09-06 17:11:09 +04:00
|
|
|
this.current = this.FourWeeks;
|
2011-09-01 17:15:38 +04:00
|
|
|
break;
|
|
|
|
case "onemonthview":
|
2011-09-06 17:11:09 +04:00
|
|
|
this.current = this.OneMonth;
|
2011-09-01 17:15:38 +04:00
|
|
|
break;
|
|
|
|
case "listview":
|
2011-09-06 17:11:09 +04:00
|
|
|
this.current = this.List;
|
2011-09-01 17:15:38 +04:00
|
|
|
break;
|
|
|
|
default:
|
2011-09-06 17:11:09 +04:00
|
|
|
alert('Unknown view:'+view);
|
2011-09-01 17:15:38 +04:00
|
|
|
break;
|
2011-08-11 13:22:07 +04:00
|
|
|
}
|
2011-09-16 19:50:55 +04:00
|
|
|
$(document).ready(function() {
|
|
|
|
$('#'+Calendar.UI.currentview).show();
|
|
|
|
$('#'+Calendar.UI.currentview + "_radio")
|
|
|
|
.addClass('active');
|
|
|
|
Calendar.UI.updateView()
|
|
|
|
});
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
|
|
|
updateDate:function(direction){
|
2011-09-07 17:13:26 +04:00
|
|
|
if(direction == 'forward' && this.current.forward) {
|
2011-09-01 17:15:38 +04:00
|
|
|
this.current.forward();
|
2011-09-06 17:11:09 +04:00
|
|
|
if(Calendar.Date.current.getMonth() == 11){
|
|
|
|
this.loadEvents(Calendar.Date.current.getFullYear() + 1);
|
2011-09-02 01:27:00 +04:00
|
|
|
}
|
2011-09-06 17:11:09 +04:00
|
|
|
this.updateView();
|
2011-08-11 13:22:07 +04:00
|
|
|
}
|
2011-09-07 17:13:26 +04:00
|
|
|
if(direction == 'backward' && this.current.backward) {
|
2011-09-01 17:15:38 +04:00
|
|
|
this.current.backward();
|
2011-09-06 17:11:09 +04:00
|
|
|
if(Calendar.Date.current.getMonth() == 0){
|
|
|
|
this.loadEvents(Calendar.Date.current.getFullYear() - 1);
|
2011-09-02 01:27:00 +04:00
|
|
|
}
|
2011-09-06 17:11:09 +04:00
|
|
|
this.updateView();
|
2011-08-11 13:22:07 +04:00
|
|
|
}
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
2011-09-06 17:11:09 +04:00
|
|
|
events:[],
|
2011-09-02 01:27:00 +04:00
|
|
|
loadEvents:function(year){
|
2011-09-08 14:29:29 +04:00
|
|
|
if( typeof (year) == 'undefined') {
|
|
|
|
this.events = [];
|
|
|
|
year = Calendar.Date.current.getFullYear();
|
|
|
|
}
|
2011-09-06 17:11:09 +04:00
|
|
|
if( typeof (this.events[year]) == "undefined") {
|
|
|
|
this.events[year] = []
|
|
|
|
}
|
2011-09-02 01:27:00 +04:00
|
|
|
$.getJSON(oc_webroot + "/apps/calendar/ajax/getcal.php?year=" + year, function(newevents, status) {
|
|
|
|
if(status == "nosession") {
|
|
|
|
alert("You are not logged in. That can happen if you don't use owncloud for a long time.");
|
|
|
|
document.location(oc_webroot);
|
|
|
|
}
|
|
|
|
if(status == "parsingfail" || typeof (newevents) == "undefined") {
|
|
|
|
$.ready(function() {
|
|
|
|
$( "#parsingfail_dialog" ).dialog();
|
|
|
|
});
|
|
|
|
} else {
|
2011-09-08 14:29:29 +04:00
|
|
|
if (typeof(newevents[year]) != 'undefined'){
|
|
|
|
Calendar.UI.events[year] = newevents[year];
|
|
|
|
}
|
2011-09-06 17:11:09 +04:00
|
|
|
$(document).ready(function() {
|
|
|
|
Calendar.UI.updateView();
|
|
|
|
});
|
2011-09-02 01:27:00 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2011-09-07 17:13:26 +04:00
|
|
|
getEventsForDate:function(date){
|
2011-09-07 00:07:33 +04:00
|
|
|
var day = date.getDate();
|
|
|
|
var month = date.getMonth();
|
|
|
|
var year = date.getFullYear();
|
2011-09-06 17:11:09 +04:00
|
|
|
if( typeof (this.events[year]) == "undefined") {
|
2011-09-07 17:13:26 +04:00
|
|
|
this.loadEvents(year);
|
|
|
|
return false;
|
2011-08-11 13:22:07 +04:00
|
|
|
}
|
2011-09-06 17:11:09 +04:00
|
|
|
if( typeof (this.events[year][month]) == "undefined") {
|
2011-09-07 17:13:26 +04:00
|
|
|
return false;
|
2011-08-11 13:22:07 +04:00
|
|
|
}
|
2011-09-06 17:11:09 +04:00
|
|
|
if( typeof (this.events[year][month][day]) == "undefined") {
|
2011-09-07 17:13:26 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return this.events[year][month][day];
|
|
|
|
},
|
|
|
|
createEventsForDate:function(date, week){
|
|
|
|
events = this.getEventsForDate(date);
|
|
|
|
if (!events) {
|
2011-09-01 17:15:38 +04:00
|
|
|
return;
|
2011-08-11 13:22:07 +04:00
|
|
|
}
|
2011-09-07 00:07:33 +04:00
|
|
|
var weekday = (date.getDay()+6)%7;
|
2011-09-01 17:15:38 +04:00
|
|
|
if( typeof (events["allday"]) != "undefined") {
|
|
|
|
var eventnumber = 1;
|
|
|
|
var eventcontainer = this.current.getEventContainer(week, weekday, "allday");
|
|
|
|
while( typeof (events["allday"][eventnumber]) != "undefined") {
|
2011-09-03 16:05:20 +04:00
|
|
|
this.addEventLabel(eventcontainer, events['allday'][eventnumber]);
|
2011-09-01 17:15:38 +04:00
|
|
|
eventnumber++;
|
|
|
|
}
|
2011-08-11 13:22:07 +04:00
|
|
|
}
|
2011-09-01 17:15:38 +04:00
|
|
|
for(var time = 0; time <= 23; time++) {
|
|
|
|
if( typeof (events[time]) != "undefined") {
|
|
|
|
var eventnumber = 1;
|
|
|
|
var eventcontainer = this.current.getEventContainer(week, weekday, time);
|
|
|
|
while( typeof (events[time][eventnumber]) != "undefined") {
|
2011-09-03 16:05:20 +04:00
|
|
|
this.addEventLabel(eventcontainer, events[time][eventnumber]);
|
2011-09-01 17:15:38 +04:00
|
|
|
eventnumber++;
|
|
|
|
}
|
|
|
|
}
|
2011-08-11 13:22:07 +04:00
|
|
|
}
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
2011-09-03 16:05:20 +04:00
|
|
|
addEventLabel:function(eventcontainer, event){
|
|
|
|
var event_holder = this.current.createEventLabel(event)
|
|
|
|
.addClass('event')
|
2011-09-04 00:13:14 +04:00
|
|
|
.data('event_info', event)
|
|
|
|
.hover(this.createEventPopup,
|
2011-09-15 23:20:42 +04:00
|
|
|
this.hideEventPopup)
|
2011-09-16 16:02:21 +04:00
|
|
|
.click(this.editEvent);
|
2011-09-03 16:05:20 +04:00
|
|
|
eventcontainer.append(event_holder);
|
|
|
|
},
|
2011-09-16 19:50:55 +04:00
|
|
|
startEventDialog:function(){
|
|
|
|
Calendar.UI.lockTime();
|
|
|
|
$( "#from" ).datepicker({
|
|
|
|
dateFormat : 'dd-mm-yy'
|
|
|
|
});
|
|
|
|
$( "#to" ).datepicker({
|
|
|
|
dateFormat : 'dd-mm-yy'
|
|
|
|
});
|
|
|
|
$('#event').dialog({
|
|
|
|
width : 500,
|
|
|
|
close : function(event, ui) {
|
|
|
|
$(this).dialog('destroy').remove();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2011-09-16 16:02:21 +04:00
|
|
|
newEvent:function(selector, time){
|
|
|
|
var date_info = $(selector).data('date_info');
|
|
|
|
var dayofmonth = date_info.getDate();
|
|
|
|
var month = date_info.getMonth();
|
|
|
|
var year = date_info.getFullYear();
|
|
|
|
if(dayofmonth <= 9){
|
|
|
|
dayofmonth = '0' + dayofmonth;
|
|
|
|
}
|
|
|
|
month++;
|
|
|
|
if(month <= 9){
|
|
|
|
month = '0' + month;
|
|
|
|
}
|
|
|
|
var date = String(dayofmonth) + String(month) + String(year);
|
|
|
|
if($('#event').dialog('isOpen') == true){
|
|
|
|
// TODO: save event
|
|
|
|
$('#event').dialog('destroy').remove();
|
|
|
|
}else{
|
2011-09-16 19:50:55 +04:00
|
|
|
$('#dialog_holder').load(oc_webroot + '/apps/calendar/ajax/neweventform.php?d=' + date + '&t=' + time, Calendar.UI.startEventDialog);
|
2011-09-16 16:02:21 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
editEvent:function(event){
|
2011-09-15 23:20:42 +04:00
|
|
|
event.stopPropagation();
|
|
|
|
var event_data = $(this).data('event_info');
|
|
|
|
var id = event_data.id;
|
2011-09-16 16:02:21 +04:00
|
|
|
if($('#event').dialog('isOpen') == true){
|
|
|
|
// TODO: save event
|
|
|
|
$('#event').dialog('destroy').remove();
|
2011-09-15 23:20:42 +04:00
|
|
|
}else{
|
2011-09-16 19:50:55 +04:00
|
|
|
$('#dialog_holder').load(oc_webroot + '/apps/calendar/ajax/editeventform.php?id=' + id, Calendar.UI.startEventDialog);
|
2011-09-15 23:20:42 +04:00
|
|
|
}
|
|
|
|
},
|
2011-09-16 19:06:57 +04:00
|
|
|
validateEventForm:function(url){
|
|
|
|
var post = $( "#event_form" ).serialize();
|
|
|
|
$("#errorbox").html("");
|
|
|
|
$.post(url, post,
|
|
|
|
function(data){
|
|
|
|
if(data.status == "error"){
|
|
|
|
var output = "Missing fields: <br />";
|
|
|
|
if(data.title == "true"){
|
|
|
|
output = output + "Title<br />";
|
|
|
|
}
|
|
|
|
if(data.cal == "true"){
|
|
|
|
output = output + "Calendar<br />";
|
|
|
|
}
|
|
|
|
if(data.from == "true"){
|
|
|
|
output = output + "From Date<br />";
|
|
|
|
}
|
|
|
|
if(data.fromtime == "true"){
|
|
|
|
output = output + "From Time<br />";
|
|
|
|
}
|
|
|
|
if(data.to == "true"){
|
|
|
|
output = output + "To Date<br />";
|
|
|
|
}
|
|
|
|
if(data.totime == "true"){
|
|
|
|
output = output + "To Time<br />";
|
|
|
|
}
|
|
|
|
if(data.endbeforestart == "true"){
|
|
|
|
output = "The event ends before it starts!";
|
|
|
|
}
|
|
|
|
if(data.dberror == "true"){
|
|
|
|
output = "There was a database fail!";
|
|
|
|
}
|
|
|
|
$("#errorbox").html(output);
|
|
|
|
} else
|
|
|
|
if(data.status == 'success'){
|
|
|
|
$('#event').dialog('destroy').remove();
|
|
|
|
Calendar.UI.loadEvents();
|
|
|
|
}
|
|
|
|
},"json");
|
|
|
|
},
|
2011-09-04 00:13:14 +04:00
|
|
|
createEventPopup:function(e){
|
|
|
|
var popup = $(this).data('popup');
|
|
|
|
if (!popup){
|
2011-09-10 00:19:06 +04:00
|
|
|
var event = $(this).data('event_info');
|
2011-09-04 00:13:14 +04:00
|
|
|
popup = $(document.createElement('div'));
|
|
|
|
$(this).data('popup', popup).append(popup);
|
2011-09-10 00:19:06 +04:00
|
|
|
popup.addClass('popup')
|
2011-09-04 00:13:14 +04:00
|
|
|
popup.addClass('event_popup')
|
|
|
|
.html(Calendar.UI.getEventPopupText(event));
|
|
|
|
}
|
|
|
|
popup.css('left', -(popup.width() - $(this).width())/2)
|
|
|
|
.show();
|
|
|
|
},
|
|
|
|
hideEventPopup:function(){
|
|
|
|
$(this).data('popup').hide();
|
|
|
|
},
|
|
|
|
getEventPopupText:function(event){
|
|
|
|
var startdate = this.formatDate(event.startdate)
|
|
|
|
var starttime = this.formatTime(event.startdate)
|
|
|
|
var enddate = this.formatDate(event.enddate)
|
|
|
|
var endtime = this.formatTime(event.enddate)
|
|
|
|
if (event.allday){
|
|
|
|
var timespan = startdate;
|
|
|
|
if (event.startdate[2] != parseInt(event.enddate[2])-1){
|
|
|
|
timespan += ' - ' + enddate;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
var start = startdate + ' ' + starttime;
|
|
|
|
if (startdate == enddate){
|
|
|
|
var end = endtime;
|
|
|
|
}else{
|
|
|
|
var end = enddate + ' ' + endtime;
|
|
|
|
}
|
|
|
|
var timespan = start + ' - ' + end;
|
|
|
|
}
|
|
|
|
return '<span class="timespan">' + timespan + '</span>'
|
|
|
|
+ ' '
|
|
|
|
+ '<span class="summary">' + event.description + '</span>';
|
|
|
|
},
|
2011-09-06 15:38:19 +04:00
|
|
|
addDateInfo:function(selector, date){
|
2011-09-07 00:07:33 +04:00
|
|
|
$(selector).data('date_info', date);
|
2011-09-06 15:38:19 +04:00
|
|
|
},
|
2011-09-12 00:06:45 +04:00
|
|
|
switch2Today:function(){
|
|
|
|
Calendar.Date.current = new Date();
|
|
|
|
Calendar.UI.updateView();
|
|
|
|
},
|
2011-09-16 16:02:21 +04:00
|
|
|
lockTime:function(){
|
|
|
|
if($('#allday_checkbox').is(':checked')) {
|
|
|
|
$("#fromtime").attr('disabled', true)
|
|
|
|
.addClass('disabled');
|
|
|
|
$("#totime").attr('disabled', true)
|
|
|
|
.addClass('disabled');
|
|
|
|
} else {
|
|
|
|
$("#fromtime").attr('disabled', false)
|
|
|
|
.removeClass('disabled');
|
|
|
|
$("#totime").attr('disabled', false)
|
|
|
|
.removeClass('disabled');
|
|
|
|
}
|
|
|
|
},
|
2011-09-16 19:50:55 +04:00
|
|
|
showCalDAVUrl:function(username, calname){
|
|
|
|
$('#caldav_url').val(totalurl + '/' + username + '/' + calname);
|
|
|
|
$('#caldav_url').show();
|
|
|
|
$("#caldav_url_close").show();
|
|
|
|
},
|
2011-09-12 00:06:45 +04:00
|
|
|
Calendar:{
|
|
|
|
overview:function(){
|
2011-09-16 16:11:22 +04:00
|
|
|
if($('#choosecalendar_dialog').dialog('isOpen') == true){
|
|
|
|
$('#choosecalendar_dialog').dialog('moveToTop');
|
2011-09-12 00:06:45 +04:00
|
|
|
}else{
|
2011-09-16 16:11:22 +04:00
|
|
|
$('#dialog_holder').load(oc_webroot + '/apps/calendar/ajax/choosecalendar.php', function(){
|
|
|
|
$('#choosecalendar_dialog').dialog({
|
|
|
|
width : 600,
|
|
|
|
close : function(event, ui) {
|
|
|
|
$(this).dialog('destroy').remove();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2011-09-12 00:06:45 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
activation:function(checkbox, calendarid)
|
|
|
|
{
|
|
|
|
$.post(oc_webroot + "/apps/calendar/ajax/activation.php", { calendarid: calendarid, active: checkbox.checked?1:0 },
|
|
|
|
function(data) {
|
|
|
|
checkbox.checked = data == 1;
|
|
|
|
Calendar.UI.loadEvents();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
new:function(object){
|
|
|
|
var tr = $(document.createElement('tr'))
|
|
|
|
.load(oc_webroot + "/apps/calendar/ajax/newcalendar.php");
|
|
|
|
$(object).closest('tr').after(tr).hide();
|
|
|
|
},
|
|
|
|
edit:function(object, calendarid){
|
|
|
|
var tr = $(document.createElement('tr'))
|
|
|
|
.load(oc_webroot + "/apps/calendar/ajax/editcalendar.php?calendarid="+calendarid);
|
|
|
|
$(object).closest('tr').after(tr).hide();
|
|
|
|
},
|
|
|
|
submit:function(button, calendarid){
|
|
|
|
var displayname = $("#displayname_"+calendarid).val();
|
2011-09-18 19:13:26 +04:00
|
|
|
var active = $("#edit_active_"+calendarid+":checked").length;
|
2011-09-12 00:06:45 +04:00
|
|
|
var description = $("#description_"+calendarid).val();
|
|
|
|
var calendarcolor = $("#calendarcolor_"+calendarid).val();
|
|
|
|
|
|
|
|
var url;
|
|
|
|
if (calendarid == 'new'){
|
|
|
|
url = "ajax/createcalendar.php";
|
|
|
|
}else{
|
|
|
|
url = "ajax/updatecalendar.php";
|
|
|
|
}
|
|
|
|
$.post(url, { id: calendarid, name: displayname, active: active, description: description, color: calendarcolor },
|
|
|
|
function(data){
|
|
|
|
if(data.error == "true"){
|
|
|
|
}else{
|
|
|
|
$(button).closest('tr').prev().html(data.data).show().next().remove();
|
|
|
|
Calendar.UI.loadEvents();
|
|
|
|
}
|
|
|
|
}, 'json');
|
|
|
|
},
|
|
|
|
cancel:function(button, calendarid){
|
|
|
|
$(button).closest('tr').prev().show().next().remove();
|
|
|
|
},
|
|
|
|
},
|
2011-09-01 17:15:38 +04:00
|
|
|
OneDay:{
|
|
|
|
forward:function(){
|
2011-08-31 17:59:22 +04:00
|
|
|
Calendar.Date.forward_day();
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
|
|
|
backward:function(){
|
2011-08-31 17:59:22 +04:00
|
|
|
Calendar.Date.backward_day();
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
|
|
|
removeEvents:function(){
|
2011-09-02 18:44:25 +04:00
|
|
|
$("#onedayview .calendar_row").html("");
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
|
|
|
renderCal:function(){
|
2011-09-06 17:11:09 +04:00
|
|
|
$("#datecontrol_date").val(Calendar.UI.formatDayShort() + Calendar.space + Calendar.Date.current.getDate() + Calendar.space + Calendar.UI.formatMonthShort() + Calendar.space + Calendar.Date.current.getFullYear());
|
|
|
|
$("#onedayview_today").html(Calendar.UI.formatDayLong() + Calendar.space + Calendar.Date.current.getDate() + Calendar.space + Calendar.UI.formatMonthShort());
|
2011-09-07 00:07:33 +04:00
|
|
|
Calendar.UI.addDateInfo('#onedayview_today', new Date(Calendar.Date.current));
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
2011-09-02 01:27:00 +04:00
|
|
|
showEvents:function(){
|
2011-09-07 00:07:33 +04:00
|
|
|
Calendar.UI.createEventsForDate(Calendar.Date.current, 0);
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
|
|
|
getEventContainer:function(week, weekday, when){
|
2011-09-02 18:44:25 +04:00
|
|
|
return $("#onedayview ." + when);
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
2011-09-03 16:05:20 +04:00
|
|
|
createEventLabel:function(event){
|
|
|
|
var time = '';
|
|
|
|
if (!event['allday']){
|
2011-09-04 00:13:14 +04:00
|
|
|
time = '<strong>' + Calendar.UI.formatTime(event['startdate']) + ' - ' + Calendar.UI.formatTime(event['enddate']) + '</strong> ';
|
2011-09-03 16:05:20 +04:00
|
|
|
}
|
|
|
|
return $(document.createElement('p'))
|
|
|
|
.html(time + event['description'])
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
OneWeek:{
|
|
|
|
forward:function(){
|
|
|
|
Calendar.Date.forward_week();
|
|
|
|
},
|
|
|
|
backward:function(){
|
|
|
|
Calendar.Date.backward_week();
|
|
|
|
},
|
|
|
|
removeEvents:function(){
|
|
|
|
for( i = 0; i <= 6; i++) {
|
2011-09-02 18:44:25 +04:00
|
|
|
$("#oneweekview ." + Calendar.UI.weekdays[i]).html("");
|
2011-09-01 17:15:38 +04:00
|
|
|
}
|
2011-09-02 18:44:25 +04:00
|
|
|
$("#oneweekview .thisday").removeClass("thisday");
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
|
|
|
renderCal:function(){
|
2011-09-06 17:11:09 +04:00
|
|
|
$("#datecontrol_date").val(Calendar.UI.cw_label + ": " + Calendar.Date.calw());
|
2011-09-02 00:31:25 +04:00
|
|
|
var dates = this.generateDates();
|
2011-09-06 17:11:09 +04:00
|
|
|
var today = new Date();
|
2011-09-01 17:15:38 +04:00
|
|
|
for(var i = 0; i <= 6; i++){
|
2011-09-07 00:07:33 +04:00
|
|
|
$("#oneweekview th." + Calendar.UI.weekdays[i]).html(Calendar.UI.formatDayShort((i+1)%7) + Calendar.space + dates[i].getDate() + Calendar.space + Calendar.UI.formatMonthShort(dates[i].getMonth()));
|
|
|
|
if(dates[i].getDate() == today.getDate() && dates[i].getMonth() == today.getMonth() && dates[i].getFullYear() == today.getFullYear()){
|
2011-09-02 18:44:25 +04:00
|
|
|
$("#oneweekview ." + Calendar.UI.weekdays[i]).addClass("thisday");
|
|
|
|
}
|
2011-09-06 15:38:19 +04:00
|
|
|
Calendar.UI.addDateInfo('#oneweekview th.' + Calendar.UI.weekdays[i], dates[i]);
|
2011-09-01 17:15:38 +04:00
|
|
|
}
|
|
|
|
},
|
2011-09-02 01:27:00 +04:00
|
|
|
showEvents:function(){
|
2011-09-02 00:31:25 +04:00
|
|
|
var dates = this.generateDates();
|
2011-09-01 17:15:38 +04:00
|
|
|
for(var weekday = 0; weekday <= 6; weekday++) {
|
2011-09-07 00:07:33 +04:00
|
|
|
Calendar.UI.createEventsForDate(dates[weekday], 0);
|
2011-09-01 17:15:38 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
getEventContainer:function(week, weekday, when){
|
2011-09-02 18:44:25 +04:00
|
|
|
return $("#oneweekview ." + Calendar.UI.weekdays[weekday] + "." + when);
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
2011-09-03 16:05:20 +04:00
|
|
|
createEventLabel:function(event){
|
|
|
|
var time = '';
|
|
|
|
if (!event['allday']){
|
2011-09-04 00:13:14 +04:00
|
|
|
time = '<strong>' + Calendar.UI.formatTime(event['startdate']) + ' - ' + Calendar.UI.formatTime(event['enddate']) + '</strong> ';
|
2011-09-03 16:05:20 +04:00
|
|
|
}
|
|
|
|
return $(document.createElement('p'))
|
|
|
|
.html(time + event['description'])
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
2011-09-02 00:31:25 +04:00
|
|
|
generateDates:function(){
|
|
|
|
var dates = new Array();
|
2011-09-06 17:11:09 +04:00
|
|
|
var date = new Date(Calendar.Date.current)
|
2011-09-06 16:14:52 +04:00
|
|
|
var dayofweek = date.getDay();
|
|
|
|
if(dayofweek == 0) {
|
|
|
|
dayofweek = 7;
|
2011-09-02 00:31:25 +04:00
|
|
|
}
|
2011-09-06 16:14:52 +04:00
|
|
|
date.setDate(date.getDate() - dayofweek + 1);
|
2011-09-06 13:47:23 +04:00
|
|
|
for(var i = 0; i <= 6; i++) {
|
2011-09-07 00:07:33 +04:00
|
|
|
dates[i] = new Date(date)
|
2011-09-06 16:14:52 +04:00
|
|
|
date.setDate(date.getDate() + 1);
|
2011-09-02 00:31:25 +04:00
|
|
|
}
|
|
|
|
return dates;
|
|
|
|
},
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
|
|
|
FourWeeks:{
|
|
|
|
forward:function(){
|
|
|
|
Calendar.Date.forward_week();
|
|
|
|
},
|
|
|
|
backward:function(){
|
|
|
|
Calendar.Date.backward_week();
|
|
|
|
},
|
|
|
|
removeEvents:function(){
|
2011-09-02 18:44:25 +04:00
|
|
|
$('#fourweeksview .day.thisday').removeClass('thisday');
|
|
|
|
$('#fourweeksview .day .events').html('');
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
|
|
|
renderCal:function(){
|
|
|
|
var calw1 = Calendar.Date.calw();
|
|
|
|
var calw2 = calw1 + 1;
|
|
|
|
var calw3 = calw1 + 2;
|
|
|
|
var calw4 = calw1 + 3;
|
|
|
|
switch(calw1) {
|
|
|
|
case 50:
|
|
|
|
calw4 = 1;
|
|
|
|
break;
|
|
|
|
case 51:
|
|
|
|
calw3 = 1;
|
|
|
|
calw4 = 2;
|
|
|
|
break;
|
|
|
|
case 52:
|
|
|
|
calw2 = 1;
|
|
|
|
calw3 = 2;
|
|
|
|
calw4 = 3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
var calwplusfour = calw4;
|
2011-09-02 00:31:25 +04:00
|
|
|
var dates = this.generateDates();
|
2011-09-01 17:15:38 +04:00
|
|
|
var week = 1;
|
|
|
|
var weekday = 0;
|
2011-09-06 17:11:09 +04:00
|
|
|
var today = new Date();
|
2011-09-01 17:15:38 +04:00
|
|
|
for(var i = 0; i <= 27; i++){
|
2011-09-07 00:07:33 +04:00
|
|
|
var dayofmonth = dates[i].getDate();
|
|
|
|
var month = dates[i].getMonth();
|
|
|
|
var year = dates[i].getFullYear();
|
2011-09-06 17:11:09 +04:00
|
|
|
$("#fourweeksview .week_" + week + " ." + Calendar.UI.weekdays[weekday] + " .dateinfo").html(dayofmonth + Calendar.space + Calendar.UI.formatMonthShort(month));
|
|
|
|
if(dayofmonth == today.getDate() && month == today.getMonth() && year == today.getFullYear()){
|
2011-09-02 18:44:25 +04:00
|
|
|
$("#fourweeksview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).addClass('thisday');
|
|
|
|
}
|
2011-09-06 15:38:19 +04:00
|
|
|
Calendar.UI.addDateInfo('#fourweeksview .week_' + week + ' .' + Calendar.UI.weekdays[weekday], dates[i]);
|
2011-09-01 17:15:38 +04:00
|
|
|
if(weekday == 6){
|
|
|
|
weekday = 0;
|
|
|
|
week++;
|
|
|
|
}else{
|
|
|
|
weekday++;
|
|
|
|
}
|
|
|
|
}
|
2011-09-02 18:44:25 +04:00
|
|
|
$("#fourweeksview .week_1 .calw").html(calw1);
|
|
|
|
$("#fourweeksview .week_2 .calw").html(calw2);
|
|
|
|
$("#fourweeksview .week_3 .calw").html(calw3);
|
|
|
|
$("#fourweeksview .week_4 .calw").html(calw4);
|
2011-09-06 17:11:09 +04:00
|
|
|
$("#datecontrol_date").val(Calendar.UI.cws_label + ": " + Calendar.Date.calw() + " - " + calwplusfour);
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
2011-09-02 01:27:00 +04:00
|
|
|
showEvents:function(){
|
2011-09-02 00:31:25 +04:00
|
|
|
var dates = this.generateDates();
|
2011-09-01 17:15:38 +04:00
|
|
|
var weekdaynum = 0;
|
|
|
|
var weeknum = 1;
|
|
|
|
for(var i = 0; i <= 27; i++) {
|
2011-09-07 00:07:33 +04:00
|
|
|
Calendar.UI.createEventsForDate(dates[i], weeknum);
|
2011-09-01 17:15:38 +04:00
|
|
|
if(weekdaynum == 6){
|
|
|
|
weekdaynum = 0;
|
|
|
|
weeknum++;
|
|
|
|
}else{
|
|
|
|
weekdaynum++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getEventContainer:function(week, weekday, when){
|
2011-09-02 18:44:25 +04:00
|
|
|
return $("#fourweeksview .week_" + week + " .day." + Calendar.UI.weekdays[weekday] + " .events");
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
2011-09-03 16:05:20 +04:00
|
|
|
createEventLabel:function(event){
|
|
|
|
var time = '';
|
|
|
|
if (!event['allday']){
|
2011-09-04 00:13:14 +04:00
|
|
|
time = '<strong>' + Calendar.UI.formatTime(event['startdate']) + '</strong> ';
|
2011-09-03 16:05:20 +04:00
|
|
|
}
|
|
|
|
return $(document.createElement('p'))
|
|
|
|
.html(time + event['description'])
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
2011-09-02 00:31:25 +04:00
|
|
|
generateDates:function(){
|
|
|
|
var dates = new Array();
|
2011-09-06 17:11:09 +04:00
|
|
|
var date = new Date(Calendar.Date.current)
|
2011-09-06 16:14:52 +04:00
|
|
|
var dayofweek = date.getDay();
|
|
|
|
if(dayofweek == 0) {
|
|
|
|
dayofweek = 7;
|
2011-09-02 00:31:25 +04:00
|
|
|
}
|
2011-09-06 16:14:52 +04:00
|
|
|
date.setDate(date.getDate() - dayofweek + 1);
|
2011-09-06 13:47:23 +04:00
|
|
|
for(var i = 0; i <= 27; i++) {
|
2011-09-07 00:07:33 +04:00
|
|
|
dates[i] = new Date(date)
|
2011-09-06 16:14:52 +04:00
|
|
|
date.setDate(date.getDate() + 1);
|
2011-09-02 00:31:25 +04:00
|
|
|
}
|
|
|
|
return dates;
|
|
|
|
},
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
|
|
|
OneMonth:{
|
|
|
|
forward:function(){
|
|
|
|
Calendar.Date.forward_month();
|
|
|
|
},
|
|
|
|
backward:function(){
|
|
|
|
Calendar.Date.backward_month();
|
|
|
|
},
|
|
|
|
removeEvents:function(){
|
2011-09-02 18:44:25 +04:00
|
|
|
$('#onemonthview .day.thisday').removeClass('thisday');
|
|
|
|
$('#onemonthview .day .events').html('');
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
|
|
|
renderCal:function(){
|
2011-09-06 17:11:09 +04:00
|
|
|
$("#datecontrol_date").val(Calendar.UI.formatMonthLong() + Calendar.space + Calendar.Date.current.getFullYear());
|
|
|
|
var cal = Calendar.Date.getnumberofdays(Calendar.Date.current.getFullYear());
|
|
|
|
var monthview_dayofweek = Calendar.Date.current.getDay();
|
|
|
|
var monthview_dayofmonth = Calendar.Date.current.getDate();
|
2011-09-01 17:15:38 +04:00
|
|
|
for(var i = monthview_dayofmonth; i > 1; i--) {
|
|
|
|
if(monthview_dayofweek == 0) {
|
|
|
|
monthview_dayofweek = 6;
|
|
|
|
} else {
|
|
|
|
monthview_dayofweek--;
|
|
|
|
}
|
|
|
|
}
|
2011-09-03 01:51:18 +04:00
|
|
|
$("#onemonthview .week_5").hide();
|
|
|
|
$("#onemonthview .week_6").hide();
|
2011-09-06 17:11:09 +04:00
|
|
|
this.rows = monthview_dayofweek + cal[Calendar.Date.current.getMonth()];
|
|
|
|
this.rows = this.rows / 7;
|
|
|
|
this.rows = Math.ceil(this.rows);
|
2011-09-02 00:31:25 +04:00
|
|
|
var dates = this.generateDates();
|
2011-09-01 17:15:38 +04:00
|
|
|
var week = 1;
|
|
|
|
var weekday = 0;
|
2011-09-06 17:11:09 +04:00
|
|
|
var today = new Date();
|
2011-09-01 17:15:38 +04:00
|
|
|
for(var i = 0; i <= 41; i++){
|
2011-09-07 00:07:33 +04:00
|
|
|
var dayofmonth = dates[i].getDate();
|
|
|
|
var month = dates[i].getMonth();
|
|
|
|
var year = dates[i].getFullYear();
|
2011-09-06 17:11:09 +04:00
|
|
|
$("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday] + " .dateinfo").html(dayofmonth + Calendar.space + Calendar.UI.formatMonthShort(month));
|
|
|
|
if(dayofmonth == today.getDate() && month == today.getMonth() && year == today.getFullYear()){
|
2011-09-02 18:44:25 +04:00
|
|
|
$("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).addClass('thisday');
|
|
|
|
}
|
2011-09-06 15:38:19 +04:00
|
|
|
Calendar.UI.addDateInfo('#onemonthview .week_' + week + ' .' + Calendar.UI.weekdays[weekday], dates[i]);
|
2011-09-01 17:15:38 +04:00
|
|
|
if(weekday == 6){
|
|
|
|
weekday = 0;
|
|
|
|
week++;
|
|
|
|
}else{
|
|
|
|
weekday++;
|
|
|
|
}
|
|
|
|
}
|
2011-09-06 17:11:09 +04:00
|
|
|
if(this.rows == 4){
|
2011-09-02 14:55:56 +04:00
|
|
|
for(var i = 1;i <= 6;i++){
|
2011-09-02 18:44:25 +04:00
|
|
|
$("#onemonthview .week_" + String(i)).height("23%");
|
2011-09-02 14:55:56 +04:00
|
|
|
}
|
|
|
|
}
|
2011-09-06 17:11:09 +04:00
|
|
|
if(this.rows == 5) {
|
2011-09-03 01:51:18 +04:00
|
|
|
$("#onemonthview .week_5").show();
|
2011-09-02 14:55:56 +04:00
|
|
|
for(var i = 1;i <= 6;i++){
|
2011-09-02 18:44:25 +04:00
|
|
|
$("#onemonthview .week_" + String(i)).height("18%");
|
2011-09-02 14:55:56 +04:00
|
|
|
}
|
2011-09-01 17:15:38 +04:00
|
|
|
}
|
2011-09-06 17:11:09 +04:00
|
|
|
if(this.rows == 6) {
|
2011-09-03 01:51:18 +04:00
|
|
|
$("#onemonthview .week_5").show();
|
|
|
|
$("#onemonthview .week_6").show();
|
2011-09-02 14:55:56 +04:00
|
|
|
for(var i = 1;i <= 6;i++){
|
2011-09-02 18:44:25 +04:00
|
|
|
$("#onemonthview .week_" + String(i)).height("14%");
|
2011-09-02 14:55:56 +04:00
|
|
|
}
|
2011-09-01 17:15:38 +04:00
|
|
|
}
|
|
|
|
},
|
2011-09-02 01:27:00 +04:00
|
|
|
showEvents:function(){
|
2011-09-02 00:31:25 +04:00
|
|
|
var dates = this.generateDates();
|
2011-09-01 17:15:38 +04:00
|
|
|
var weekdaynum = 0;
|
|
|
|
var weeknum = 1;
|
|
|
|
for(var i = 0; i <= 41; i++) {
|
2011-09-07 00:07:33 +04:00
|
|
|
Calendar.UI.createEventsForDate(dates[i], weeknum);
|
2011-09-01 17:15:38 +04:00
|
|
|
if(weekdaynum == 6){
|
|
|
|
weekdaynum = 0;
|
|
|
|
weeknum++;
|
|
|
|
}else{
|
|
|
|
weekdaynum++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getEventContainer:function(week, weekday, when){
|
2011-09-02 18:44:25 +04:00
|
|
|
return $("#onemonthview .week_" + week + " .day." + Calendar.UI.weekdays[weekday] + " .events");
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
2011-09-03 16:05:20 +04:00
|
|
|
createEventLabel:function(event){
|
|
|
|
var time = '';
|
|
|
|
if (!event['allday']){
|
2011-09-04 00:13:14 +04:00
|
|
|
time = '<strong>' + Calendar.UI.formatTime(event['startdate']) + '</strong> ';
|
2011-09-03 16:05:20 +04:00
|
|
|
}
|
|
|
|
return $(document.createElement('p'))
|
|
|
|
.html(time + event['description'])
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
2011-09-02 00:31:25 +04:00
|
|
|
generateDates:function(){
|
|
|
|
var dates = new Array();
|
2011-09-06 17:11:09 +04:00
|
|
|
var date = new Date(Calendar.Date.current)
|
2011-09-06 16:14:52 +04:00
|
|
|
date.setDate(1);
|
|
|
|
var dayofweek = date.getDay();
|
|
|
|
if(dayofweek == 0) {
|
|
|
|
dayofweek = 7;
|
2011-09-06 17:11:09 +04:00
|
|
|
this.rows++;
|
2011-09-02 00:31:25 +04:00
|
|
|
}
|
2011-09-06 16:14:52 +04:00
|
|
|
date.setDate(date.getDate() - dayofweek + 1);
|
2011-09-06 13:47:23 +04:00
|
|
|
for(var i = 0; i <= 41; i++) {
|
2011-09-07 00:07:33 +04:00
|
|
|
dates[i] = new Date(date)
|
2011-09-06 16:14:52 +04:00
|
|
|
date.setDate(date.getDate() + 1);
|
2011-09-02 00:31:25 +04:00
|
|
|
}
|
|
|
|
return dates;
|
|
|
|
},
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
|
|
|
List:{
|
|
|
|
removeEvents:function(){
|
2011-09-07 17:13:26 +04:00
|
|
|
this.eventContainer = $('#listview #events').html('');
|
|
|
|
this.startdate = new Date();
|
|
|
|
this.enddate = new Date();
|
|
|
|
this.enddate.setDate(this.enddate.getDate());
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
|
|
|
renderCal:function(){
|
2011-09-07 17:13:26 +04:00
|
|
|
var today = new Date();
|
|
|
|
$('#datecontrol_date').val(this.formatDate(Calendar.Date.current));
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
2011-09-02 01:27:00 +04:00
|
|
|
showEvents:function(){
|
2011-09-07 17:13:26 +04:00
|
|
|
this.renderMoreBefore();
|
|
|
|
this.renderMoreAfter();
|
|
|
|
},
|
|
|
|
formatDate:function(date){
|
|
|
|
return Calendar.UI.formatDayShort(date.getDay())
|
|
|
|
+ Calendar.space
|
|
|
|
+ date.getDate()
|
|
|
|
+ Calendar.space
|
|
|
|
+ Calendar.UI.formatMonthShort(date.getMonth())
|
|
|
|
+ Calendar.space
|
|
|
|
+ date.getFullYear();
|
|
|
|
},
|
|
|
|
createDay:function(date) {
|
|
|
|
return $(document.createElement('div'))
|
|
|
|
.addClass('day')
|
|
|
|
.html(this.formatDate(date));
|
|
|
|
},
|
|
|
|
renderMoreBefore:function(){
|
|
|
|
var date = Calendar.UI.List.startdate;
|
|
|
|
for(var i = 0; i <= 13; i++) {
|
|
|
|
if (Calendar.UI.getEventsForDate(date)) {
|
|
|
|
Calendar.UI.List.dayContainer=Calendar.UI.List.createDay(date);
|
|
|
|
Calendar.UI.createEventsForDate(date, 0);
|
|
|
|
Calendar.UI.List.eventContainer.prepend(Calendar.UI.List.dayContainer);
|
|
|
|
}
|
|
|
|
date.setDate(date.getDate()-1);
|
|
|
|
}
|
|
|
|
var start = Calendar.UI.List.formatDate(date);
|
|
|
|
$('#listview #more_before').html(String(Calendar.UI.more_before).replace('{startdate}', start));
|
|
|
|
},
|
|
|
|
renderMoreAfter:function(){
|
|
|
|
var date = Calendar.UI.List.enddate;
|
|
|
|
for(var i = 0; i <= 13; i++) {
|
|
|
|
if (Calendar.UI.getEventsForDate(date)) {
|
|
|
|
Calendar.UI.List.dayContainer=Calendar.UI.List.createDay(date);
|
|
|
|
Calendar.UI.createEventsForDate(date, 0);
|
|
|
|
Calendar.UI.List.eventContainer.append(Calendar.UI.List.dayContainer);
|
|
|
|
}
|
|
|
|
date.setDate(date.getDate()+1);
|
|
|
|
}
|
|
|
|
var end = Calendar.UI.List.formatDate(date);
|
|
|
|
$('#listview #more_after').html(String(Calendar.UI.more_after).replace('{enddate}', end));
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
|
|
|
getEventContainer:function(week, weekday, when){
|
2011-09-07 17:13:26 +04:00
|
|
|
return this.dayContainer;
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
2011-09-03 16:05:20 +04:00
|
|
|
createEventLabel:function(event){
|
|
|
|
var time = '';
|
|
|
|
if (!event['allday']){
|
2011-09-04 00:13:14 +04:00
|
|
|
time = Calendar.UI.formatTime(event['startdate']) + ' - ' + Calendar.UI.formatTime(event['enddate']) + ' ';
|
2011-09-03 16:05:20 +04:00
|
|
|
}
|
|
|
|
return $(document.createElement('p'))
|
|
|
|
.html(time + event['description'])
|
2011-09-01 17:15:38 +04:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-09-07 17:13:26 +04:00
|
|
|
$(document).ready(function(){
|
|
|
|
$('#listview #more_before').click(Calendar.UI.List.renderMoreBefore);
|
|
|
|
$('#listview #more_after').click(Calendar.UI.List.renderMoreAfter);
|
|
|
|
});
|
2011-09-06 17:11:09 +04:00
|
|
|
//event vars
|
2011-09-08 14:29:29 +04:00
|
|
|
Calendar.UI.loadEvents();
|