</div>
-
- <script type="text/javascript">
- jQuery(document).ready(function($) {
-
- var fullCalendarLoaded = false;
- var recurrencesInited = false;
- var locationsInited = false;
- var table = 'glm-table-calendar';
- var post_start, post_end, month_obj;
- var rows = $(".glm-event-day-row");
- var agenda = $("#glm-event-agenda-view");
- var view_select = $("#glm-event-view-select");
- var search = $("#glm-events-search-form");
- var calendar = $("#eventCalendar");
- var event_search = $(".glm-search-icon");
- var main_content = $("#main-content");
- var member_id = '{$memberId}';
- var view = '{$cal_view}';
- var months = '{$json_months}';
- var category = $('#glm-event-category').val();
- var current_month = $('{$current_month}');
- var current_year = $('{$current_year}');
- var custom_page = '{$customPage}';
- var page_slug = '{$pageSlug}';
- var retain_date;
-
- if(!member_id){
- member_id = null;
- }
-
- // add 7 days to ensure we always get the current month and not any other month view that may
- // be visible (last few days of previous month or first few days of next month)
- function get_current_view(){
- var retain_date;
- var calCurrDate = $('#eventCalendar').fullCalendar('getView').start;
- var d = moment(calCurrDate).add(7, 'days').format('YYYY-MM-01');
-
- return retain_date = d;
- }
- function in_mobile(){
- if($(window).width() < 641 ){
- return true;
- } else {
- return false;
- }
- }
-
- $('#glm-event-from').on("change", function(){
- var from_date = $(this).val();
- $('#glm-event-to').val(from_date);
-
- });
-
- months = JSON.parse(months);
-
- event_search.on('click', function(){
- sessionStorage.override = 'yes';
- });
-
- if( sessionStorage.view && sessionStorage.override === 'no' && !in_mobile()){
- view = sessionStorage.view;
- } else if( sessionStorage.override === 'yes' || in_mobile()){
- view = 'agenda';
- }
-
- // AJAX FUNCTION ************************************************
- // Get calendar month via AJAX
- function eventsCalMonthAJAX(month) {
- var dat = {
-
- action: 'glm_members_admin_ajax',
- glm_action: 'eventsCalMonthAJAX',
- month: month,
- category: category,
- member_id: member_id,
- custom_page: custom_page,
- page_slug: page_slug
- };
- $('.fc-event').remove();
-
- jQuery.ajax({
- type: 'POST',
- url: '{$ajaxUrl}',
- data: dat,
- beforeSend: function(){
- $(".event-overlay").show();
- $(".loading").show();
- },
- complete: function(){
- $(".event-overlay").hide();
- $(".loading").hide();
- },
- cache: false,
- success: function (response){
- var buildingEvents = [];
- //var events_obj = jQuery.parseJSON(response);
- var events_obj = response;
- var events = events_obj.events;
- buildingEvents = $.map(events, function(i, val) {
- return {
- title: i.title,
- start: i.start,
- end: i.last,
- allDay: i.all_day,
- url: i.url,
- recurs: i.recurs
- };
- });
- $("#eventCalendar").fullCalendar('removeEvents');
- $("#eventCalendar").fullCalendar('addEventSource', buildingEvents);
- }
- });
- var timestamp = $.now();
- var url = '{$ajaxUrl}' + '?t=' + timestamp;
- }
- var height = 900;
- // Calendar *****************************************************
- $('#eventCalendar').fullCalendar({
- eventOrder: 'allDay',
- height: height,
- contentHeight: height,
- eventRender: function(event, element){
- element.attr('title', event.title);
- },
- viewRender: function (view, element){
- post_start = view.start._d;
- post_end = view.end._d;
- {literal}month_obj = {start: view.start._d, last: view.end._d};{/literal}
- },
- header: {
- left: 'prev,next,today',
- center: 'title',
- right: ''
- },
- dayClick: function(date, jsEvent, view) {
- //$('#eventCalendar').fullCalendar('changeView', 'agendaDay');
- //$('#eventCalendar').fullCalendar('gotoDate', date);
- },
- editable: false,
- handleWindowResize: true,
- lazyFetching: true,
- eventClick : function (event){
-
- sessionStorage.current_calendar_view = get_current_view();
-
-
- if(custom_page !== ''){
- location.href = event.url + '&glm_event_from=' + event.start.format();
- } else {
- location.href = event.url + '?glm_event_from=' + event.start.format();
- }
-
- return false;
- },
- eventLimit: true,
- views: {
- month: {
- eventLimit: 4,
- eventBackgroundColor: 'transparent',
- eventTextColor: '#3A87AD',
- eventBorderColor: 'transparent',
- },
- agenda: {
- eventLimit: 4
- }
- }
- });
-
- if(view === "calendar"){
- eventsCalMonthAJAX(month_obj);
- main_content.removeClass("small-8").addClass("small-12");
- calendar.show();
- view_select.val('calendar');
-
- } else if ( view === "agenda"){
- calendar.hide();
- agenda.css("display", "block");
- view_select.val('agenda');
- }
- $("#glm-event-view-select").on("change", function (){
- sessionStorage.override = 'no';
- sessionStorage.setItem("view", $(this).attr("value"));
- if($("#glm-event-view-select option:selected").val() === "calendar"){
- eventsCalMonthAJAX(month_obj);
- agenda.css("display","none");
- calendar.fadeIn('slow', function(){});
- calendar.fullCalendar('render');
-
- } else if ( $("#glm-event-view-select option:selected").val() === "agenda"){
- agenda.css("display", "block");
- calendar.fadeOut('slow', function(){});
- }
- });
- $(window).on("load", function(){
-
- if(sessionStorage.current_calendar_view){
- $('#event-date-toggle option').each(function(){
- if( $(this).val() === sessionStorage.current_calendar_view){
- $(this).prop('selected', true);
- }
- });
- }
-
- $('#event-date-toggle-container').insertAfter( $('.fc-left')).fadeTo('slow', 1);
-
- $('#event-date-toggle').on("change", function(){
- var selected_date = $(this).val();
-
- $('#eventCalendar').fullCalendar('gotoDate', selected_date);
- eventsCalMonthAJAX(month_obj);
- if(sessionStorage.current_calendar_view){
- sessionStorage.current_calendar_view = '';
- }
- });
- });
- if(sessionStorage.current_calendar_view){
- $('#eventCalendar').fullCalendar('gotoDate', sessionStorage.current_calendar_view);
- eventsCalMonthAJAX(month_obj);
- }
- // initialize calendar with AJAX calls *************************************
- $(document).on("click", "button.fc-button", function () {
- if(sessionStorage.current_calendar_view){
- sessionStorage.current_calendar_view = '';
- }
-
- eventsCalMonthAJAX(month_obj);
- });
-
- $('#eventCalendar').find('.fc-today-button').on("click", function(){
- eventsCalMonthAJAX(month_obj);
- var current_view = get_current_view();
- $('#event-date-toggle option').each(function(){
- if( $(this).val() === current_view){
- $(this).prop('selected', true);
- }
- });
- });
-
- var dates = $(".agenda-event-recur-dates");
- dates.each( function (){
- if( $(this).text().indexOf('-') < 0 ){
- $(this).remove();
- }
- });
-
- // Event agenda view container click, go to event url
- $('.glm-event-day-event').on("click", function(){
- window.location = $(this).data('url');
- });
-
-
- });
- </script>
-
+{include file='front/events/agendaScript.html'}