2011-09-24 00:59:24 +04:00
|
|
|
/**
|
2012-01-15 03:06:26 +04:00
|
|
|
* Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
2011-09-24 00:59:24 +04:00
|
|
|
* 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-01 17:15:38 +04:00
|
|
|
UI:{
|
2011-12-28 00:48:04 +04:00
|
|
|
loading: function(isLoading){
|
|
|
|
if (isLoading){
|
|
|
|
$('#loading').show();
|
|
|
|
}else{
|
|
|
|
$('#loading').hide();
|
|
|
|
}
|
|
|
|
},
|
2011-09-16 19:50:55 +04:00
|
|
|
startEventDialog:function(){
|
2011-12-28 00:48:04 +04:00
|
|
|
Calendar.UI.loading(false);
|
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'
|
|
|
|
});
|
2012-01-16 23:22:54 +04:00
|
|
|
$('#fromtime').timepicker({
|
|
|
|
showPeriodLabels: false
|
|
|
|
});
|
|
|
|
$('#totime').timepicker({
|
|
|
|
showPeriodLabels: false
|
|
|
|
});
|
2012-04-13 01:06:45 +04:00
|
|
|
$('#category').multiple_autocomplete({source: categories});
|
2011-12-26 02:19:49 +04:00
|
|
|
Calendar.UI.repeat('init');
|
|
|
|
$('#end').change(function(){
|
|
|
|
Calendar.UI.repeat('end');
|
|
|
|
});
|
|
|
|
$('#repeat').change(function(){
|
|
|
|
Calendar.UI.repeat('repeat');
|
|
|
|
});
|
|
|
|
$('#advanced_year').change(function(){
|
|
|
|
Calendar.UI.repeat('year');
|
|
|
|
});
|
|
|
|
$('#advanced_month').change(function(){
|
|
|
|
Calendar.UI.repeat('month');
|
|
|
|
});
|
2012-01-31 14:57:09 +04:00
|
|
|
$( "#event" ).tabs({ selected: 0});
|
2011-09-16 19:50:55 +04:00
|
|
|
$('#event').dialog({
|
|
|
|
width : 500,
|
2012-06-09 17:38:03 +04:00
|
|
|
height: 600,
|
2011-09-16 19:50:55 +04:00
|
|
|
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-12-28 00:48:04 +04:00
|
|
|
Calendar.UI.loading(true);
|
2012-02-20 14:27:25 +04:00
|
|
|
$('#dialog_holder').load(OC.filePath('calendar', 'ajax/event', 'new.form.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){
|
2012-03-01 23:56:00 +04:00
|
|
|
if (calEvent.editable == false || calEvent.source.editable == false) {
|
|
|
|
return;
|
|
|
|
}
|
2011-10-18 23:04:14 +04:00
|
|
|
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-12-28 00:48:04 +04:00
|
|
|
Calendar.UI.loading(true);
|
2012-06-09 16:40:15 +04:00
|
|
|
$('#dialog_holder').load(OC.filePath('calendar', 'ajax/event', 'edit.form.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-12-28 00:48:04 +04:00
|
|
|
Calendar.UI.loading(true);
|
2011-09-23 00:09:03 +04:00
|
|
|
$.post(url, post, function(data){
|
2011-12-28 00:48:04 +04:00
|
|
|
Calendar.UI.loading(false);
|
2011-09-23 00:09:03 +04:00
|
|
|
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-12-28 00:48:04 +04:00
|
|
|
Calendar.UI.loading(true);
|
2011-09-16 19:06:57 +04:00
|
|
|
$.post(url, post,
|
|
|
|
function(data){
|
2011-12-28 00:48:04 +04:00
|
|
|
Calendar.UI.loading(false);
|
2011-09-16 19:06:57 +04:00
|
|
|
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){
|
2011-10-28 00:56:22 +04:00
|
|
|
$('.tipsy').remove();
|
2011-12-28 00:48:04 +04:00
|
|
|
Calendar.UI.loading(true);
|
2012-02-20 14:27:25 +04:00
|
|
|
$.post(OC.filePath('calendar', 'ajax/event', 'move.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, allDay: allDay?1:0, lastmodified: event.lastmodified},
|
2011-10-01 22:27:30 +04:00
|
|
|
function(data) {
|
2011-12-28 00:48:04 +04:00
|
|
|
Calendar.UI.loading(false);
|
2011-10-19 00:25:54 +04:00
|
|
|
if (data.status == 'success'){
|
2011-11-10 01:17:09 +04:00
|
|
|
event.lastmodified = data.lastmodified;
|
2011-10-19 00:25:54 +04:00
|
|
|
console.log("Event moved successfully");
|
|
|
|
}else{
|
|
|
|
revertFunc();
|
2011-11-10 01:17:09 +04:00
|
|
|
$('#calendar_holder').fullCalendar('refetchEvents');
|
2011-10-19 00:25:54 +04:00
|
|
|
}
|
2011-10-01 22:27:30 +04:00
|
|
|
});
|
|
|
|
},
|
2011-10-19 01:02:00 +04:00
|
|
|
resizeEvent:function(event, dayDelta, minuteDelta, revertFunc){
|
2011-10-28 00:56:22 +04:00
|
|
|
$('.tipsy').remove();
|
2011-12-28 00:48:04 +04:00
|
|
|
Calendar.UI.loading(true);
|
2012-02-20 14:27:25 +04:00
|
|
|
$.post(OC.filePath('calendar', 'ajax/event', 'resize.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, lastmodified: event.lastmodified},
|
2011-10-19 01:02:00 +04:00
|
|
|
function(data) {
|
2011-12-28 00:48:04 +04:00
|
|
|
Calendar.UI.loading(false);
|
2011-10-19 01:02:00 +04:00
|
|
|
if (data.status == 'success'){
|
2011-11-10 01:17:09 +04:00
|
|
|
event.lastmodified = data.lastmodified;
|
2011-10-19 01:02:00 +04:00
|
|
|
console.log("Event resized successfully");
|
|
|
|
}else{
|
|
|
|
revertFunc();
|
2011-11-10 01:17:09 +04:00
|
|
|
$('#calendar_holder').fullCalendar('refetchEvents');
|
2011-10-19 01:02:00 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2011-09-27 23:56:16 +04:00
|
|
|
showadvancedoptions:function(){
|
2011-12-26 02:19:49 +04:00
|
|
|
$("#advanced_options").slideDown('slow');
|
2011-09-27 23:56:16 +04:00
|
|
|
$("#advanced_options_button").css("display", "none");
|
|
|
|
},
|
2011-12-26 02:19:49 +04:00
|
|
|
showadvancedoptionsforrepeating:function(){
|
|
|
|
if($("#advanced_options_repeating").is(":hidden")){
|
|
|
|
$('#advanced_options_repeating').slideDown('slow');
|
|
|
|
}else{
|
|
|
|
$('#advanced_options_repeating').slideUp('slow');
|
|
|
|
}
|
|
|
|
},
|
2011-09-04 00:13:14 +04:00
|
|
|
getEventPopupText:function(event){
|
2011-10-18 23:15:11 +04:00
|
|
|
if (event.allDay){
|
2011-11-20 17:23:26 +04:00
|
|
|
var timespan = $.fullCalendar.formatDates(event.start, event.end, 'ddd d MMMM[ yyyy]{ -[ddd d] MMMM yyyy}', {monthNamesShort: monthNamesShort, monthNames: monthNames, dayNames: dayNames, dayNamesShort: dayNamesShort}); //t('calendar', "ddd d MMMM[ yyyy]{ -[ddd d] MMMM yyyy}")
|
2011-09-04 00:13:14 +04:00
|
|
|
}else{
|
2011-11-20 17:23:26 +04:00
|
|
|
var timespan = $.fullCalendar.formatDates(event.start, event.end, 'ddd d MMMM[ yyyy] ' + defaulttime + '{ -[ ddd d MMMM yyyy]' + defaulttime + '}', {monthNamesShort: monthNamesShort, monthNames: monthNames, dayNames: dayNames, dayNamesShort: dayNamesShort}); //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){
|
2012-06-22 01:27:45 +04:00
|
|
|
$('#caldav_url').val(totalurl + '/' + username + '/' + decodeURIComponent(calname));
|
2011-09-16 19:50:55 +04:00
|
|
|
$('#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)
|
2012-02-27 00:29:52 +04:00
|
|
|
document.addEventListener('DOMMouseScroll', Calendar.UI.scrollCalendar, false);
|
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-28 00:56:22 +04:00
|
|
|
$('.tipsy').remove();
|
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-11-18 02:53:06 +04:00
|
|
|
$(document).scrollTop(0);
|
|
|
|
event.preventDefault();
|
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-11-18 02:53:06 +04:00
|
|
|
$(document).scrollTop(win_height);
|
|
|
|
event.preventDefault();
|
2011-10-14 15:46:28 +04:00
|
|
|
}
|
|
|
|
},
|
2011-12-26 02:19:49 +04:00
|
|
|
repeat:function(task){
|
|
|
|
if(task=='init'){
|
|
|
|
$('#byweekno').multiselect({
|
|
|
|
header: false,
|
|
|
|
noneSelectedText: $('#advanced_byweekno').attr('title'),
|
|
|
|
selectedList: 2,
|
|
|
|
minWidth:'auto'
|
|
|
|
});
|
|
|
|
$('#weeklyoptions').multiselect({
|
|
|
|
header: false,
|
|
|
|
noneSelectedText: $('#weeklyoptions').attr('title'),
|
|
|
|
selectedList: 2,
|
|
|
|
minWidth:'auto'
|
|
|
|
});
|
|
|
|
$('input[name="bydate"]').datepicker({
|
|
|
|
dateFormat : 'dd-mm-yy'
|
|
|
|
});
|
|
|
|
$('#byyearday').multiselect({
|
|
|
|
header: false,
|
|
|
|
noneSelectedText: $('#byyearday').attr('title'),
|
|
|
|
selectedList: 2,
|
|
|
|
minWidth:'auto'
|
|
|
|
});
|
|
|
|
$('#bymonth').multiselect({
|
|
|
|
header: false,
|
|
|
|
noneSelectedText: $('#bymonth').attr('title'),
|
|
|
|
selectedList: 2,
|
|
|
|
minWidth:'auto'
|
|
|
|
});
|
|
|
|
$('#bymonthday').multiselect({
|
|
|
|
header: false,
|
|
|
|
noneSelectedText: $('#bymonthday').attr('title'),
|
|
|
|
selectedList: 2,
|
|
|
|
minWidth:'auto'
|
|
|
|
});
|
|
|
|
Calendar.UI.repeat('end');
|
|
|
|
Calendar.UI.repeat('month');
|
|
|
|
Calendar.UI.repeat('year');
|
2012-01-05 23:54:44 +04:00
|
|
|
Calendar.UI.repeat('repeat');
|
2011-12-26 02:19:49 +04:00
|
|
|
}
|
|
|
|
if(task == 'end'){
|
|
|
|
$('#byoccurrences').css('display', 'none');
|
|
|
|
$('#bydate').css('display', 'none');
|
|
|
|
if($('#end option:selected').val() == 'count'){
|
|
|
|
$('#byoccurrences').css('display', 'block');
|
|
|
|
}
|
|
|
|
if($('#end option:selected').val() == 'date'){
|
|
|
|
$('#bydate').css('display', 'block');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(task == 'repeat'){
|
|
|
|
$('#advanced_month').css('display', 'none');
|
|
|
|
$('#advanced_weekday').css('display', 'none');
|
|
|
|
$('#advanced_weekofmonth').css('display', 'none');
|
|
|
|
$('#advanced_byyearday').css('display', 'none');
|
|
|
|
$('#advanced_bymonth').css('display', 'none');
|
|
|
|
$('#advanced_byweekno').css('display', 'none');
|
|
|
|
$('#advanced_year').css('display', 'none');
|
|
|
|
$('#advanced_bymonthday').css('display', 'none');
|
|
|
|
if($('#repeat option:selected').val() == 'monthly'){
|
|
|
|
$('#advanced_month').css('display', 'block');
|
2012-01-05 23:54:44 +04:00
|
|
|
Calendar.UI.repeat('month');
|
2011-12-26 02:19:49 +04:00
|
|
|
}
|
|
|
|
if($('#repeat option:selected').val() == 'weekly'){
|
|
|
|
$('#advanced_weekday').css('display', 'block');
|
|
|
|
}
|
|
|
|
if($('#repeat option:selected').val() == 'yearly'){
|
|
|
|
$('#advanced_year').css('display', 'block');
|
2012-01-05 23:54:44 +04:00
|
|
|
Calendar.UI.repeat('year');
|
2011-12-26 02:19:49 +04:00
|
|
|
}
|
|
|
|
if($('#repeat option:selected').val() == 'doesnotrepeat'){
|
|
|
|
$('#advanced_options_repeating').slideUp('slow');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(task == 'month'){
|
|
|
|
$('#advanced_weekday').css('display', 'none');
|
|
|
|
$('#advanced_weekofmonth').css('display', 'none');
|
|
|
|
if($('#advanced_month_select option:selected').val() == 'weekday'){
|
|
|
|
$('#advanced_weekday').css('display', 'block');
|
|
|
|
$('#advanced_weekofmonth').css('display', 'block');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(task == 'year'){
|
|
|
|
$('#advanced_weekday').css('display', 'none');
|
|
|
|
$('#advanced_byyearday').css('display', 'none');
|
|
|
|
$('#advanced_bymonth').css('display', 'none');
|
|
|
|
$('#advanced_byweekno').css('display', 'none');
|
|
|
|
$('#advanced_bymonthday').css('display', 'none');
|
2011-12-26 22:59:15 +04:00
|
|
|
if($('#advanced_year_select option:selected').val() == 'byyearday'){
|
|
|
|
//$('#advanced_byyearday').css('display', 'block');
|
2011-12-26 02:19:49 +04:00
|
|
|
}
|
2011-12-26 22:59:15 +04:00
|
|
|
if($('#advanced_year_select option:selected').val() == 'byweekno'){
|
2011-12-26 02:19:49 +04:00
|
|
|
$('#advanced_byweekno').css('display', 'block');
|
|
|
|
}
|
2011-12-26 22:59:15 +04:00
|
|
|
if($('#advanced_year_select option:selected').val() == 'bydaymonth'){
|
2011-12-26 02:19:49 +04:00
|
|
|
$('#advanced_bymonth').css('display', 'block');
|
|
|
|
$('#advanced_bymonthday').css('display', 'block');
|
|
|
|
$('#advanced_weekday').css('display', 'block');
|
|
|
|
}
|
|
|
|
}
|
2012-01-05 23:54:44 +04:00
|
|
|
|
2011-12-26 02:19:49 +04:00
|
|
|
},
|
2012-01-20 00:00:19 +04:00
|
|
|
setViewActive: function(view){
|
|
|
|
$('#view input[type="button"]').removeClass('active');
|
|
|
|
var id;
|
|
|
|
switch (view) {
|
|
|
|
case 'agendaWeek':
|
|
|
|
id = 'oneweekview_radio';
|
|
|
|
break;
|
|
|
|
case 'month':
|
|
|
|
id = 'onemonthview_radio';
|
|
|
|
break;
|
|
|
|
case 'list':
|
|
|
|
id = 'listview_radio';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$('#'+id).addClass('active');
|
2012-01-15 03:06:26 +04:00
|
|
|
},
|
2012-04-13 01:06:45 +04:00
|
|
|
categoriesChanged:function(newcategories){
|
|
|
|
categories = $.map(newcategories, function(v) {return v;});
|
|
|
|
console.log('Calendar categories changed to: ' + categories);
|
|
|
|
$('#category').multiple_autocomplete('option', 'source', categories);
|
|
|
|
},
|
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-12-28 00:48:04 +04:00
|
|
|
Calendar.UI.loading(true);
|
2012-02-20 14:27:25 +04:00
|
|
|
$('#dialog_holder').load(OC.filePath('calendar', 'ajax/calendar', 'overview.php'), function(){
|
2011-09-16 16:11:22 +04:00
|
|
|
$('#choosecalendar_dialog').dialog({
|
|
|
|
width : 600,
|
2012-05-17 23:51:27 +04:00
|
|
|
height: 400,
|
2011-09-16 16:11:22 +04:00
|
|
|
close : function(event, ui) {
|
|
|
|
$(this).dialog('destroy').remove();
|
|
|
|
}
|
|
|
|
});
|
2011-12-28 00:48:04 +04:00
|
|
|
Calendar.UI.loading(false);
|
2011-09-16 16:11:22 +04:00
|
|
|
});
|
2011-09-12 00:06:45 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
activation:function(checkbox, calendarid)
|
|
|
|
{
|
2011-12-28 00:48:04 +04:00
|
|
|
Calendar.UI.loading(true);
|
2012-02-20 14:27:25 +04:00
|
|
|
$.post(OC.filePath('calendar', 'ajax/calendar', 'activation.php'), { calendarid: calendarid, active: checkbox.checked?1:0 },
|
2011-09-12 00:06:45 +04:00
|
|
|
function(data) {
|
2011-12-28 00:48:04 +04:00
|
|
|
Calendar.UI.loading(false);
|
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'))
|
2012-02-20 14:27:25 +04:00
|
|
|
.load(OC.filePath('calendar', 'ajax/calendar', 'new.form.php'),
|
2011-10-14 16:56:18 +04:00
|
|
|
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'))
|
2012-06-09 16:40:15 +04:00
|
|
|
.load(OC.filePath('calendar', 'ajax/calendar', 'edit.form.php'), {calendarid: calendarid},
|
2011-10-03 22:32:31 +04:00
|
|
|
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{
|
2012-02-20 14:27:25 +04:00
|
|
|
$.post(OC.filePath('calendar', 'ajax/calendar', 'delete.php'), { calendarid: calid},
|
2011-10-19 21:07:56 +04:00
|
|
|
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();
|
2012-06-15 04:07:32 +04:00
|
|
|
$('#calendar_holder').fullCalendar('refetchEvents');
|
2011-10-19 21:07:56 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
submit:function(button, calendarid){
|
2012-01-21 20:42:34 +04:00
|
|
|
var displayname = $.trim($("#displayname_"+calendarid).val());
|
2011-10-19 21:07:56 +04:00
|
|
|
var active = $("#edit_active_"+calendarid+":checked").length;
|
|
|
|
var description = $("#description_"+calendarid).val();
|
|
|
|
var calendarcolor = $("#calendarcolor_"+calendarid).val();
|
2012-01-21 20:42:34 +04:00
|
|
|
if(displayname == ''){
|
|
|
|
$("#displayname_"+calendarid).css('background-color', '#FF2626');
|
|
|
|
$("#displayname_"+calendarid).focus(function(){
|
|
|
|
$("#displayname_"+calendarid).css('background-color', '#F8F8F8');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-10-19 21:07:56 +04:00
|
|
|
var url;
|
|
|
|
if (calendarid == 'new'){
|
2012-02-20 14:27:25 +04:00
|
|
|
url = OC.filePath('calendar', 'ajax/calendar', 'new.php');
|
2011-10-19 21:07:56 +04:00
|
|
|
}else{
|
2012-02-20 14:27:25 +04:00
|
|
|
url = OC.filePath('calendar', 'ajax/calendar', 'update.php');
|
2011-10-19 21:07:56 +04:00
|
|
|
}
|
|
|
|
$.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);
|
2012-01-19 15:27:16 +04:00
|
|
|
if (calendarid == 'new'){
|
2012-02-05 00:23:31 +04:00
|
|
|
$('#choosecalendar_dialog > table:first').append('<tr><td colspan="6"><a href="#" onclick="Calendar.UI.Calendar.newCalendar(this);"><input type="button" value="' + newcalendar + '"></a></td></tr>');
|
2012-01-19 15:27:16 +04:00
|
|
|
}
|
2012-01-21 20:42:34 +04:00
|
|
|
}else{
|
|
|
|
$("#displayname_"+calendarid).css('background-color', '#FF2626');
|
|
|
|
$("#displayname_"+calendarid).focus(function(){
|
|
|
|
$("#displayname_"+calendarid).css('background-color', '#F8F8F8');
|
|
|
|
});
|
2011-10-19 21:07:56 +04:00
|
|
|
}
|
|
|
|
}, '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) {
|
2012-02-21 23:10:40 +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
|
|
|
}
|
2012-02-05 00:23:31 +04:00
|
|
|
},
|
|
|
|
Share:{
|
|
|
|
currentid: 'false',
|
|
|
|
idtype: '',
|
2012-04-18 13:39:00 +04:00
|
|
|
activation:function(object,owner,id){
|
2012-06-09 16:40:15 +04:00
|
|
|
$.post(OC.filePath('calendar', 'ajax/share', 'activation.php'),{id:id, idtype:'calendar', activation:object.checked?1:0});
|
2012-04-18 13:50:12 +04:00
|
|
|
$('#calendar_holder').fullCalendar('refetchEvents');
|
2012-04-18 13:39:00 +04:00
|
|
|
},
|
2012-02-05 00:23:31 +04:00
|
|
|
dropdown:function(userid, calid){
|
|
|
|
$('.calendar_share_dropdown').remove();
|
2012-05-26 17:23:46 +04:00
|
|
|
var element = document.getElementById(userid+'_'+calid);
|
|
|
|
$('<div class="calendar_share_dropdown"></div>').appendTo(element);
|
2012-06-09 16:40:15 +04:00
|
|
|
$.post(OC.filePath('calendar', 'ajax/share', 'dropdown.php'), {calid: calid}, function(data){
|
2012-05-26 17:23:46 +04:00
|
|
|
$('.calendar_share_dropdown').html(data);
|
|
|
|
$('.calendar_share_dropdown').show('blind');
|
2012-02-05 00:23:31 +04:00
|
|
|
$('#share_user').chosen();
|
|
|
|
$('#share_group').chosen();
|
|
|
|
});
|
|
|
|
Calendar.UI.Share.currentid = calid;
|
|
|
|
Calendar.UI.Share.idtype = 'calendar';
|
|
|
|
},
|
|
|
|
share:function(id, idtype, sharewith, sharetype){
|
2012-06-09 16:40:15 +04:00
|
|
|
$.post(OC.filePath('calendar', 'ajax/share', 'share.php'),{id:id, idtype:idtype, sharewith:sharewith, sharetype:sharetype}, function(data){
|
2012-05-07 17:48:41 +04:00
|
|
|
if(sharetype == 'public'){
|
|
|
|
$('#public_token').val(parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=calendar&t='+data.message);
|
|
|
|
$('#public_token').css('display', 'block');
|
|
|
|
}
|
2012-02-05 00:23:31 +04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
unshare:function(id, idtype, sharewith, sharetype){
|
2012-06-09 16:40:15 +04:00
|
|
|
$.post(OC.filePath('calendar', 'ajax/share', 'unshare.php'),{id:id, idtype:idtype, sharewith:sharewith, sharetype:sharetype}, function(){
|
2012-02-05 00:23:31 +04:00
|
|
|
if(sharetype == 'public'){
|
|
|
|
$('#public_token').val('');
|
|
|
|
$('#public_token').css('display', 'none');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
changepermission:function(id, idtype, sharewith, sharetype, permission){
|
2012-06-09 16:40:15 +04:00
|
|
|
$.post(OC.filePath('calendar', 'ajax/share', 'changepermission.php'),{id:id, idtype:idtype, sharewith: sharewith, sharetype:sharetype, permission: (permission?1:0)});
|
2012-02-05 00:23:31 +04:00
|
|
|
},
|
|
|
|
init:function(){
|
|
|
|
$('.calendar_share_dropdown').live('mouseleave', function(){
|
|
|
|
$('.calendar_share_dropdown').hide('blind', function(){
|
|
|
|
$('.calendar_share_dropdown').remove();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('#share_user').live('change', function(){
|
|
|
|
if($('#sharewithuser_' + $('#share_user option:selected').text()).length == 0){
|
|
|
|
Calendar.UI.Share.share(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $('#share_user option:selected').text(), 'user');
|
2012-07-04 01:44:47 +04:00
|
|
|
var newitem = '<li id="sharewithuser_' + $('#share_user option:selected').text() +'"><input type="checkbox" width="12px" style="visibility:hidden;" title="' + $('#share_user option:selected').text() + '">' + $('#share_user option:selected').text() + '<img src="' + OC.imagePath('core', 'actions/delete.svg') + '" class="svg action" style="display:none;float:right;"></li>';
|
2012-02-05 00:23:31 +04:00
|
|
|
$('#sharewithuser_list').append(newitem);
|
|
|
|
$('#sharewithuser_' + $('#share_user option:selected').text() + ' > img').click(function(){
|
2012-02-11 16:30:15 +04:00
|
|
|
$('#share_user option[value="' + $(this).parent().text() + '"]').removeAttr('disabled');
|
2012-02-05 00:23:31 +04:00
|
|
|
Calendar.UI.Share.unshare(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $(this).parent().text(), 'user' );
|
2012-02-11 16:30:15 +04:00
|
|
|
$("#share_user").trigger("liszt:updated");
|
2012-02-18 00:19:04 +04:00
|
|
|
$(this).parent().remove();
|
2012-02-05 00:23:31 +04:00
|
|
|
});
|
|
|
|
$('#share_user option:selected').attr('disabled', 'disabled');
|
|
|
|
$("#share_user").trigger("liszt:updated");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$('#share_group').live('change', function(){
|
|
|
|
if($('#sharewithgroup_' + $('#share_group option:selected').text()).length == 0){
|
|
|
|
Calendar.UI.Share.share(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $('#share_group option:selected').text(), 'group');
|
2012-07-04 01:44:47 +04:00
|
|
|
var newitem = '<li id="sharewithgroup_' + $('#share_group option:selected').text() +'"><input type="checkbox" width="12px" style="visibility:hidden;" title="' + $('#share_group option:selected').text() + '">' + $('#share_group option:selected').text() + '<img src="' + OC.imagePath('core', 'actions/delete.svg') + '" class="svg action" style="display:none;float:right;"></li>';
|
2012-02-05 00:23:31 +04:00
|
|
|
$('#sharewithgroup_list').append(newitem);
|
2012-02-11 16:30:15 +04:00
|
|
|
$('#sharewithgroup_' + $('#share_group option:selected').text() + ' > img').click(function(){
|
|
|
|
$('#share_group option[value="' + $(this).parent().text() + '"]').removeAttr('disabled');
|
2012-02-05 00:23:31 +04:00
|
|
|
Calendar.UI.Share.unshare(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $(this).parent().text(), 'group');
|
2012-02-11 16:30:15 +04:00
|
|
|
$("#share_group").trigger("liszt:updated");
|
2012-02-18 00:19:04 +04:00
|
|
|
$(this).parent().remove();
|
2012-02-05 00:23:31 +04:00
|
|
|
});
|
|
|
|
$('#share_group option:selected').attr('disabled', 'disabled');
|
|
|
|
$("#share_group").trigger("liszt:updated");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$('#sharewithuser_list > li > input:checkbox').live('change', function(){
|
|
|
|
Calendar.UI.Share.changepermission(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $(this).parent().text(), 'user', this.checked);
|
|
|
|
});
|
|
|
|
$('#sharewithgroup_list > li > input:checkbox').live('change', function(){
|
|
|
|
Calendar.UI.Share.changepermission(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $(this).parent().text(), 'group', this.checked);
|
|
|
|
});
|
|
|
|
$('#publish').live('change', function(){
|
|
|
|
if(this.checked == 1){
|
|
|
|
Calendar.UI.Share.share(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, '', 'public');
|
|
|
|
}else{
|
|
|
|
Calendar.UI.Share.unshare(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, '', 'public');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$('#sharewithuser_list').live('mouseenter', function(){
|
|
|
|
$('#sharewithuser_list > li > img').css('display', 'block');
|
|
|
|
$('#sharewithuser_list > li > input').css('visibility', 'visible');
|
|
|
|
});
|
|
|
|
$('#sharewithuser_list').live('mouseleave', function(){
|
|
|
|
$('#sharewithuser_list > li > img').css('display', 'none');
|
|
|
|
$('#sharewithuser_list > li > input').css('visibility', 'hidden');
|
|
|
|
});
|
|
|
|
$('#sharewithgroup_list').live('mouseenter', function(){
|
|
|
|
$('#sharewithgroup_list > li > img').css('display', 'block');
|
|
|
|
$('#sharewithgroup_list > li > input').css('visibility', 'visible');
|
|
|
|
});
|
|
|
|
$('#sharewithgroup_list').live('mouseleave', function(){
|
|
|
|
$('#sharewithgroup_list > li > img').css('display', 'none');
|
|
|
|
$('#sharewithgroup_list > li > input').css('visibility', 'hidden');
|
|
|
|
});
|
|
|
|
/*var permissions = (this.checked) ? 1 : 0;*/
|
|
|
|
}
|
2012-05-13 17:05:57 +04:00
|
|
|
},
|
|
|
|
Drop:{
|
|
|
|
init:function(){
|
|
|
|
if (typeof window.FileReader === 'undefined') {
|
|
|
|
console.log('The drop-import feature is not supported in your browser :(');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
droparea = document.getElementById('calendar_holder');
|
|
|
|
droparea.ondrop = function(e){
|
|
|
|
e.preventDefault();
|
|
|
|
Calendar.UI.Drop.drop(e);
|
|
|
|
}
|
|
|
|
console.log('Drop initialized successfully');
|
|
|
|
},
|
|
|
|
drop:function(e){
|
|
|
|
var files = e.dataTransfer.files;
|
|
|
|
for(var i = 0;i < files.length;i++){
|
|
|
|
var file = files[i]
|
|
|
|
reader = new FileReader();
|
|
|
|
reader.onload = function(event){
|
|
|
|
if(file.type != 'text/calendar'){
|
|
|
|
$('#notification').html('At least one file don\'t seems to be a calendar file. File skipped.');
|
|
|
|
$('#notification').slideDown();
|
|
|
|
window.setTimeout(function(){$('#notification').slideUp();}, 5000);
|
|
|
|
return false;
|
|
|
|
}else{
|
|
|
|
Calendar.UI.Drop.import(event.target.result);
|
2012-05-13 17:08:27 +04:00
|
|
|
$('#calendar_holder').fullCalendar('refetchEvents');
|
2012-05-13 17:05:57 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
reader.readAsDataURL(file);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
import:function(data){
|
|
|
|
$.post(OC.filePath('calendar', 'ajax/import', 'dropimport.php'), {'data':data},function(result) {
|
2012-05-13 17:08:27 +04:00
|
|
|
if(result.status == 'success'){
|
2012-05-13 17:05:57 +04:00
|
|
|
return true;
|
|
|
|
}else{
|
|
|
|
$('#notification').html('ownCloud wasn\'t able to import at least one file. File skipped.');
|
|
|
|
$('#notification').slideDown();
|
|
|
|
window.setTimeout(function(){$('#notification').slideUp();}, 5000);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
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);
|
2012-06-22 13:30:40 +04:00
|
|
|
addDays(t.end, -7);
|
2011-10-21 00:18:17 +04:00
|
|
|
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{
|
2012-06-22 13:30:40 +04:00
|
|
|
addDays(t.start, 7);
|
2011-10-21 00:18:17 +04:00
|
|
|
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,
|
2012-02-27 00:23:20 +04:00
|
|
|
firstDay: firstDay,
|
2011-10-18 21:58:47 +04:00
|
|
|
editable: true,
|
2011-10-18 22:42:22 +04:00
|
|
|
defaultView: defaultView,
|
|
|
|
timeFormat: {
|
2011-11-20 17:23:26 +04:00
|
|
|
agenda: agendatime,
|
|
|
|
'': defaulttime
|
2011-10-18 22:42:22 +04:00
|
|
|
},
|
2012-01-20 00:39:05 +04:00
|
|
|
columnFormat: {
|
|
|
|
month: t('calendar', 'ddd'), // Mon
|
|
|
|
week: t('calendar', 'ddd M/d'), // Mon 9/7
|
|
|
|
day: t('calendar', 'dddd M/d') // Monday 9/7
|
|
|
|
},
|
2011-10-21 00:18:17 +04:00
|
|
|
titleFormat: {
|
2012-01-20 00:39:05 +04:00
|
|
|
month: t('calendar', 'MMMM yyyy'),
|
|
|
|
// September 2009
|
|
|
|
week: t('calendar', "MMM d[ yyyy]{ '—'[ MMM] d yyyy}"),
|
|
|
|
// Sep 7 - 13 2009
|
|
|
|
day: t('calendar', 'dddd, MMM d, yyyy'),
|
|
|
|
// Tuesday, Sep 8, 2009
|
2011-10-21 00:18:17 +04:00
|
|
|
},
|
2011-11-20 17:23:26 +04:00
|
|
|
axisFormat: defaulttime,
|
2011-10-18 22:42:22 +04:00
|
|
|
monthNames: monthNames,
|
|
|
|
monthNamesShort: monthNamesShort,
|
|
|
|
dayNames: dayNames,
|
|
|
|
dayNamesShort: dayNamesShort,
|
|
|
|
allDayText: allDayText,
|
2011-10-18 21:58:47 +04:00
|
|
|
viewDisplay: function(view) {
|
2012-06-13 11:05:35 +04:00
|
|
|
$('#datecontrol_date').val($('<p>').html(view.title).text());
|
2012-02-18 00:40:57 +04:00
|
|
|
if (view.name != defaultView) {
|
2012-06-09 16:40:15 +04:00
|
|
|
$.post(OC.filePath('calendar', 'ajax', 'changeview.php'), {v:view.name});
|
2012-02-18 00:40:57 +04:00
|
|
|
defaultView = view.name;
|
|
|
|
}
|
2012-01-20 00:00:19 +04:00
|
|
|
Calendar.UI.setViewActive(view.name);
|
2012-01-19 23:26:07 +04:00
|
|
|
if (view.name == 'agendaWeek') {
|
|
|
|
$('#calendar_holder').fullCalendar('option', 'aspectRatio', 0.1);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('#calendar_holder').fullCalendar('option', 'aspectRatio', 1.35);
|
|
|
|
}
|
2011-10-18 23:04:14 +04:00
|
|
|
},
|
2012-01-21 20:42:34 +04:00
|
|
|
columnFormat: {
|
|
|
|
week: 'ddd d. MMM'
|
|
|
|
},
|
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) {
|
2012-07-03 15:55:48 +04:00
|
|
|
element.find('.fc-event-title').html(element.find('.fc-event-title').text());
|
2011-10-21 23:47:42 +04:00
|
|
|
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-12-28 00:48:04 +04:00
|
|
|
loading: Calendar.UI.loading,
|
2011-10-18 23:15:11 +04:00
|
|
|
eventSources: eventSources
|
2011-10-18 21:58:47 +04:00
|
|
|
});
|
2012-06-13 11:05:35 +04:00
|
|
|
$('#datecontrol_date').datepicker({
|
|
|
|
changeMonth: true,
|
|
|
|
changeYear: true,
|
|
|
|
showButtonPanel: true,
|
|
|
|
beforeShow: function(input, inst) {
|
|
|
|
var calendar_holder = $('#calendar_holder');
|
|
|
|
var date = calendar_holder.fullCalendar('getDate');
|
|
|
|
inst.input.datepicker('setDate', date);
|
|
|
|
inst.input.val(calendar_holder.fullCalendar('getView').title);
|
|
|
|
return inst;
|
|
|
|
},
|
|
|
|
onSelect: function(value, inst) {
|
|
|
|
var date = inst.input.datepicker('getDate');
|
|
|
|
$('#calendar_holder').fullCalendar('gotoDate', date);
|
|
|
|
}
|
|
|
|
});
|
2012-05-08 10:40:06 +04:00
|
|
|
fillWindow($('#content'));
|
2012-04-13 01:06:45 +04:00
|
|
|
OCCategories.changed = Calendar.UI.categoriesChanged;
|
|
|
|
OCCategories.app = 'calendar';
|
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');
|
|
|
|
});
|
2012-02-05 00:23:31 +04:00
|
|
|
Calendar.UI.Share.init();
|
2012-05-13 17:05:57 +04:00
|
|
|
Calendar.UI.Drop.init();
|
2011-09-07 17:13:26 +04:00
|
|
|
});
|