streams/view/tpl/event_head.tpl

161 lines
5.2 KiB
Smarty
Raw Normal View History

<link rel='stylesheet' type='text/css' href='{{$baseurl}}/library/fullcalendar/fullcalendar.css' />
<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>
<script>
function showEvent(eventid) {
$.get(
2016-02-25 02:54:52 +00:00
'{{$baseurl}}{{$module_url}}/?id='+eventid,
function(data){
$.colorbox({ scrolling: false, html: data, onComplete: function() { $.colorbox.resize(); }});
}
);
}
function doEventPreview() {
$('#event-edit-preview').val(1);
$.post('events',$('#event-edit-form').serialize(), function(data) {
$.colorbox({ html: data });
});
$('#event-edit-preview').val(0);
}
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');
if(view.type !== 'month' && !$('main').hasClass('fullscreen')) {
$('#events-calendar').fullCalendar('option', 'height', 'auto');
}
else {
$('#events-calendar').fullCalendar('option', 'height', '');
}
2016-06-28 11:44:32 +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
}
2015-11-18 22:50:42 +00:00
$('#title').text(view.title);
}
$(document).ready(function() {
$('#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}}',
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',
eventClick: function(calEvent, jsEvent, view) {
showEvent(calEvent.id);
},
loading: function(isLoading, view) {
$('#events-spinner').show();
$('#today-btn > i').hide();
if(!isLoading) {
$('#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');
});
}
},
eventRender: function(event, element, view) {
2015-11-26 15:38:14 +00:00
//console.log(view.name);
2013-03-19 04:29:59 +00:00
if (event.item['author']['xchan_name']==null) return;
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}'>&nbsp;<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,"") : ''
));
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;'>&nbsp;{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,"") : ''
));
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;'>&nbsp;{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,"") : ''
));
break;
}
}
});
// center on date
2016-02-25 02:54:52 +00:00
// @fixme does not work for cal/$nick module_url
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}}
if (args.length>=4) {
$("#events-calendar").fullCalendar('gotoDate',args[2] , args[3]-1);
2016-02-25 02:54:52 +00:00
}
{{/if}}
// 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);
// 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();
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;
}
});
});
2011-06-10 04:23:45 +00:00
</script>