PageSourceSearch

https://sbschool.org/js/frontend/events.js

js sbschool.org collected 2026-10-03 21:38:18 UTC 3,396 bytes, 98 lines download raw bytes

1/* ----------------------------------------------------------------------------------------------------------------------- */
2/* Chosen Dropdown Replace Handling (for multi-selects) ------------------------------------------------------------------ */
3/* ----------------------------------------------------------------------------------------------------------------------- */
4var chosen_loaded = 0;
5var chosen_loading = 0;
6function do_chosen() {
7	if($('.do-chosen').length) {
8		if(!chosen_loaded) {
9			if(!chosen_loading) {
10				chosen_loading = 1;
11				add_css(shared_root+'/js/jquery/jquery.chosen/chosen.min.css');
12				$.when(add_js(shared_root+'/js/jquery/jquery.chosen/chosen.jquery.min.js')).done(function() {
13					chosen_loaded = 1;
14					$('.do-chosen').chosen();
15					$('.do-chosen').each(function(){
16						$(this).siblings('.chosen-container').css('width', realWidth($(this)));
17						$(this).trigger("chosen:updated");
18					});
19				});
20			}
21		} else {
22			$('.do-chosen').each(function(){
23				$(this).siblings('.chosen-container').css('width', realWidth($(this)));
24				$(this).trigger("chosen:updated");
25			});
26		}
27	}
28}
29function kill_chosen() {
30	$(".do-chosen").chosen("destroy");
31	chosen_loaded = 0;
32	chosen_loading = 0;
33}
34function realWidth($element){
35	var $clone = $element.clone();
36	$clone.css({"display":"block","visibility":"hidden"});
37	$($element).parent('form').append($clone);
38	var width = $clone.outerWidth();
39	$clone.remove();
40	return width;
41}
42do_chosen();
43
44
45/* ----------------------------------------------------------------------------------------------------------------------- */
46/* AJAX Handling --------------------------------------------------------------------------------------------------------- */
47/* ----------------------------------------------------------------------------------------------------------------------- */
48var cal_loader_timeout;
49var last_url = window.location.search;
50
51$(document).on('change',"select.category-id-select",function() {
52	var href = '?'+$(this).closest('form').serialize();
53	ajax_load_events_calendar_page(href);		
54});
55
56$(document).on('click',"#view-as-calendar-link, #view-as-list-link, .event-links-bar .button",function() {
57	var href = $(this).attr('href');
58	ajax_load_events_calendar_page(href);		
59	return false;
60});
61
62function ajax_load_events_calendar_page(href,no_push_state) {
63	var calendar_wrap = $('#calendar-and-filters-wrap');
64
65	$(calendar_wrap).css({'opacity':'0.5','pointer-events':'none'});
66
67	if(!no_push_state) history.pushState(null, null, href);
68	last_url = window.location.search;
69
70	$.ajax({
71		type: "GET",
72		url: href+(href.indexOf('?')>=0?'&':'?')+'ajax_calendar_load=1',
73		success: function(html,textStatus) {
74			$(calendar_wrap).html(html).css({'opacity':'','pointer-events':''});
75			if(chosen_loaded) {
76				$(calendar_wrap).find('.do-chosen').chosen();
77				$('.do-chosen').each(function(){
78					$(this).siblings('.chosen-container').css('width', realWidth($(this)));
79					$(this).trigger("chosen:updated");
80				});
81			}
82			$('body').trigger('ajax-events-calendar-loaded');
83		}
84	});		
85}
86
87setInterval(function() {
88	if(window.location.search != last_url) {
89		var href = window.location.search;
90		ajax_load_events_calendar_page(href,1);		
91	}
92},250);
93
94$(document).on('click','.calendar-subscribe-link',function() {
95	var html = $('#calendar-subscribe-overlay').html();
96	showSoSimpleOverlay(html);
97	return false;
98});

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.