2011-09-24 00:59:24 +04:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
|
|
|
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
2011-08-31 17:59:22 +04:00
|
|
|
Calendar={
|
2011-09-06 17:11:09 +04:00
|
|
|
space:' ',
|
2011-10-01 11:54:52 +04:00
|
|
|
firstdayofweek: '',
|
2011-09-01 17:15:38 +04:00
|
|
|
UI:{
|
2011-10-01 22:27:30 +04:00
|
|
|
drageventid: '',
|
2011-09-02 01:27:00 +04:00
|
|
|
loadEvents:function(year){
|
|
|
|
},
|
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-10-01 11:54:52 +04:00
|
|
|
var weekday = (date.getDay()+7-Calendar.firstdayofweek)%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-10-01 22:27:30 +04:00
|
|
|
.draggable({
|
|
|
|
drag: function() {
|
|
|
|
Calendar.UI.drageventid = event.id;
|
|
|
|
}
|
|
|
|
})
|
2011-09-16 16:02:21 +04:00
|
|
|
.click(this.editEvent);
|
2011-09-29 01:16:32 +04:00
|
|
|
var color = this.calendars[event['calendarid']]['color'];
|
|
|
|
if (color){
|
|
|
|
event_holder.css('background-color', color)
|
|
|
|
.addClass('colored');
|
|
|
|
}
|
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'
|
|
|
|
});
|
2011-09-23 00:22:52 +04:00
|
|
|
$('#category').multiselect({
|
|
|
|
header: false,
|
|
|
|
noneSelectedText: $('#category').attr('title'),
|
|
|
|
selectedList: 2,
|
|
|
|
minWidth:'auto',
|
|
|
|
classes: 'category',
|
|
|
|
});
|
2011-09-16 19:50:55 +04:00
|
|
|
$('#event').dialog({
|
|
|
|
width : 500,
|
|
|
|
close : function(event, ui) {
|
|
|
|
$(this).dialog('destroy').remove();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2011-10-18 23:04:14 +04:00
|
|
|
newEvent:function(date, allDay, jsEvent, view){
|
|
|
|
var dayofmonth = date.getDate();
|
|
|
|
var month = date.getMonth();
|
|
|
|
var year = date.getFullYear();
|
|
|
|
var hour = date.getHours();
|
|
|
|
var min = date.getMinutes();
|
2011-09-16 16:02:21 +04:00
|
|
|
if(dayofmonth <= 9){
|
|
|
|
dayofmonth = '0' + dayofmonth;
|
|
|
|
}
|
|
|
|
month++;
|
|
|
|
if(month <= 9){
|
|
|
|
month = '0' + month;
|
|
|
|
}
|
2011-10-18 23:04:14 +04:00
|
|
|
if(hour <= 9){
|
|
|
|
hour = '0' + hour;
|
|
|
|
}
|
|
|
|
if(min <= 9){
|
|
|
|
min = '0' + min;
|
|
|
|
}
|
2011-09-16 16:02:21 +04:00
|
|
|
var date = String(dayofmonth) + String(month) + String(year);
|
2011-10-18 23:04:14 +04:00
|
|
|
if (allDay){
|
|
|
|
var time = 'allday';
|
|
|
|
}else{
|
|
|
|
var time = String(hour) + String(min);
|
|
|
|
}
|
2011-09-16 16:02:21 +04:00
|
|
|
if($('#event').dialog('isOpen') == true){
|
|
|
|
// TODO: save event
|
|
|
|
$('#event').dialog('destroy').remove();
|
|
|
|
}else{
|
2011-09-29 01:16:32 +04:00
|
|
|
$('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'neweventform.php') + '?d=' + date + '&t=' + time, Calendar.UI.startEventDialog);
|
2011-09-16 16:02:21 +04:00
|
|
|
}
|
|
|
|
},
|
2011-10-18 23:04:14 +04:00
|
|
|
editEvent:function(calEvent, jsEvent, view){
|
|
|
|
var id = calEvent.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-29 01:16:32 +04:00
|
|
|
$('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'editeventform.php') + '?id=' + id, Calendar.UI.startEventDialog);
|
2011-09-15 23:20:42 +04:00
|
|
|
}
|
|
|
|
},
|
2011-09-23 00:09:03 +04:00
|
|
|
submitDeleteEventForm:function(url){
|
2011-10-19 21:09:01 +04:00
|
|
|
var post = $( '#event_form' ).serialize();
|
|
|
|
$('#errorbox').empty();
|
2011-09-23 00:09:03 +04:00
|
|
|
$.post(url, post, function(data){
|
|
|
|
if(data.status == 'success'){
|
2011-10-19 21:09:01 +04:00
|
|
|
$('#calendar_holder').fullCalendar('removeEvents', $('#event_form input[name=id]').val());
|
2011-09-23 00:09:03 +04:00
|
|
|
$('#event').dialog('destroy').remove();
|
|
|
|
} else {
|
2011-10-19 21:09:01 +04:00
|
|
|
$('#errorbox').html(t('calendar', 'Deletion failed'));
|
2011-09-23 00:09:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}, "json");
|
|
|
|
},
|
2011-09-16 19:06:57 +04:00
|
|
|
validateEventForm:function(url){
|
|
|
|
var post = $( "#event_form" ).serialize();
|
2011-09-29 01:16:32 +04:00
|
|
|
$("#errorbox").empty();
|
2011-09-16 19:06:57 +04:00
|
|
|
$.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();
|
2011-10-19 21:09:01 +04:00
|
|
|
$('#calendar_holder').fullCalendar('refetchEvents');
|
2011-09-16 19:06:57 +04:00
|
|
|
}
|
|
|
|
},"json");
|
|
|
|
},
|
2011-10-19 00:25:54 +04:00
|
|
|
moveEvent:function(event, dayDelta, minuteDelta, allDay, revertFunc){
|
|
|
|
$.post(OC.filePath('calendar', 'ajax', 'moveevent.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, allDay: allDay?1:0},
|
2011-10-01 22:27:30 +04:00
|
|
|
function(data) {
|
2011-10-19 00:25:54 +04:00
|
|
|
if (data.status == 'success'){
|
|
|
|
console.log("Event moved successfully");
|
|
|
|
}else{
|
|
|
|
revertFunc();
|
|
|
|
}
|
2011-10-01 22:27:30 +04:00
|
|
|
});
|
|
|
|
},
|
2011-10-19 01:02:00 +04:00
|
|
|
resizeEvent:function(event, dayDelta, minuteDelta, revertFunc){
|
|
|
|
$.post(OC.filePath('calendar', 'ajax', 'resizeevent.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta},
|
|
|
|
function(data) {
|
|
|
|
if (data.status == 'success'){
|
|
|
|
console.log("Event resized successfully");
|
|
|
|
}else{
|
|
|
|
revertFunc();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2011-09-27 23:56:16 +04:00
|
|
|
showadvancedoptions:function(){
|
|
|
|
$("#advanced_options").css("display", "block");
|
|
|
|
$("#advanced_options_button").css("display", "none");
|
|
|
|
},
|
2011-10-18 23:15:11 +04:00
|
|
|
createEventPopup:function(event, e, view){
|
2011-09-04 00:13:14 +04:00
|
|
|
var popup = $(this).data('popup');
|
|
|
|
if (!popup){
|
|
|
|
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){
|
2011-10-18 23:15:11 +04:00
|
|
|
if (event.allDay){
|
|
|
|
var timespan = $.fullCalendar.formatDates(event.start, event.end, t('calendar', "MMMM d[ yyyy]{ '—'[ MMMM][ d] yyyy}"));
|
2011-09-04 00:13:14 +04:00
|
|
|
}else{
|
2011-10-18 23:15:11 +04:00
|
|
|
var timespan = $.fullCalendar.formatDates(event.start, event.end, t('calendar', "HH:mm[ MMMM d yyyy]{ '—' HH:mm MMMM d yyyy}"));
|
2011-09-04 00:13:14 +04:00
|
|
|
}
|
|
|
|
return '<span class="timespan">' + timespan + '</span>'
|
|
|
|
+ ' '
|
2011-10-18 23:15:11 +04:00
|
|
|
+ '<span class="summary">' + event.title + '</span>'
|
|
|
|
+ '<span class="description">' + event.description + '</span>';
|
2011-09-04 00:13:14 +04:00
|
|
|
},
|
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-10-14 15:46:28 +04:00
|
|
|
initscroll:function(){
|
|
|
|
if(window.addEventListener)
|
|
|
|
document.addEventListener('DOMMouseScroll', Calendar.UI.scrollcalendar);
|
|
|
|
//}else{
|
|
|
|
document.onmousewheel = Calendar.UI.scrollcalendar;
|
|
|
|
//}
|
|
|
|
},
|
|
|
|
scrollcalendar:function(event){
|
|
|
|
var direction;
|
|
|
|
if(event.detail){
|
|
|
|
if(event.detail < 0){
|
|
|
|
direction = "top";
|
|
|
|
}else{
|
|
|
|
direction = "down";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (event.wheelDelta){
|
|
|
|
if(event.wheelDelta > 0){
|
|
|
|
direction = "top";
|
|
|
|
}else{
|
|
|
|
direction = "down";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(Calendar.UI.currentview == "onemonthview"){
|
|
|
|
if(direction == "down"){
|
|
|
|
Calendar.UI.updateDate("forward");
|
|
|
|
}else{
|
|
|
|
Calendar.UI.updateDate("backward");
|
|
|
|
}
|
|
|
|
}else if(Calendar.UI.currentview == "oneweekview"){
|
|
|
|
if(direction == "down"){
|
|
|
|
Calendar.UI.updateDate("forward");
|
|
|
|
}else{
|
|
|
|
Calendar.UI.updateDate("backward");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
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-29 01:16:32 +04:00
|
|
|
$('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'choosecalendar.php'), function(){
|
2011-09-16 16:11:22 +04:00
|
|
|
$('#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)
|
|
|
|
{
|
2011-09-29 01:16:32 +04:00
|
|
|
$.post(OC.filePath('calendar', 'ajax', 'activation.php'), { calendarid: calendarid, active: checkbox.checked?1:0 },
|
2011-09-12 00:06:45 +04:00
|
|
|
function(data) {
|
2011-10-19 21:07:56 +04:00
|
|
|
if (data.status == 'success'){
|
|
|
|
checkbox.checked = data.active == 1;
|
|
|
|
if (data.active == 1){
|
|
|
|
$('#calendar_holder').fullCalendar('addEventSource', data.eventSource);
|
|
|
|
}else{
|
|
|
|
$('#calendar_holder').fullCalendar('removeEventSource', data.eventSource.url);
|
|
|
|
}
|
|
|
|
}
|
2011-09-12 00:06:45 +04:00
|
|
|
});
|
|
|
|
},
|
2011-09-24 00:22:03 +04:00
|
|
|
newCalendar:function(object){
|
2011-09-12 00:06:45 +04:00
|
|
|
var tr = $(document.createElement('tr'))
|
2011-10-14 16:56:18 +04:00
|
|
|
.load(OC.filePath('calendar', 'ajax', 'newcalendar.php'),
|
|
|
|
function(){Calendar.UI.Calendar.colorPicker(this)});
|
2011-09-12 00:06:45 +04:00
|
|
|
$(object).closest('tr').after(tr).hide();
|
|
|
|
},
|
|
|
|
edit:function(object, calendarid){
|
|
|
|
var tr = $(document.createElement('tr'))
|
2011-10-03 22:32:31 +04:00
|
|
|
.load(OC.filePath('calendar', 'ajax', 'editcalendar.php') + "?calendarid="+calendarid,
|
|
|
|
function(){Calendar.UI.Calendar.colorPicker(this)});
|
2011-09-12 00:06:45 +04:00
|
|
|
$(object).closest('tr').after(tr).hide();
|
|
|
|
},
|
2011-10-19 21:07:56 +04:00
|
|
|
deleteCalendar:function(calid){
|
|
|
|
var check = confirm("Do you really want to delete this calendar?");
|
|
|
|
if(check == false){
|
|
|
|
return false;
|
|
|
|
}else{
|
|
|
|
$.post(OC.filePath('calendar', 'ajax', 'deletecalendar.php'), { calendarid: calid},
|
|
|
|
function(data) {
|
|
|
|
if (data.status == 'success'){
|
|
|
|
var url = 'ajax/events.php?calendar_id='+calid;
|
|
|
|
$('#calendar_holder').fullCalendar('removeEventSource', url);
|
|
|
|
$('#choosecalendar_dialog').dialog('destroy').remove();
|
|
|
|
Calendar.UI.Calendar.overview();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
submit:function(button, calendarid){
|
|
|
|
var displayname = $("#displayname_"+calendarid).val();
|
|
|
|
var active = $("#edit_active_"+calendarid+":checked").length;
|
|
|
|
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.status == 'success'){
|
|
|
|
$(button).closest('tr').prev().html(data.page).show().next().remove();
|
|
|
|
$('#calendar_holder').fullCalendar('removeEventSource', data.eventSource.url);
|
|
|
|
$('#calendar_holder').fullCalendar('addEventSource', data.eventSource);
|
|
|
|
}
|
|
|
|
}, 'json');
|
|
|
|
},
|
|
|
|
cancel:function(button, calendarid){
|
|
|
|
$(button).closest('tr').prev().show().next().remove();
|
|
|
|
},
|
2011-10-03 22:32:31 +04:00
|
|
|
colorPicker:function(container){
|
|
|
|
// based on jquery-colorpicker at jquery.webspirited.com
|
|
|
|
var obj = $('.colorpicker', container);
|
|
|
|
var picker = $('<div class="calendar-colorpicker"></div>');
|
|
|
|
//build an array of colors
|
|
|
|
var colors = {};
|
|
|
|
$(obj).children('option').each(function(i, elm) {
|
|
|
|
colors[i] = {};
|
|
|
|
colors[i].color = $(elm).val();
|
|
|
|
colors[i].label = $(elm).text();
|
|
|
|
});
|
|
|
|
for (var i in colors) {
|
2011-10-07 18:03:26 +04:00
|
|
|
picker.append('<span class="calendar-colorpicker-color ' + (colors[i].color == $(obj).children(":selected").val() ? ' active' : '') + '" rel="' + colors[i].label + '" style="background-color: #' + colors[i].color + ';"></span>');
|
2011-10-03 22:32:31 +04:00
|
|
|
}
|
|
|
|
picker.delegate(".calendar-colorpicker-color", "click", function() {
|
|
|
|
$(obj).val($(this).attr('rel'));
|
|
|
|
$(obj).change();
|
|
|
|
picker.children('.calendar-colorpicker-color.active').removeClass('active');
|
|
|
|
$(this).addClass('active');
|
|
|
|
});
|
|
|
|
$(obj).after(picker);
|
|
|
|
$(obj).css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: -10000
|
|
|
|
});
|
2011-10-19 21:07:56 +04:00
|
|
|
}
|
2011-10-17 21:58:56 +04:00
|
|
|
},
|
2011-09-01 17:15:38 +04:00
|
|
|
List:{
|
|
|
|
removeEvents:function(){
|
2011-09-29 01:16:32 +04:00
|
|
|
this.eventContainer = $('#listview #events').empty();
|
2011-09-07 17:13:26 +04:00
|
|
|
this.startdate = new Date();
|
|
|
|
this.enddate = new Date();
|
|
|
|
this.enddate.setDate(this.enddate.getDate());
|
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-10-14 15:46:28 +04:00
|
|
|
Calendar.UI.initscroll();
|
2011-10-18 21:58:47 +04:00
|
|
|
$('#calendar_holder').fullCalendar({
|
|
|
|
header: false,
|
|
|
|
firstDay: 1,
|
|
|
|
editable: true,
|
2011-10-18 22:42:22 +04:00
|
|
|
defaultView: defaultView,
|
|
|
|
timeFormat: {
|
|
|
|
agenda: 'HH:mm{ - HH:mm}',
|
|
|
|
'': 'HH:mm'
|
|
|
|
},
|
|
|
|
axisFormat: 'HH:mm',
|
|
|
|
monthNames: monthNames,
|
|
|
|
monthNamesShort: monthNamesShort,
|
|
|
|
dayNames: dayNames,
|
|
|
|
dayNamesShort: dayNamesShort,
|
|
|
|
allDayText: allDayText,
|
2011-10-18 21:58:47 +04:00
|
|
|
viewDisplay: function(view) {
|
|
|
|
$('#datecontrol_date').html(view.title);
|
2011-10-18 22:42:22 +04:00
|
|
|
$.get(OC.filePath('calendar', 'ajax', 'changeview.php') + "?v="+view.name);
|
2011-10-18 23:04:14 +04:00
|
|
|
},
|
|
|
|
dayClick: Calendar.UI.newEvent,
|
2011-10-18 23:15:11 +04:00
|
|
|
eventClick: Calendar.UI.editEvent,
|
2011-10-19 00:25:54 +04:00
|
|
|
eventDrop: Calendar.UI.moveEvent,
|
2011-10-19 01:02:00 +04:00
|
|
|
eventResize: Calendar.UI.resizeEvent,
|
2011-10-18 23:15:11 +04:00
|
|
|
eventMouseover: Calendar.UI.createEventPopup,
|
|
|
|
eventMouseout: Calendar.UI.hideEventPopup,
|
|
|
|
eventSources: eventSources
|
2011-10-18 21:58:47 +04:00
|
|
|
});
|
|
|
|
$('#oneweekview_radio').click(function(){
|
|
|
|
$('#calendar_holder').fullCalendar('changeView', 'agendaWeek');
|
|
|
|
});
|
|
|
|
$('#onemonthview_radio').click(function(){
|
|
|
|
$('#calendar_holder').fullCalendar('changeView', 'month');
|
|
|
|
});
|
|
|
|
//$('#listview_radio').click();
|
|
|
|
$('#today_input').click(function(){
|
|
|
|
$('#calendar_holder').fullCalendar('today');
|
|
|
|
});
|
|
|
|
$('#datecontrol_left').click(function(){
|
|
|
|
$('#calendar_holder').fullCalendar('prev');
|
|
|
|
});
|
|
|
|
$('#datecontrol_right').click(function(){
|
|
|
|
$('#calendar_holder').fullCalendar('next');
|
|
|
|
});
|
2011-09-07 17:13:26 +04:00
|
|
|
});
|