Calendar
Date Set: ' + moment(event.setdate, "YYYY-MM-DD").format("DD/MM/YYYY") + '
');
}
} else if (element.parents('.fc-month-view').length > 0) {
if (event.homework_type === "set") {
element.find('.fc-title').prepend(' ')
} else if (event.homework_type === "due") {
element.find('.fc-title').prepend(' ')
}
}
}
}
var calRender = function( view ) {
calTransitions( false );
// Set the mini calendar to the same date as the full calendar.
if ( $calMini !== false ) { $calMini.fullCalendar( 'gotoDate', view.calendar.getDate() ); }
// Hide the list while the events are loading and being filters.
if ( view.name == 'listMonth' || view.name == 'listWeek' ) {
view.el.hide();
view.el.parent('.fc-view-container').removeClass('ui_card ui_card--void');
$('.content__calendar').addClass('content__calendar--list');
} else {
view.el.parent('.fc-view-container').addClass('ui_card ui_card--void');
$('.content__calendar').removeClass('content__calendar--list');
}
}
var intCalSwitchScrollCount = 0;
var objCalSwitchInterval;
var calSwitch = function( cell ) {
$calFull.fullCalendar( 'changeView', 'listMonth' );
if ( $calMini !== false ) $calMini.fullCalendar( 'gotoDate', cell.date );
objCalSwitchInterval = setInterval(function(){calSwitchScroll( cell.date )},250);
}
var calSwitchScroll = function(cellDate) {
if (intCalSwitchScrollCount <= 20) {
if ($('.fc-listMonth-view').length > 0) {
clearInterval(objCalSwitchInterval);
calScroll(cellDate);
}
} else {
clearInterval(objCalSwitchInterval);
}
intCalSwitchScrollCount++;
}
var calTransitions = function( bool ) {
if (!bool) { $('.fc-view-container').addClass('fc-view-updating'); }
else { $('.fc-view-container').removeClass('fc-view-updating'); }
}
var calICSLink = function(strSiteDomain) {
strLink = ''+strSiteDomain+'/calendar/ics.asp?calid=';
var blnFirst = true;
$('.content__calendar__filters input').each(function() {
if ( $(this).prop('checked') ) {
if (!blnFirst) {
strLink = strLink + ',';
}
strLink = strLink + $(this).attr('name');
blnFirst = false
}
});
return strLink;
}
var calScroll = function( date ) {
// TODO : Introduce Mason settings to define scroll offsets.
var $dateAnchor = $('a[name="' + date.format() + '"]');
if ( $dateAnchor.length > 0 ) {
var intScroll = $dateAnchor.offset().top;
var intSpeed = intScroll - $(document).scrollTop();
if (intSpeed < 0) intSpeed = -(intSpeed);
$viewport.animate({ 'scrollTop': intScroll + 'px' }, { duration: intSpeed });
}
}
var calFilter = function( view ) {
//This function is now redundant a skeleton remains to preserve backwards compatibility
$calFull.fullCalendar('refetchEvents');
}
$('.content__calendar__filters input').on('change', function() {
calTransitions( true );
$calFull.fullCalendar('refetchEvents');
strCalICSLink = calICSLink('www.princewilliamschool.co.uk');
});
$(document).ready(function() {
calBuild();
//Code to update the print button url
if ($('.content__calendar__print').length > 0 && $('li','.content__calendar__filters').length > 0) {
$('.content__calendar__print').click(function(event){
event.preventDefault();
strCal = '';
$('li','.content__calendar__filters').each(function(){
if ($('input',$(this)).is(':checked')) {
if (strCal !== '') strCal += ',';
strCal += $('input',$(this)).attr('name');
}
});
strURL = '/calendar/print.asp?month='+$calFull.fullCalendar('getDate').format("M")+'&year='+$calFull.fullCalendar('getDate').format("YYYY")+'&calid=';
strURL += strCal;
strURL += '&pid=';
strURL += $(this).data('page');
strURL += '&viewid=';
strURL += $(this).data('view');
window.location.assign(strURL);
});
}
});