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-09-01 17:15:38 +04:00
|
|
|
UI:{
|
2011-09-16 19:50:55 +04:00
|
|
|
startEventDialog:function(){
|
2011-10-25 22:01:04 +04:00
|
|
|
$('.tipsy').remove();
|
2011-10-28 00:54:39 +04:00
|
|
|
$('#calendar_holder').fullCalendar('unselect');
|
2011-09-16 19:50:55 +04:00
|
|
|
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-25 21:57:20 +04:00
|
|
|
newEvent:function(start, end, allday){
|
|
|
|
start = Math.round(start.getTime()/1000);
|
|
|
|
if (end){
|
|
|
|
end = Math.round(end.getTime()/1000);
|
2011-10-18 23:04:14 +04:00
|
|
|
}
|
2011-09-16 16:02:21 +04:00
|
|
|
if($('#event').dialog('isOpen') == true){
|
|
|
|
// TODO: save event
|
|
|
|
$('#event').dialog('destroy').remove();
|
|
|
|
}else{
|
2011-10-25 21:57:20 +04:00
|
|
|
$('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'neweventform.php'), {start:start, end:end, allday:allday?1:0}, 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"){
|
2011-10-22 15:14:54 +04:00
|
|
|
var output = missing_field + ": <br />";
|
2011-09-16 19:06:57 +04:00
|
|
|
if(data.title == "true"){
|
2011-10-22 15:14:54 +04:00
|
|
|
output = output + missing_field_title + "<br />";
|
2011-09-16 19:06:57 +04:00
|
|
|
}
|
|
|
|
if(data.cal == "true"){
|
2011-10-22 15:14:54 +04:00
|
|
|
output = output + missing_field_calendar + "<br />";
|
2011-09-16 19:06:57 +04:00
|
|
|
}
|
|
|
|
if(data.from == "true"){
|
2011-10-22 15:14:54 +04:00
|
|
|
output = output + missing_field_fromdate + "<br />";
|
2011-09-16 19:06:57 +04:00
|
|
|
}
|
|
|
|
if(data.fromtime == "true"){
|
2011-10-22 15:14:54 +04:00
|
|
|
output = output + missing_field_fromtime + "<br />";
|
2011-09-16 19:06:57 +04:00
|
|
|
}
|
|
|
|
if(data.to == "true"){
|
2011-10-22 15:14:54 +04:00
|
|
|
output = output + missing_field_todate + "<br />";
|
2011-09-16 19:06:57 +04:00
|
|
|
}
|
|
|
|
if(data.totime == "true"){
|
2011-10-22 15:14:54 +04:00
|
|
|
output = output + missing_field_totime + "<br />";
|
2011-09-16 19:06:57 +04:00
|
|
|
}
|
|
|
|
if(data.endbeforestart == "true"){
|
2011-10-22 15:14:54 +04:00
|
|
|
output = output + missing_field_startsbeforeends + "!<br/>";
|
2011-09-16 19:06:57 +04:00
|
|
|
}
|
|
|
|
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-09-04 00:13:14 +04:00
|
|
|
getEventPopupText:function(event){
|
2011-10-18 23:15:11 +04:00
|
|
|
if (event.allDay){
|
2011-10-21 23:47:42 +04:00
|
|
|
var timespan = $.fullCalendar.formatDates(event.start, event.end, t('calendar', "ddd d MMMM[ yyyy]{ -[ddd d] MMMM yyyy}"));
|
2011-09-04 00:13:14 +04:00
|
|
|
}else{
|
2011-10-21 23:47:42 +04:00
|
|
|
var timespan = $.fullCalendar.formatDates(event.start, event.end, t('calendar', "ddd d MMMM[ yyyy] HH:mm{ -[ ddd d MMMM yyyy] HH:mm}"));
|
2011-10-21 00:18:17 +04:00
|
|
|
// Tue 18 October 2011 08:00 - 16:00
|
2011-09-04 00:13:14 +04:00
|
|
|
}
|
2011-10-21 23:47:42 +04:00
|
|
|
var html =
|
|
|
|
'<div class="summary">' + event.title + '</div>' +
|
|
|
|
'<div class="timespan">' + timespan + '</div>';
|
|
|
|
if (event.description){
|
|
|
|
html += '<div class="description">' + event.description + '</div>';
|
|
|
|
}
|
|
|
|
return html;
|
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-21 01:34:05 +04:00
|
|
|
initScroll:function(){
|
2011-10-14 15:46:28 +04:00
|
|
|
if(window.addEventListener)
|
2011-10-21 01:34:05 +04:00
|
|
|
document.addEventListener('DOMMouseScroll', Calendar.UI.scrollCalendar);
|
2011-10-14 15:46:28 +04:00
|
|
|
//}else{
|
2011-10-21 01:34:05 +04:00
|
|
|
document.onmousewheel = Calendar.UI.scrollCalendar;
|
2011-10-14 15:46:28 +04:00
|
|
|
//}
|
|
|
|
},
|
2011-10-21 01:34:05 +04:00
|
|
|
scrollCalendar:function(event){
|
2011-10-14 15:46:28 +04:00
|
|
|
var direction;
|
|
|
|
if(event.detail){
|
|
|
|
if(event.detail < 0){
|
2011-10-21 01:34:05 +04:00
|
|
|
direction = 'top';
|
2011-10-14 15:46:28 +04:00
|
|
|
}else{
|
2011-10-21 01:34:05 +04:00
|
|
|
direction = 'down';
|
2011-10-14 15:46:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (event.wheelDelta){
|
|
|
|
if(event.wheelDelta > 0){
|
2011-10-21 01:34:05 +04:00
|
|
|
direction = 'top';
|
2011-10-14 15:46:28 +04:00
|
|
|
}else{
|
2011-10-21 01:34:05 +04:00
|
|
|
direction = 'down';
|
2011-10-14 15:46:28 +04:00
|
|
|
}
|
|
|
|
}
|
2011-10-25 21:56:57 +04:00
|
|
|
var scroll = $(document).scrollTop(),
|
|
|
|
doc_height = $(document).height(),
|
|
|
|
win_height = $(window).height();
|
|
|
|
if(direction == 'down' && win_height == (doc_height - scroll)){
|
2011-10-21 01:34:05 +04:00
|
|
|
$('#calendar_holder').fullCalendar('next');
|
2011-10-25 21:56:57 +04:00
|
|
|
}else if (direction == 'top' && scroll == 0) {
|
2011-10-21 01:34:05 +04:00
|
|
|
$('#calendar_holder').fullCalendar('prev');
|
2011-10-14 15:46:28 +04:00
|
|
|
}
|
|
|
|
},
|
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-21 00:18:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$.fullCalendar.views.list = ListView;
|
|
|
|
function ListView(element, calendar) {
|
|
|
|
var t = this;
|
|
|
|
|
|
|
|
// imports
|
|
|
|
jQuery.fullCalendar.views.month.call(t, element, calendar);
|
|
|
|
var opt = t.opt;
|
|
|
|
var trigger = t.trigger;
|
|
|
|
var eventElementHandlers = t.eventElementHandlers;
|
|
|
|
var reportEventElement = t.reportEventElement;
|
|
|
|
var formatDate = calendar.formatDate;
|
|
|
|
var formatDates = calendar.formatDates;
|
|
|
|
var addDays = $.fullCalendar.addDays;
|
|
|
|
var cloneDate = $.fullCalendar.cloneDate;
|
|
|
|
function skipWeekend(date, inc, excl) {
|
|
|
|
inc = inc || 1;
|
|
|
|
while (!date.getDay() || (excl && date.getDay()==1 || !excl && date.getDay()==6)) {
|
|
|
|
addDays(date, inc);
|
|
|
|
}
|
|
|
|
return date;
|
|
|
|
}
|
|
|
|
|
|
|
|
// overrides
|
|
|
|
t.name='list';
|
|
|
|
t.render=render;
|
|
|
|
t.renderEvents=renderEvents;
|
|
|
|
t.setHeight=setHeight;
|
|
|
|
t.setWidth=setWidth;
|
|
|
|
t.clearEvents=clearEvents;
|
|
|
|
|
|
|
|
function setHeight(height, dateChanged) {
|
|
|
|
}
|
|
|
|
|
|
|
|
function setWidth(width) {
|
|
|
|
}
|
|
|
|
|
|
|
|
function clearEvents() {
|
|
|
|
this.reportEventClear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// main
|
|
|
|
function sortEvent(a, b) {
|
|
|
|
return a.start - b.start;
|
|
|
|
}
|
|
|
|
|
|
|
|
function render(date, delta) {
|
|
|
|
if (!t.start){
|
|
|
|
t.start = addDays(cloneDate(date, true), -7);
|
|
|
|
t.end = addDays(cloneDate(date, true), 7);
|
|
|
|
}
|
|
|
|
if (delta) {
|
|
|
|
if (delta < 0){
|
|
|
|
addDays(t.start, -7);
|
|
|
|
if (!opt('weekends')) {
|
|
|
|
skipWeekend(t.start, delta < 0 ? -1 : 1);
|
2011-09-07 17:13:26 +04:00
|
|
|
}
|
2011-10-21 00:18:17 +04:00
|
|
|
}else{
|
|
|
|
addDays(t.end, 7);
|
|
|
|
if (!opt('weekends')) {
|
|
|
|
skipWeekend(t.end, delta < 0 ? -1 : 1);
|
2011-09-07 17:13:26 +04:00
|
|
|
}
|
2011-10-21 00:18:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
t.title = formatDates(
|
|
|
|
t.start,
|
|
|
|
t.end,
|
|
|
|
opt('titleFormat', 'week')
|
|
|
|
);
|
|
|
|
t.visStart = cloneDate(t.start);
|
|
|
|
t.visEnd = cloneDate(t.end);
|
|
|
|
}
|
|
|
|
|
|
|
|
function eventsOfThisDay(events, theDate) {
|
|
|
|
var start = cloneDate(theDate, true);
|
|
|
|
var end = addDays(cloneDate(start), 1);
|
|
|
|
var retArr = new Array();
|
|
|
|
for (i in events) {
|
|
|
|
var event_end = t.eventEnd(events[i]);
|
|
|
|
if (events[i].start < end && event_end >= start) {
|
|
|
|
retArr.push(events[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return retArr;
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderEvent(event) {
|
|
|
|
if (event.allDay) { //all day event
|
|
|
|
var time = opt('allDayText');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var time = formatDates(event.start, event.end, opt('timeFormat', 'agenda'));
|
|
|
|
}
|
|
|
|
var classes = ['fc-event', 'fc-list-event'];
|
|
|
|
classes = classes.concat(event.className);
|
|
|
|
if (event.source) {
|
|
|
|
classes = classes.concat(event.source.className || []);
|
|
|
|
}
|
|
|
|
var html = '<tr>' +
|
|
|
|
'<td> </td>' +
|
|
|
|
'<td class="fc-list-time">' +
|
|
|
|
time +
|
|
|
|
'</td>' +
|
|
|
|
'<td> </td>' +
|
|
|
|
'<td class="fc-list-event">' +
|
|
|
|
'<span id="list' + event.id + '"' +
|
|
|
|
' class="' + classes.join(' ') + '"' +
|
|
|
|
'>' +
|
|
|
|
'<span class="fc-event-title">' +
|
|
|
|
event.title +
|
|
|
|
'</span>' +
|
|
|
|
'</span>' +
|
|
|
|
'</td>' +
|
|
|
|
'</tr>';
|
|
|
|
return html;
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderDay(date, events) {
|
|
|
|
var dayRows = $('<tr>' +
|
|
|
|
'<td colspan="4" class="fc-list-date">' +
|
|
|
|
'<span>' +
|
|
|
|
formatDate(date, opt('titleFormat', 'day')) +
|
|
|
|
'</span>' +
|
|
|
|
'</td>' +
|
|
|
|
'</tr>');
|
|
|
|
for (i in events) {
|
|
|
|
var event = events[i];
|
|
|
|
var eventElement = $(renderEvent(event));
|
|
|
|
triggerRes = trigger('eventRender', event, event, eventElement);
|
|
|
|
if (triggerRes === false) {
|
|
|
|
eventElement.remove();
|
|
|
|
}else{
|
|
|
|
if (triggerRes && triggerRes !== true) {
|
|
|
|
eventElement.remove();
|
|
|
|
eventElement = $(triggerRes);
|
2011-09-03 16:05:20 +04:00
|
|
|
}
|
2011-10-21 00:18:17 +04:00
|
|
|
$.merge(dayRows, eventElement);
|
|
|
|
eventElementHandlers(event, eventElement);
|
|
|
|
reportEventElement(event, eventElement);
|
|
|
|
}
|
2011-09-01 17:15:38 +04:00
|
|
|
}
|
2011-10-21 00:18:17 +04:00
|
|
|
return dayRows;
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderEvents(events, modifiedEventId) {
|
|
|
|
events = events.sort(sortEvent);
|
|
|
|
|
|
|
|
var table = $('<table class="fc-list-table"></table>');
|
|
|
|
var total = events.length;
|
|
|
|
if (total > 0) {
|
|
|
|
var date = cloneDate(t.visStart);
|
|
|
|
while (date <= t.visEnd) {
|
|
|
|
var dayEvents = eventsOfThisDay(events, date);
|
|
|
|
if (dayEvents.length > 0) {
|
|
|
|
table.append(renderDay(date, dayEvents));
|
|
|
|
}
|
|
|
|
date=addDays(date, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.element.html(table);
|
2011-09-01 17:15:38 +04:00
|
|
|
}
|
|
|
|
}
|
2011-09-07 17:13:26 +04:00
|
|
|
$(document).ready(function(){
|
2011-10-25 21:56:57 +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'
|
|
|
|
},
|
2011-10-21 00:18:17 +04:00
|
|
|
titleFormat: {
|
|
|
|
list: 'yyyy/MMM/d dddd'
|
|
|
|
},
|
2011-10-18 22:42:22 +04:00
|
|
|
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
|
|
|
},
|
2011-10-25 21:57:20 +04:00
|
|
|
selectable: true,
|
|
|
|
selectHelper: true,
|
|
|
|
select: 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-21 23:47:42 +04:00
|
|
|
eventRender: function(event, element) {
|
|
|
|
element.tipsy({
|
|
|
|
className: 'tipsy-event',
|
|
|
|
opacity: 0.9,
|
|
|
|
gravity:$.fn.tipsy.autoBounds(150, 's'),
|
|
|
|
fade:true,
|
|
|
|
delayIn: 400,
|
|
|
|
html:true,
|
|
|
|
title:function() {
|
|
|
|
return Calendar.UI.getEventPopupText(event);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2011-10-18 23:15:11 +04:00
|
|
|
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');
|
|
|
|
});
|
2011-10-21 00:18:17 +04:00
|
|
|
$('#listview_radio').click(function(){
|
|
|
|
$('#calendar_holder').fullCalendar('changeView', 'list');
|
|
|
|
});
|
2011-10-18 21:58:47 +04:00
|
|
|
$('#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
|
|
|
});
|