PageSourceSearch

https://www.hppc.co.uk/wp-content/themes/hurst/assets/src/js/ricalendar.js?ver=1791079202

js hppc.co.uk collected 2026-10-04 03:07:15 UTC 7,016 bytes, 160 lines download raw bytes

1var $post_type = '',$taxonomy = '';
2
3//The function that updates the calendar and adjacent view area via AJAX
4function updateCalendar($theDate,$post_type,$term_id,$taxonomy){
5    $('.ricalendar').append('<span class="loader"></span>');
6    var $view_type = $('.list_view_filter li.current').attr('data-view') ? $('.list_view_filter li.current').attr('data-view') : 'day';
7    $.ajax({
8        type: 'POST',
9        url: $('.ricalendar').attr('data-calendar')+'/ricalendar/ricalendar-ajax-data.php',
10        data: {
11            date: $theDate,
12            post_type: $post_type,
13            term_id: $term_id,
14            view_type: $view_type,
15            taxonomy: $taxonomy 
16        },
17        success: function (data) {
18            $('.ricalendar .loader').fadeOut(function(){
19                $('.ricalendar').html(data);
20                setTimeout(function(){
21                    $('.ricalendar').find('td.has_item').first().trigger('click');      
22                },500);
23            });
24        }
25    });
26}
27
28//Initiate the calendar loading the current month
29$(document).ready(function(){
30	if($('.ricalendar').length){
31        var d = new Date();
32        var year = d.getFullYear();
33        var month = d.getMonth() + 1;
34        $post_type = $('.ricalendar').attr('data-selected');
35        $taxonomy = $('.ricalendar').attr('data-selected')+'_category';
36        updateCalendar(year+'-'+month,$post_type,'',$taxonomy);
37	}
38});
39
40//Scroll through months in calendar
41$(document).on('click','.ricalendar .previous_month:not(".disabled"),.ricalendar .next_month', function(e){
42	e.preventDefault();
43	var theDate = $(this).attr('data-date');
44    var $term_id = $('.calendar_categories option:selected').val();
45    updateCalendar(theDate,$post_type,$term_id,$taxonomy);
46});
47//Filter calendar by category
48$(document).on('change','.ricalendar .calendar_categories', function(e){
49    e.preventDefault();
50    var theDate = $('.calendar_scroll span[data-current]').html();
51    var $term_id = $('.calendar_categories option:selected').val();
52    updateCalendar(theDate,$post_type,$term_id,$taxonomy);
53});
54
55//Load day or week data (depending on selected view type) based on the date just clicked on
56$(document).on('click','.ricalendar-calendar table tr td', function(){
57
58    //DAY VIEW
59    if( $('.list_view_filter li.current').is('[data-view="day"]') || $('.list_view_filter li.current').length < 1){
60        //Change the title in the list to the selected date
61        if($(this).hasClass('has_item')){
62            $('.ricalendar-list .list_header h2').html( $(this).attr('data-date') );
63        }
64
65        //Switch selected dates
66	    $('.ricalendar table tr td').removeClass('selected')
67        $(this).addClass('selected');
68
69        //Remove all data from the day slots
70        $('.day_view table td:nth-child(2)').removeClass('active').html('');
71
72        //Loop through each info element, obtain the data and populate the day list
73        $(this).children('i').each(function(){
74            var startHour = $(this).attr('data-starthour');
75            var startTime = $(this).attr('data-starttime');
76            var title = $(this).attr('data-title');
77            if(startHour == 0){startHour = '';}
78            $('.day_view table td[data-hour="'+startHour+'"]').addClass('active').append('<p><span>'+startTime+'</span> <strong>'+title+'</strong></p>');        
79        });
80    }
81
82
83
84    //WEEK VIEW
85    if( $('.list_view_filter li.current').is('[data-view="week"]') ){
86    
87        //Switch selected dates
88	    $('.ricalendar table tr td').removeClass('selected')
89        $(this).siblings('.has_item').addBack().addClass('selected');
90
91        var $firstDay = $('.has_item.selected').siblings('td[data-date]').addBack().first().attr('data-date');
92        var $lastDay = $('.has_item.selected').siblings('td[data-date]').addBack().last().attr('data-date');
93
94        var $title = $firstDay+' - '+ $lastDay;
95        $('.ricalendar-list .list_header h2').html($title);
96
97        //Remove all data from the day slots
98        $('.week_view table td:not(:nth-child(1))').removeClass('active').html('');
99
100        //Loop through each info element, obtain the data and populate the day list
101        $('.ricalendar td.has_item.selected').siblings('td.has_item').addBack().each(function(){
102            var nthColumn = parseInt($(this).attr('data-dayofweek'))*1 + (1*1);
103            $(this).children('i').each(function(){
104                var startHour = $(this).attr('data-starthour');
105                var startTime = $(this).attr('data-starttime');
106                var title = $(this).attr('data-title');
107                if(startHour == 0){startHour = '';}
108                $('.week_view table td[data-hour="'+startHour+'"]:nth-child('+nthColumn+')').addClass('active').append('<p><span>'+startTime+'</span> <strong>'+title+'</strong></p>');        
109            });
110        });
111    }
112
113    //MONTH OR LIST VIEW - just updates the date title
114    if( $('.list_view_filter li.current').is('[data-view="month"],[data-view="list"]') ){
115        var $theDate = $('.ricalendar-calendar .calendar_scroll span[data-current]').attr('data-current');
116        $theDate = $theDate.split('-');
117        var $title = new Date(Date.UTC($theDate[0], ($theDate[1] - 1), 28, 0, 0, 0));
118        $title = $title.toLocaleDateString('en-GB', { year: 'numeric', month: 'long'});
119
120        //Switch selected dates
121	    $('.ricalendar table tr td').removeClass('selected')        
122        $('.ricalendar-list .list_header h2').html($title);
123    }
124
125    //Scroll to the first event of the day
126    if($('.ricalendar-list table td.active,.ricalendar-list table td.has_item').length){
127        var $firstEventTop = $('.ricalendar-list table td.active:first,.ricalendar-list table td.has_item:first').position().top - 10;
128        $('.day_view,.week_view').delay(100).animate({scrollTop: $firstEventTop});
129    }
130});
131
132
133//Load a new view type (day, week, month or list views)
134$(document).on('click','.filter.list_view_filter li', function(){
135    //If we are clicking the view type already active then just cancel the click
136    if($(this).hasClass('current')){return false;}
137
138
139    $(this).addClass('current').siblings().removeClass('current');
140    var $theDate = $('.ricalendar-calendar .calendar_scroll span[data-current]').attr('data-current');
141    var $term_id = $('.calendar_categories option:selected').val();
142    updateCalendar($theDate,$post_type,$term_id,$taxonomy);
143});
144
145//in the week view stick the initials of the days-of-the-week to the top of the scrolling box
146document.addEventListener('scroll',function(e){
147        var $elm = $(e.target);
148        if( $elm.is('.week_view')){
149            $('.ricalendar-list .week_view thead').css({top: $('.week_view').scrollTop() });
150        }
151    },
152    true
153);
154
155//Reset to day view if the screen size is below 690 (the limit of which the other views fit on a screen)
156$(window).on('resize', function(){
157    if(window.innerWidth < 690){
158        $('ul.list_view_filter li[data-view="day"]').not('.current').trigger('click');
159    }
160});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.