2013-05-08 08:23:17 +00:00
<link rel='stylesheet' type='text/css' href=' { { $baseurl } } /library/fullcalendar/fullcalendar.css' />
2015-11-18 22:56:25 +00:00
<script language="javascript" type="text/javascript" src=" { { $baseurl } } /library/moment/moment.min.js"></script>
2015-11-18 22:50:42 +00:00
<script language="javascript" type="text/javascript" src=" { { $baseurl } } /library/fullcalendar/fullcalendar.min.js"></script>
2016-09-22 07:43:11 +00:00
<script language="javascript" type="text/javascript" src=" { { $baseurl } } /library/fullcalendar/locale-all.js"></script>
2012-02-14 15:19:48 +00:00
<script>
2012-04-24 06:12:30 +00:00
function showEvent(eventid) {
$.get(
2016-02-25 02:54:52 +00:00
' { { $baseurl } } { { $module_url } } /?id='+eventid,
2012-04-24 06:12:30 +00:00
function(data) {
2015-02-10 02:58:43 +00:00
$.colorbox( { scrolling : false , html : data , onComplete : function ( ) { $ . colorbox . resize ( ) ; } } );
2012-04-24 06:12:30 +00:00
}
);
}
2015-02-09 23:57:22 +00:00
function doEventPreview() {
$('#event-edit-preview').val(1);
$.post('events',$('#event-edit-form').serialize(), function(data) {
$.colorbox( { html : data } );
});
2015-02-10 02:58:43 +00:00
$('#event-edit-preview').val(0);
2015-02-09 23:57:22 +00:00
}
2015-11-18 22:50:42 +00:00
function exportDate() {
var moment = $('#events-calendar').fullCalendar('getDate');
var sT = 'events/' + moment.year() + '/' + (moment.month() + 1) + '/export';
window.location.href=sT;
}
function changeView(action, viewName) {
$('#events-calendar').fullCalendar(action, viewName);
var view = $('#events-calendar').fullCalendar('getView');
2016-07-01 10:21:19 +00:00
if(view.type !== 'month' && !$('main').hasClass('fullscreen')) {
2016-06-17 09:57:36 +00:00
$('#events-calendar').fullCalendar('option', 'height', 'auto');
}
else {
2016-07-01 10:21:19 +00:00
$('#events-calendar').fullCalendar('option', 'height', '');
}
2016-06-28 11:44:32 +00:00
2016-07-01 10:21:19 +00:00
if($('main').hasClass('fullscreen')) {
$('#events-calendar').fullCalendar('option', 'height', $(window).height() - $('.section-title-wrapper').outerHeight(true) - 2); // -2 is for border width (.generic-content-wrapper top and bottom) of .generic-content-wrapper
2016-06-17 09:57:36 +00:00
}
2016-07-01 10:21:19 +00:00
2015-11-18 22:50:42 +00:00
$('#title').text(view.title);
}
2015-02-09 23:57:22 +00:00
2012-02-14 15:19:48 +00:00
$(document).ready(function() {
2012-04-24 06:12:30 +00:00
$('#events-calendar').fullCalendar( {
2016-02-25 02:54:52 +00:00
events: ' { { $baseurl } } { { $module_url } } /json',
2015-11-18 22:50:42 +00:00
header: false,
2017-03-23 12:11:27 +00:00
eventTextColor: 'white',
2015-11-20 15:39:55 +00:00
lang: ' { { $lang } } ',
2015-11-21 14:33:57 +00:00
firstDay: { { $first_day } } ,
2015-11-18 22:50:42 +00:00
eventLimit: 3,
2015-06-26 01:23:48 +00:00
monthNames: aStr['monthNames'],
monthNamesShort: aStr['monthNamesShort'],
dayNames: aStr['dayNames'],
dayNamesShort: aStr['dayNamesShort'],
2015-11-18 22:50:42 +00:00
2015-06-26 01:23:48 +00:00
allDayText: aStr['allday'],
2015-11-18 22:50:42 +00:00
timeFormat: 'HH:mm',
2012-02-14 15:19:48 +00:00
eventClick: function(calEvent, jsEvent, view) {
2012-04-24 06:12:30 +00:00
showEvent(calEvent.id);
2012-02-14 15:19:48 +00:00
},
2015-01-01 17:19:17 +00:00
loading: function(isLoading, view) {
2017-09-26 11:02:11 +00:00
$('#events-spinner').show();
$('#today-btn > i').hide();
2015-01-01 17:19:17 +00:00
if(!isLoading) {
2017-09-26 11:02:11 +00:00
$('#events-spinner').hide();
$('#today-btn > i').show();
2015-11-24 13:33:23 +00:00
$('td.fc-day').dblclick(function() {
openMenu('form');
//window.location.href='/events/new?start='+$(this).data('date');
});
2015-01-01 17:19:17 +00:00
}
},
2014-11-25 04:40:00 +00:00
2012-02-14 15:19:48 +00:00
eventRender: function(event, element, view) {
2015-11-26 15:38:14 +00:00
2012-02-14 15:28:10 +00:00
//console.log(view.name);
2013-03-19 04:29:59 +00:00
if (event.item['author']['xchan_name']==null) return;
2014-11-25 04:40:00 +00:00
2012-02-14 15:19:48 +00:00
switch(view.name) {
case "month":
2015-11-26 15:38:14 +00:00
element.find(".fc-title").html(
2015-11-26 22:19:06 +00:00
"<img src=' { 0 } ' style='height:12px;width:12px;' title=' { 1 } '> <span title=' { 3 } { 4 } '> { 2 } </span>".format(
2013-03-19 04:29:59 +00:00
event.item['author']['xchan_photo_s'],
event.item['author']['xchan_name'],
2015-11-26 19:53:42 +00:00
event.title,
2015-11-26 22:19:06 +00:00
event.item.description ? event.item.description + "\r\n\r\n" : '',
event.item.location ? aStr['location'] + ': ' + event.item.location.replace(/(<([^>]+)>)/ig,"") : ''
2012-02-14 15:19:48 +00:00
));
break;
case "agendaWeek":
2015-11-26 15:38:14 +00:00
element.find(".fc-title").html(
2015-11-26 22:19:06 +00:00
"<img src=' { 0 } ' style='height:12px;width:12px;'> { 1 } : <span title=' { 3 } { 4 } '> { 2 } </span>".format(
2013-03-19 04:29:59 +00:00
event.item['author']['xchan_photo_s'],
event.item['author']['xchan_name'],
2015-11-26 15:38:14 +00:00
event.title,
2015-11-26 22:19:06 +00:00
event.item.description ? event.item.description + "\r\n\r\n" : '',
event.item.location ? aStr['location'] + ': ' + event.item.location.replace(/(<([^>]+)>)/ig,"") : ''
2012-02-14 15:19:48 +00:00
));
break;
case "agendaDay":
2015-11-26 15:38:14 +00:00
element.find(".fc-title").html(
2015-11-26 22:19:06 +00:00
"<img src=' { 0 } ' style='height:12px;width:12px;'> { 1 } : <span title=' { 3 } { 4 } '> { 2 } </span>".format(
2013-03-19 04:29:59 +00:00
event.item['author']['xchan_photo_s'],
event.item['author']['xchan_name'],
2015-11-26 15:38:14 +00:00
event.title,
2015-11-26 22:19:06 +00:00
event.item.description ? event.item.description + "\r\n\r\n" : '',
event.item.location ? aStr['location'] + ': ' + event.item.location.replace(/(<([^>]+)>)/ig,"") : ''
2012-02-14 15:19:48 +00:00
));
break;
}
}
2015-11-25 14:05:21 +00:00
});
2012-04-24 06:12:30 +00:00
// center on date
2016-02-25 02:54:52 +00:00
// @fixme does not work for cal/$nick module_url
2012-04-24 06:12:30 +00:00
var args=location.href.replace(baseurl,"").split("/");
2016-02-25 02:54:52 +00:00
{ { if $modparams = = 2 } }
if (args.length>=5) {
$("#events-calendar").fullCalendar('gotoDate',args[3] , args[4]-1);
}
{ { else } }
2012-04-24 06:12:30 +00:00
if (args.length>=4) {
$("#events-calendar").fullCalendar('gotoDate',args[2] , args[3]-1);
2016-02-25 02:54:52 +00:00
}
{ { / if } }
2012-04-24 06:12:30 +00:00
// show event popup
var hash = location.hash.split("-")
if (hash.length==2 && hash[0]=="#link") showEvent(hash[1]);
2015-11-18 22:50:42 +00:00
// echo the title
var view = $('#events-calendar').fullCalendar('getView');
$('#title').text(view.title);
2015-11-25 14:05:21 +00:00
// shift the finish time date on start time date change automagically
var origsval = $('#id_start_text').val();
$('#id_start_text').change(function() {
var origfval = $('#id_finish_text').val();
2015-11-25 18:02:48 +00:00
if(origfval) {
var sval = $('#id_start_text').val();
var diff = moment(sval).diff(origsval);
var fval = moment(origfval).add(diff, 'millisecond').format("YYYY-MM-DD HH:mm");
$('#id_finish_text').val(fval);
origsval = sval;
}
2015-11-25 14:05:21 +00:00
});
2012-04-24 06:12:30 +00:00
});
2011-06-10 04:23:45 +00:00
</script>