/** * @license e-Calendar v0.9.3 * (c) 2014-2016 - Jhonis de Souza * License: GNU */ (function ($) { var eCalendar = function (options, object) { // Initializing global variables var adDay = new Date().getDate(); var adMonth = new Date().getMonth(); var adYear = new Date().getFullYear(); var dDay = adDay; var dMonth = adMonth; var dYear = adYear; var instance = object; var settings = $.extend({}, $.fn.eCalendar.defaults, options); function lpad(value, length, pad) { if (typeof pad == 'undefined') { pad = '0'; } var p; for (var i = 0; i < length; i++) { p += pad; } return (p + value).slice(-length); } var mouseOver = function () { $(this).addClass('c-nav-btn-over'); }; var mouseLeave = function () { $(this).removeClass('c-nav-btn-over'); }; var mouseOverEvent = function () { $(this).addClass('c-event-over'); var d = $(this).attr('data-event-day'); $('div.c-event-item[data-event-day="' + d + '"]').addClass('c-event-over'); }; var mouseLeaveEvent = function () { $(this).removeClass('c-event-over') var d = $(this).attr('data-event-day'); $('div.c-event-item[data-event-day="' + d + '"]').removeClass('c-event-over'); }; var mouseOverItem = function () { $(this).addClass('c-event-over'); var d = $(this).attr('data-event-day'); $('div.c-event[data-event-day="' + d + '"]').addClass('c-event-over'); }; var mouseLeaveItem = function () { $(this).removeClass('c-event-over') var d = $(this).attr('data-event-day'); $('div.c-event[data-event-day="' + d + '"]').removeClass('c-event-over'); }; var nextMonth = function () { if (dMonth < 11) { dMonth++; } else { dMonth = 0; dYear++; } print(); }; var previousMonth = function () { if (dMonth > 0) { dMonth--; } else { dMonth = 11; dYear--; } print(); }; function loadEvents() { if (typeof settings.url != 'undefined' && settings.url != '') { $.ajax({url: settings.url, async: false, success: function (result) { settings.events = result; } }); } } function print() { loadEvents(); var dWeekDayOfMonthStart = new Date(dYear, dMonth, 1).getDay() - settings.firstDayOfWeek; if (dWeekDayOfMonthStart < 0) { dWeekDayOfMonthStart = 6 - ((dWeekDayOfMonthStart + 1) * -1); } var dLastDayOfMonth = new Date(dYear, dMonth + 1, 0).getDate(); var dLastDayOfPreviousMonth = new Date(dYear, dMonth + 1, 0).getDate() - dWeekDayOfMonthStart + 1; var cBody = $('
').addClass('c-grid'); var cEvents = $('
').addClass('c-event-grid'); var cEventsBody = $('
').addClass('c-event-body'); cEvents.append($('
').addClass('c-event-title c-pad-top').html(settings.eventTitle)); cEvents.append(cEventsBody); var cNext = $('
').addClass('c-next c-grid-title c-pad-top'); var cMonth = $('
').addClass('c-month c-grid-title c-pad-top'); var cPrevious = $('
').addClass('c-previous c-grid-title c-pad-top'); cPrevious.html(settings.textArrows.previous); cMonth.html(settings.months[dMonth] + ' ' + dYear); cNext.html(settings.textArrows.next); cPrevious.on('mouseover', mouseOver).on('mouseleave', mouseLeave).on('click', previousMonth); cNext.on('mouseover', mouseOver).on('mouseleave', mouseLeave).on('click', nextMonth); cBody.append(cPrevious); cBody.append(cMonth); cBody.append(cNext); var dayOfWeek = settings.firstDayOfWeek; for (var i = 0; i < 7; i++) { if (dayOfWeek > 6) { dayOfWeek = 0; } var cWeekDay = $('
').addClass('c-week-day c-pad-top'); cWeekDay.html(settings.weekDays[dayOfWeek]); cBody.append(cWeekDay); dayOfWeek++; } var day = 1; var dayOfNextMonth = 1; for (var i = 0; i < 42; i++) { var cDay = $('
'); if (i < dWeekDayOfMonthStart) { cDay.addClass('c-day-previous-month c-pad-top'); cDay.html(dLastDayOfPreviousMonth++); } else if (day <= dLastDayOfMonth) { cDay.addClass('c-day c-pad-top'); if (day == dDay && adMonth == dMonth && adYear == dYear) { cDay.addClass('c-today'); } for (var j = 0; j < settings.events.length; j++) { var d = settings.events[j].datetime; if (d.getDate() == day && d.getMonth() == dMonth && d.getFullYear() == dYear) { cDay.addClass('c-event').attr('data-event-day', d.getDate()); cDay.on('mouseover', mouseOverEvent).on('mouseleave', mouseLeaveEvent); } } cDay.html(day++); } else { cDay.addClass('c-day-next-month c-pad-top'); cDay.html(dayOfNextMonth++); } cBody.append(cDay); } var eventList = $('
').addClass('c-event-list'); for (var i = 0; i < settings.events.length; i++) { var d = settings.events[i].datetime; if (d.getMonth() == dMonth && d.getFullYear() == dYear) { var date = lpad(d.getDate(), 2) + '/' + lpad(d.getMonth() + 1, 2) + '/' + lpad(d.getFullYear(), 4); var item = $('
').addClass('c-event-item'); var title = $('
').addClass('title').html(date + ' ' + settings.events[i].title + '
'); var description = $('
').addClass('description').html(settings.events[i].description + '
'); item.attr('data-event-day', d.getDate()); item.on('mouseover', mouseOverItem).on('mouseleave', mouseLeaveItem); item.append(title).append(description); // Add the url to the description if is set if( settings.events[i].url !== undefined ) { /** * If the setting url_blank is set and is true, the target of the url * will be "_blank" */ type_url = settings.events[i].url_blank !== undefined && settings.events[i].url_blank === true ? '_blank':''; description.wrap( '' ); } eventList.append(item); } } $(instance).addClass('calendar'); cEventsBody.append(eventList); $(instance).html(cBody).append(cEvents); } return print(); } $.fn.eCalendar = function (oInit) { return this.each(function () { return eCalendar(oInit, $(this)); }); }; // plugin defaults $.fn.eCalendar.defaults = { weekDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], textArrows: {previous: '', next: ''}, eventTitle: 'Upcoming Events', url: '', events: [ {title: 'Term One Commences in Clontarf & Sutton', description: 'Term One Commences in our Clontarf & Sutton Schools on Saturday 2nd September 2017.', datetime: new Date(2017, 8, 2)}, {title: 'Term One Commences in Baldoyle', description: 'Term One Commences in our Baldoyle School on Monday 4th September 2017.', datetime: new Date(2017, 8, 4)}, {title: 'Term One Commences in Lucan & Naul', description: 'Term One Commences in our Lucan & Naul Schools on Tuesday 5th September 2017.', datetime: new Date(2017, 8, 5)}, {title: 'Term One Commences in Sandymount & Leixlip', description: 'Term One Commences in our Sandymount & Leixlip Schools on Wednesday 6th September 2017.', datetime: new Date(2017, 8, 6)}, {title: 'Term One Commences in Lucan', description: 'Term One Commences in our Lucan School on Thursday 7th September 2017.', datetime: new Date(2017, 8, 7)}, {title: 'Term One Commences in Balbriggan', description: 'Term One Commences in our Balbriggan School on Friday 8th September 2017.', datetime: new Date(2017, 8, 8)}, {title: 'Closed for Halloween Mid-Term Break', description: 'The school will be closed from Monday 30th October to Sunday 5th November inclusive.', datetime: new Date(2017, 9, 30)}, {title: 'Term Two Commences in Clontarf & Sutton', description: 'Term Two Commences in our Clontarf & Sutton Schools on Saturday 18th November 2017.', datetime: new Date(2017, 10, 18)}, {title: 'Term Two Commences in Sandymount & Leixlip', description: 'Term Two Commences in our Sandymount & Leixlip Schools on Wednesday 22nd November 2017.', datetime: new Date(2017, 10, 22)}, {title: 'Term Two Commences in Lucan', description: 'Term Two Commences in our Lucan School on Thursday 23rd November 2017.', datetime: new Date(2017, 10, 23)}, {title: 'Term Two Commences in Balbriggan', description: 'Term Two Commences in our Balbriggan School on Friday 24th November 2017.', datetime: new Date(2017, 10, 24)}, {title: 'Autumn Examination Session', description: 'Autumn Examination Session will be on Sunday 26th November 2017.', datetime: new Date(2017, 10, 26)}, {title: 'Term Two Commences in Baldoyle', description: 'Term Two Commences in our Baldoyle School on Monday 27th November 2017.', datetime: new Date(2017, 10, 27)}, {title: 'Term Two Commences in Lucan & Naul', description: 'Term Two Commences in our Lucan & Naul Schools on Tuesday 28th November 2017.', datetime: new Date(2017, 10, 28)}, {title: 'No Classes in Clontarf', description: 'No Classes Clontarf on Monday 18th and Tuesday 19th of December for Junior School Christmas Concert.', datetime: new Date(2017, 11, 18)}, {title: 'No Classes in Clontarf', description: 'No Classes Clontarf on Monday 18th and Tuesday 19th of December for Junior School Christmas Concert.', datetime: new Date(2017, 11, 19)}, {title: 'Closed for Christmas Holidays', description: 'The school will be closed from Wednesday 20th December to Friday 5th January inclusive.', datetime: new Date(2017, 11, 20)}, {title: 'Classes Recommence', description: 'End of Christmas holidays, classes recommence as usual on Saturday 6th January 2018.', datetime: new Date(2018, 0, 6)}, {title: 'Term Three Commences in Clontarf & Sutton', description: 'Term Three Commences in our Clontarf & Sutton Schools on Saturday 10th February 2018.', datetime: new Date(2018, 1, 10)}, {title: 'Closed for February Mid-Term Break', description: 'The school will be closed from Wednesday 14th February to Sunday 18th February inclusive.', datetime: new Date(2018, 1, 14)}, {title: 'Term Three Commences in Baldoyle', description: 'Term Three Commences in our Baldoyle School on Monday 19th February 2018.', datetime: new Date(2018, 1, 19)}, {title: 'Term Three Commences in Lucan & Naul', description: 'Term Three Commences in our Lucan & Naul Schools on Tuesday 20th February 2018.', datetime: new Date(2018, 1, 20)}, {title: 'Term Three Commences in Sandymount & Leixlip', description: 'Term Three Commences in our Sandymount & Leixlip Schools on Wednesday 28th February 2018.', datetime: new Date(2018, 1, 28)}, {title: 'Term Three Commences in Lucan', description: 'Term Three Commences in our Lucan School on Thursday 1st March 2018.', datetime: new Date(2018, 2, 1)}, {title: 'Term Three Commences in Balbriggan', description: 'Term Three Commences in our Balbriggan School on Friday 2nd March 2018.', datetime: new Date(2018, 2, 2)}, {title: 'Spring Examination Session', description: 'Provisional date Sunday 11th March 2018.', datetime: new Date(2018, 2, 11)}, {title: 'Closed for St. Patrick\'s Weekend', description: 'The school will be closed from Saturday 17th March to Monday 19th March inclusive.', datetime: new Date(2018, 2, 17)}, {title: 'Closed for Easter Holidays', description: 'The school will be closed from Monday 26th March to Sunday 8th April inclusive.', datetime: new Date(2018, 2, 26)}, {title: 'Classes Recommence', description: 'Classes recommence on Monday 9th April following Easter holidays.', datetime: new Date(2018, 3, 9)}, {title: 'No Classes in Clontarf', description: 'There will be no classes in Clontarf on Saturday 28th April for First Holy Communions.', datetime: new Date(2018, 3, 28)}, {title: 'Closed for Bank Holiday', description: 'The school will be closed on Monday 7th May 2018.', datetime: new Date(2018, 4, 7)}, {title: 'Last Class of The Year in Naul', description: 'The school will close after the last class of the year for our Naul School on Tuesday 8th May 2018.', datetime: new Date(2018, 4, 8)}, {title: 'Last Class of The Year in Sutton', description: 'The school will close after the last class of the year for our Sutton School on Saturday 12th May 2018.', datetime: new Date(2018, 4, 12)}, {title: 'Last Class of The Year in Sandymount & Leixlip', description: 'The school will close after the last class of the year for our Sandymount & Leixlip Schools on Wednesday 16th May 2018.', datetime: new Date(2018, 4, 16)}, {title: 'Last Class of The Year in Lucan', description: 'The school will close after the last class of the year for our Lucan School on Thursday 17th May 2018.', datetime: new Date(2018, 4, 17)}, {title: 'Last Class of The Year in Balbriggan', description: 'The school will close after the last class of the year for our Naul School on Friday 18th May 2018.', datetime: new Date(2018, 4, 18)}, {title: 'Last Class of The Year in Clontarf', description: 'The school will close after the last class of the year for our Clontarf School on Saturday 19th May 2018.', datetime: new Date(2018, 4, 19)}, {title: 'Last Class of The Year in Baldoyle', description: 'The school will close after the last class of the year for our Baldoyle School on Monday 21st May 2018.', datetime: new Date(2018, 4, 21)}, {title: 'Summer Examination Session', description: 'Provisional date Saturday 26th May 2018.', datetime: new Date(2018, 4, 26)}, {title: 'Summer Examination Session', description: 'Provisional date Sunday 27th May 2018.', datetime: new Date(2018, 4, 27)}, ], firstDayOfWeek: 0 }; }(jQuery));