PageSourceSearch

https://apexlearning.org.uk/wp-content/themes/wplms-apex-child-theme/assets/js/custom.js?ver=1790363488

js apexlearning.org.uk collected 2026-09-25 19:13:02 UTC 10,931 bytes, 289 lines download raw bytes

1function toggleFilter() {
2    var filterContent = document.querySelector('.foy-custom-sidebar');
3    var filterButtonIcon = document.querySelector('.filter-button i');
4    // Toggle the display of the filter content
5    filterContent.style.display = (filterContent.style.display == 'none' || filterContent.style.display == '') ? 'block' : 'none';
6    // Toggle the icon between 'times' and 'filter'
7    filterButtonIcon.classList.toggle('fa-times', filterContent.style.display === 'block');
8    filterButtonIcon.classList.toggle('fa-filter', filterContent.style.display === 'none');
9}
10// Function to handle AllCourse Ajax
11jQuery(document).ready(function ($) {
12    function sendAjaxRequest(page, filters) {
13        var loading = true;
14        loadingClassHandler(loading);
15        var data = {
16            action: 'get_courses_ajax',
17            page: page,
18            filters: filters,
19        };
20        $.ajax({
21            url: ajaxurl,
22            type: 'POST',
23            data: data,
24            beforeSend: function() {
25
26            },
27            success: function(response) {
28                console.log(response);
29                $('.foy-course-list').html(response);
30                // console.log(response);
31                if (clickedRadioButton && !clickedRadioButton.prop('checked')) {
32                    propertiesUpdate(clickedRadioButton);
33                }
34            },
35            complete: function() {
36                var loading = false;
37                loadingClassHandler(loading);
38            },
39            error: function(jqXHR, textStatus, errorThrown) {
40                console.error('AJAX Error:', textStatus, errorThrown);
41            }
42        });
43    }
44    // Event listener for radio buttons and pagination
45    $(document).on('change click', '.foy-custom-sidebar input[type=radio], .foy-allcourse-pagination .foy-pagination a, .foy-reset', function (e) {
46        console.log("hello");
47        e.preventDefault();
48        var selectedFilters = "";
49        var page = 1;
50        // for radio button checked action
51        clickedRadioButton = false;
52        if ($(e.target).is('input[type=radio]')) {
53            clickedRadioButton = $(this);
54        }else if ($(this).hasClass('foy-reset')) {
55            // If the clicked element has the class 'foy-reset', handle reset logic
56            var currentContainer = $(this).closest('.foy-course-sidebar');
57            resetRadioButton(currentContainer);
58        }else{
59            if ($(this).attr('data-page')) {
60                var page = parseInt($(this).attr('data-page'), 10);
61            }
62        }
63        var selectedFilters = {
64            subject: $('input[name=subject]:checked').val() ?? "",
65            type: $('input[name=type]:checked').val() ?? "",
66            language: $('input[name=language]:checked').val() ?? "",
67            order: $('.foy-course-filter select').val() ?? ""
68        }
69        sendAjaxRequest(page, selectedFilters);
70    });
71
72    $(document).on('change', '.foy-course-filter select', function (e) {
73        e.preventDefault();
74        clickedRadioButton = false;
75        if ($(e.target).is('input[type=radio]')) {
76            clickedRadioButton = $(this);
77        }
78        var selectedFilters = {
79            subject: $('input[name=subject]:checked').val() ?? "",
80            type: $('input[name=type]:checked').val() ?? "",
81            language: $('input[name=language]:checked').val() ?? "",
82            order: $(this).val() ?? "" // Capture the value of the select element
83        };
84        sendAjaxRequest(1, selectedFilters); // Assuming the page should reset to 1 on filter change
85    });
86    // for handling loading css
87    function loadingClassHandler(loading) {
88        $('#loader').toggle(loading);
89        $('.foy-custom-sidebar, #course-list').toggleClass('foy-loading', loading);
90    }
91    // function loadingClassHandler(loading) {
92    //     if(loading){
93    //         $('#loader').show();
94    //         $('.foy-custom-sidebar').addClass('foy-loading');
95    //         $('#course-list').addClass('foy-loading');
96    //     }else{
97    //         $('#loader').hide();
98    //         $('.foy-custom-sidebar').removeClass('foy-loading');
99    //         $('#course-list').removeClass('foy-loading');
100    //     }
101    // }
102    // for handling resetbutton
103    function resetRadioButton(container) {
104        container.find('input[type=radio]').prop('checked', false);
105        container.find('button.foy-reset').prop('disabled', true);
106        lebelClassUpdate(container);
107    }
108    function lebelClassUpdate(container) {
109        container.find('label.foy-not-clickable').removeClass('foy-not-clickable');
110    }
111    function propertiesUpdate(clickedRadioButton){
112        var currentContainer = clickedRadioButton.closest('.foy-course-sidebar');
113        resetRadioButton(currentContainer);
114        currentContainer.find('button.foy-reset').prop('disabled', false);
115        var label = clickedRadioButton.closest('label');
116        clickedRadioButton.prop('checked', true);
117        label.addClass('foy-not-clickable');
118
119        $('.foy-custom-sidebar li').removeClass('active');
120        clickedRadioButton.closest('li').addClass('active');
121    }
122});
123
124// Function to handle CourseCat Ajax
125jQuery(document).ready(function ($) {
126    function sendAjaxRequest(page, filters) {
127        var loading = true;
128        loadingClassHandler(loading);
129        var data = {
130            action: 'get_cat_courses_ajax',
131            page: page,
132            filters: filters,
133        };
134        $.ajax({
135            url: ajaxurl,
136            type: 'POST',
137            data: data,
138            beforeSend: function() {
139                // handle beforeSend
140            },
141            success: function(response) {
142                $('.foy-course-list').html(response);
143                // console.log(response);
144            },
145            complete: function() {
146                var loading = false;
147                loadingClassHandler(loading);
148            },
149            error: function(jqXHR, textStatus, errorThrown) {
150                console.error('AJAX Error:', textStatus, errorThrown);
151            }
152        });
153    }
154    // Event listener for radio buttons and pagination
155    $(document).on('change click', '.foy-archive-pagination .foy-pagination a', function (e) {
156        e.preventDefault();
157        var page = 1;
158        if ($(this).attr('data-page')) {
159            var page = parseInt($(this).attr('data-page'), 10);
160        }
161        var selectedFilters = {
162            subject: $('.foy-page-name').val() ?? "",
163        }
164        sendAjaxRequest(page, selectedFilters);
165    });
166    function loadingClassHandler(loading) {
167        if(loading){
168            $('#loader').show();
169            $('.foy-custom-sidebar').addClass('foy-loading');
170            $('#course-list').addClass('foy-loading');
171        }else{
172            $('#loader').hide();
173            $('.foy-custom-sidebar').removeClass('foy-loading');
174            $('#course-list').removeClass('foy-loading');
175        }
176    }
177});
178
179// Function to handle CourseSearch Ajax
180jQuery(document).ready(function ($) {
181    function sendAjaxRequest(page, filters) {
182        var loading = true;
183        loadingClassHandler(loading);
184        var data = {
185            action: 'get_search_courses_ajax',
186            page: page,
187            filters: filters,
188        };
189        $.ajax({
190            url: ajaxurl,
191            type: 'POST',
192            data: data,
193            beforeSend: function() {
194                // handle beforeSend
195            },
196            success: function(response) {
197                $('.foy-course-list').html(response);
198                console.log(response);
199                if (clickedCheckboxButton) {
200                    propertiesUpdate(clickedCheckboxButton);
201                }
202                // updateCourseCount(page);
203            },
204            complete: function() {
205                var loading = false;
206                loadingClassHandler(loading);
207            },
208            error: function(jqXHR, textStatus, errorThrown) {
209                console.error('AJAX Error:', textStatus, errorThrown);
210            }
211        });
212    }
213    // Event listener for radio buttons and pagination
214    let previousOrder = $('#course-order-by').val();
215    $(document).on('change click', '#course-order-by, .foy-searchcourse-pagination .foy-pagination a', function (e) {
216        console.log($('#course-order-by').val());
217        e.preventDefault();
218        
219        if ($(this).is('#course-order-by')) {
220
221            // Ignore clicks that only open the dropdown
222            if ($('#course-order-by').val() === '') {
223                return;
224            }
225
226            const currentValue = $(this).val();
227
228            // Ignore if nothing selected or value hasn't changed
229            if (currentValue === '' || currentValue === previousOrder) {
230                return;
231            }
232
233            previousOrder = currentValue;
234        }
235
236
237        var selectedFilters = "";
238        var page = 1;
239        clickedCheckboxButton = false;
240        if ($(e.target).is('input[type=checkbox]')) {
241            clickedCheckboxButton = $(this);
242        } else if ($(this).attr('data-page')){
243            var page = parseInt($(this).attr('data-page'), 10);
244        }else if ($(this).hasClass('foy-all-reset')) {
245            resetCheckboxButton();
246        }
247        var selectedFilters = {
248            order_by: $('#course-order-by').val(),
249            query: $('.foy-search-query').val() ?? "",
250        };
251        sendAjaxRequest(page, selectedFilters);
252    });
253    function getCheckedValues(name) {
254        var checkboxes = $('input[name="' + name + '"]:checked');
255        var values = checkboxes.map(function() {
256            return $(this).val();
257        }).get();
258        return values;
259        // return values != '' ? values : '';
260    }
261    // function updateCourseCount(page){
262    //     courseStart = ((page - 1) * 16) + 1;
263    //     courseEnd = page * 16;
264    //     $('.foy-course-count h2 span').text(courseStart + ' - ' + courseEnd);
265    // }
266    function loadingClassHandler(loading) {
267        $('#loader').toggle(loading);
268        $('.foy-course-categories, #course-list, .foy-controls').toggleClass('foy-loading', loading);
269    }
270    // for handling resetbutton
271    // function resetCheckboxButton(container) {
272    //     $('.foy-custom-sidebar input[type=checkbox]').prop('checked', false);
273    //     $('.foy-custom-sidebar button.foy-all-reset').prop('disabled', true);
274    // }
275    // function propertiesUpdate(clickedCheckboxButton) {
276    //     clickedCheckboxButton.prop('checked', !clickedCheckboxButton.prop('checked'));
277    //     $('.foy-custom-sidebar button.foy-all-reset').prop('disabled', false);
278    // }
279});
280jQuery(function ($) {
281    $('#loader').hide();
282
283    $('.foy-course-categories, #course-list, .foy-controls')
284        .removeClass('foy-loading')
285        .css({
286            opacity: '',
287            visibility: ''
288        });
289});

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.