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.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 calSwitch = function( cell ) {
$calFull.fullCalendar( 'changeView', 'listMonth' );
if ( $calMini !== false ) $calMini.fullCalendar( 'gotoDate', cell.date );
calScroll( cell.date );
}
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 = 'http://'+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 ) {
if ( view.name == 'listMonth' ) { $('.fc-row.fc-day',view.el).addClass('fc-day-empty ui_card'); }
else { $('.fc-row.fc-day',view.el).addClass('fc-day-empty'); }
$('.fc-event',view.el).addClass('fc-event-hide');
$('.fc-cal-icon',view.el).addClass('fc-cal-icon-hide');
$('.content__calendar__filters input').each(function() {
if ( $(this).prop('checked') ) {
var $event = $('.fc-event-cal-' + $(this).attr('name'),view.el);
var $icon = $('.fc-cal-icon-' + $(this).attr('name'),view.el);
var $day = $event.closest('.fc-row.fc-day');
$day.removeClass('fc-day-empty');
$event.removeClass('fc-event-hide');
$icon.removeClass('fc-cal-icon-hide');
}
});
// Now we have filtered the list of events, we can fade them in.
if ( view.name == 'listMonth' ) { view.el.fadeIn(); }
}
$('.content__calendar__filters input').on('change', function() {
calTransitions( true );
calFilter( false );
strCalICSLink = calICSLink('www.princewilliamschool.co.uk');
});
$(document).ready(function() {
calBuild();
});