PageSourceSearch

https://www.gospelweeklies.com/wp-content/plugins/skilled-plugin/e…/timetable/js/timetable.js?ver=5.1.2

js gospelweeklies.com collected 2026-10-09 17:53:24 UTC 17,462 bytes, 452 lines download raw bytes

1jQuery(document).ready(function($){
2	var tt_atts = $.parseJSON($(".timetable_atts").val());
3	$(".tt_tabs").bind("tabsbeforeactivate", function(event, ui){
4		if(ui.newTab.length)
5		{
6			if(ui.newTab[0].parentNode.className.indexOf("all_filters")===-1)
7				$("html, body").animate({scrollTop: $("#"+$(ui.newTab).children("a").attr("id")).offset().top}, 400);
8			else
9			{
10				if($(".events_categories_filter").length)
11					$("html, body").animate({scrollTop: $(".events_categories_filter").offset().top}, 400);
12				else if($(".events_filter").length)
13					$("html, body").animate({scrollTop: $(".events_filter").offset().top}, 400);
14			}
15		}
16	});
17	
18	$(".tt_tabs").on("tabsactivate", function(event, ui){
19		ui.newPanel.find(".image_carousel").trigger("configuration", ["debug", false, true]);
20	});
21	
22	$(".tt_tabs_navigation a").click(function(event){
23		var $this = $(this);
24		$this.parent().parent().find("li").removeClass("ui-tabs-active");
25		$this.parent().addClass("ui-tabs-active");
26	});
27	
28	$(".tt_tabs").tabs({
29		event: "change",
30		show: true,
31		create: function(event, ui){
32			$("html, body").scrollTop(0);
33			if($(".tt_tabs_navigation.all_filters").length && window.location.href.indexOf("book-event-hour-")===-1)
34			{
35				if(ui.tab.length && $(".tt_tabs_navigation.events_categories_filter a[href='" + ui.tab[0].children[0].hash + "']").length)
36					$(".tt_tabs_navigation.events_categories_filter a[href='" + ui.tab[0].children[0].hash + "']").parent().addClass("ui-tabs-active");
37				else
38					$(".tt_tabs_navigation.events_categories_filter li:first-child a").parent().addClass("ui-tabs-active");
39				
40				if(ui.tab.length && $(".tt_tabs_navigation.events_filter a[href='" + ui.tab[0].children[0].hash + "']").length)
41					$(".tt_tabs_navigation.events_filter a[href='" + ui.tab[0].children[0].hash + "']").parent().addClass("ui-tabs-active");
42				else
43					$(".tt_tabs_navigation.events_filter li:first-child a").parent().addClass("ui-tabs-active");
44			}
45		}
46	});
47	
48	//browser history
49	$(".tt_tabs .ui-tabs-nav a").click(function(){
50		if($(this).attr("href").substr(0,4)!="http")
51			$.bbq.pushState($(this).attr("href"));
52		else
53			window.location.href = $(this).attr("href");
54	});
55	
56	//tabs box navigation
57	$(".tabs_box_navigation").mouseover(function(){
58		$(this).find("ul").removeClass("tabs_box_navigation_hidden");
59	});
60	
61	$(".tabs_box_navigation a").click(function(event){
62		if($.param.fragment()==$(this).attr("href").replace("#", "") || ($.param.fragment()=="" && $(this).attr("href").replace("#", "").substr(0, 10)=="all-events"))
63			event.preventDefault();
64		$(this).parent().parent().find(".selected").removeClass("selected");
65		$(this).parent().addClass("selected");
66		$(this).parent().parent().parent().children('label').text($(this).text());
67		$(this).parent().parent().addClass("tabs_box_navigation_hidden");
68	});
69	
70	$(".tt_tabs_navigation:not(.all_filter) a, .tabs_box_navigation:not(.all_filter) a").click(function(event){
71		event.preventDefault();
72		var $this = $(this);
73		var hash = $this.attr("href");
74		var sharpIdx = (window.location.href.indexOf("#")!==-1 ? window.location.href.indexOf("#") : window.location.href.length);
75		var event_str = ($(".events_filter .selected a").length ? $(".events_filter .selected a").attr("href").replace("#", "") : ($(".events_filter .ui-tabs-active a").length ? $(".events_filter .ui-tabs-active a").attr("href").replace("#", "") : ""));
76		var events_category_str = ($(".events_categories_filter .selected a").length ? $(".events_categories_filter .selected a").attr("href").replace("#", "") : ($(".events_categories_filter .ui-tabs-active a").length ? $(".events_categories_filter .ui-tabs-active a").attr("href").replace("#", "") : ""));
77		$("#tt_error_message").addClass("tt_hide");
78		if(event_str!=="" && events_category_str!=="")
79		{
80			if((event_str!=="all-events" && events_category_str!=="all-events" && $("[id='" + event_str + "'][class*='tt-event-category-" + events_category_str.toLowerCase() +"']").length) || (events_category_str==="all-events"))
81				window.location.href = escape_str(window.location.href.substr(0, sharpIdx)) + decodeURIComponent("#" + event_str);
82			else if(event_str==="all-events" && events_category_str!=="all-events")
83				window.location.href = escape_str(window.location.href.substr(0, sharpIdx)) + decodeURIComponent("#" + events_category_str);
84			else
85			{
86				window.location.href = escape_str(window.location.href.substr(0, sharpIdx)) + "#";
87				$(".tt_tabs").tabs("option", "collapsible", true);
88				$(".tt_tabs").tabs("option", "active", false);
89				$("#tt_error_message").removeClass("tt_hide");
90			}
91		}
92		else
93			window.location.href = escape_str(window.location.href.substr(0, sharpIdx)) + decodeURIComponent(hash);
94		//window.location.hash is causing issues on Safari, because of that
95		//it's necessary to use window.location.href
96	});
97	
98	if($(".events_categories_filter li.ui-tabs-active").length && $(".events_filter li.ui-tabs-active").length)	
99		$(".events_filter li.ui-tabs-active a").click();
100	
101	//hashchange
102	$(window).bind("hashchange", function(event){
103		var param_fragment = escape_str($.param.fragment());
104		//some browsers will have the URL fragment already encoded, 
105		//while others will not, thus it's necessary to handle both cases.
106		
107		//URL fragment is already encoded:
108		$(".tabs_box_navigation a[href='#" + param_fragment + "']").trigger("click");
109		$(".tt_tabs .ui-tabs-nav [href='#" + param_fragment + "']").trigger("change");
110		//URL fragment must be encoded:
111		$(".tabs_box_navigation a[href='#" + encodeURIComponent(param_fragment) + "']").trigger("click");
112		$(".tt_tabs .ui-tabs-nav [href='#" + encodeURIComponent(param_fragment) + "']").trigger("change");
113	}).trigger("hashchange");
114	
115	//tooltip
116	$(".tt_tooltip").bind("mouseover click", function(){
117		var attachTo = $(this);
118		if($(this).is(".event_container"))
119			attachTo = $(this).parent();
120		var tooltip_text = $(this).children(".tt_tooltip_text");
121		
122		tooltip_text.css("width", $(this).outerWidth() + "px");
123		tooltip_text.css("height", tooltip_text.height() + "px");
124		tooltip_text.css({"top":  -(tooltip_text.parent().offset().top-attachTo.offset().top+tooltip_text.innerHeight()) + "px", "left": 0 + "px"});
125	});
126	
127	//upcoming events
128	$(".tt_upcoming_events").each(function(){
129		var self = $(this);
130		var autoscroll = 0;
131		var elementClasses = $(this).attr("class").split(" ");
132		for(var i=0; i<elementClasses.length; i++)
133		{
134			if(elementClasses[i].indexOf("autoscroll-")!=-1)
135				autoscroll = elementClasses[i].replace("autoscroll-", "");
136		}
137		self.carouFredSel({
138			direction: "up",
139			items: {
140				visible: (self.children().length>2 ? 3 : self.children().length),
141				height: "variable"
142			},
143			scroll: {
144				items: 1,
145				easing: "swing",
146				pauseOnHover: true
147			},
148			prev: {button: self.next().children("#upcoming_event_prev")},
149			next: {button: self.next().children("#upcoming_event_next")},
150			auto: {
151				play: (parseInt(autoscroll) ? true : false)
152			}
153		});
154		
155		self.find("li a.tt_upcoming_events_event_container, li>span").hover(function(){
156			self.trigger("configuration", ["debug", false, true]);
157		},
158		function(){
159			setTimeout(function(){
160				self.trigger("configuration", ["debug", false, true]);
161			}, 1);
162		});
163	});
164	$(window).resize(function(){
165		$(".tt_upcoming_events").trigger("configuration", ["debug", false, true]);
166	});
167	
168	//timetable row heights
169	/*var maxHeight = Math.max.apply(null, $(".timetable:visible tr td:first-child").map(function ()
170	{
171		return $(this).height();
172	}).get());
173	$(".timetable:visible tr td").css("height", maxHeight);
174	//timetable height fix
175	$(".timetable .event").each(function(){
176		if($(this).children(".event_container").length>1)
177		{
178			var childrenHeight = 0;
179			$(this).children(".event_container").not(":last").each(function(){
180				childrenHeight += $(this).innerHeight();
181			});
182			var height = $(this).height()-childrenHeight-($(this).parent().parent().width()<=750 ? 9 : 22);
183			if(height>$(this).children(".event_container").last().height())
184				$(this).children(".event_container").last().css("height", height + "px");
185		}
186	});*/
187	
188	//show/hide event hours on mobile device
189	$(document.body).on("click", ".tt_timetable.small .plus.box_header", function(event) {
190		var $this = $(this);
191		var $list = $this.next("ul.tt_items_list");
192		$list.slideDown(500);
193		$this.removeClass("plus");
194		$this.addClass("minus");
195	});
196	$(document.body).on("click", ".tt_timetable.small .minus.box_header", function(event) {
197		var $this = $(this);
198		var $list = $this.next("ul.tt_items_list");
199		$list.slideUp(500, function() {
200			$this.removeClass("minus");
201			$this.addClass("plus");
202		});
203	});
204	
205	if($("#tt_booking_popup_message").length && in_iframe())
206	{
207		$("#tt_booking_popup_message").addClass("in_iframe");
208	}
209	
210	$(document.body).on("click touchstart", ".event_hour_booking", function(event) {
211		event.preventDefault();
212		var $this = $(this);
213		var $booking_popup = $("#tt_booking_popup_message");
214		var $booking_popup_message = $booking_popup.find(".tt_booking_message");
215		var $booking_popup_preloader = $booking_popup.find(".tt_preloader");
216		var event_hour_id = $this.attr("data-event-hour-id");
217		var redirect_url = window.location.href;
218		if(redirect_url.indexOf("#")===-1)
219			redirect_url = redirect_url + "#book-event-hour-" + event_hour_id;
220		else
221			redirect_url = redirect_url.substr(0, redirect_url.indexOf("#")) + "#book-event-hour-" + event_hour_id;
222		
223		if($this.hasClass("unavailable") || $this.hasClass("booked"))
224			return;
225		
226		$booking_popup_message.html("");
227		open_booking_popup();
228		$booking_popup_preloader.removeClass("tt_hide");
229		resize_booking_popup();
230		$booking_popup_message.attr("data-event-hour-id", event_hour_id);
231		
232		$.post(tt_config.ajaxurl,
233			{
234				action: "timetable_ajax_event_hour_details",
235				redirect_url: redirect_url,
236				event_hour_id: event_hour_id,
237				time_format: tt_atts.time_format,
238				booking_popup_message_template: tt_atts.booking_popup_message,
239				booking_popup_label: tt_atts.booking_popup_label,
240				cancel_popup_label: tt_atts.cancel_popup_label,
241				continue_popup_label: tt_atts.continue_popup_label,
242				login_popup_label: tt_atts.login_popup_label,
243			},
244			function(result){
245				/* assign event handler, fix for bug occuring on Android devices */
246				$booking_popup.on('click touchstart', handleBookingPopupMessageClickTouch);
247				$booking_popup_preloader.addClass("tt_hide");
248				var indexStart = result.indexOf("timetable_start")+15;
249				var indexEnd = result.indexOf("timetable_end")-indexStart;
250				result = $.parseJSON(result.substr(indexStart, indexEnd));
251				if(typeof(result.msg!=="undefined"))
252				{
253					if(!result.error)
254						$booking_popup_message.html(result.msg);
255					else
256					{
257						$booking_popup_message.html("<p>" + result.msg + "</p><div><a href='#' class='tt_btn cancel'>Cancel</a></div>");
258					}
259					resize_booking_popup();
260				}
261			},
262			"html"
263		);
264	});
265	
266	$(document.body).on("click touchstart", "#tt_booking_popup_message .tt_btn.book", function(event)
267	{
268		event.preventDefault();
269		var $booking_popup = $("#tt_booking_popup_message");
270		var $booking_popup_message = $booking_popup.find(".tt_booking_message");
271		var $booking_popup_preloader = $booking_popup.find(".tt_preloader");		
272		var event_hour_id = $booking_popup_message.attr("data-event-hour-id");
273		
274		$booking_popup_message.html("");
275		$booking_popup_preloader.removeClass("tt_hide");
276		resize_booking_popup();
277		
278		$.post(tt_config.ajaxurl,
279			{
280				action: "timetable_ajax_event_hour_booking",
281				event_hour_id: event_hour_id,
282				time_format: tt_atts.time_format,
283				cancel_popup_label: tt_atts.cancel_popup_label,
284				continue_popup_label: tt_atts.continue_popup_label,
285				booking_popup_thank_you_message_template: tt_atts.booking_popup_thank_you_message,
286			},
287			function(result){
288				$booking_popup_preloader.addClass("tt_hide");
289				var indexStart = result.indexOf("timetable_start")+15;
290				var indexEnd = result.indexOf("timetable_end")-indexStart;
291				result = $.parseJSON(result.substr(indexStart, indexEnd));
292				if(typeof(result.msg!=="undefined"))
293				{
294					if(!result.error)
295					{
296						$booking_popup_message.html(result.msg);
297						
298						var booked_button_html = 
299							'<a href="#"' + 
300							' class="event_hour_booking id-' + event_hour_id + ' booked ' + tt_atts.show_booking_button + '"' + 
301							' style="' + (tt_atts.booked_text_color.length && tt_atts.booked_text_color.toUpperCase()!='AAAAAA' ? ' color:#' + tt_atts.booked_text_color + ' !important;' : "") + (tt_atts.booked_bg_color.length && tt_atts.booked_bg_color.toUpperCase()!='EEEEEE' ? '" background-color:#"' + tt_atts.booked_bg_color + ' !important;' : '') + '"' + 
302							' title="' + tt_atts.booked_label + '">' + 
303								tt_atts.booked_label + 
304							'</a>';
305						
306						$(".event_hour_booking.id-" + event_hour_id).replaceWith(booked_button_html);
307						
308						if(typeof(result.remaining_places)!=="undefined")
309						{
310							if(result.remaining_places>0)
311								$(".available_slots.id-" + event_hour_id + "").html("<span class='count'> " + result.remaining_places + "</span> " + result.available_slots_label);
312							else
313								$(".available_slots.id-" + event_hour_id + "").remove();
314						}
315					}
316					else
317					{
318						$booking_popup_message.html("<p>" + result.msg + "</p><div><a href='#' class='tt_btn cancel'>" + tt_atts.cancel_popup_label + "</a></div>");
319					}
320					resize_booking_popup();
321				}
322			},
323			"html"
324		);
325	});
326	
327	function handleBookingPopupMessageClickTouch(event)
328	{
329		var target = $(event.target);
330		if(target.is($(this)))
331			close_booking_popup();
332	}
333	
334	$(document.body).on("click touchstart", ".tt_btn.cancel,.tt_btn.continue", function(event) {
335		event.preventDefault();
336		close_booking_popup();
337	});
338	
339	function open_booking_popup()
340	{
341		var $booking_popup = $("#tt_booking_popup_message"),
342			$booking_popup_wrapper = $("#tt_booking_popup_message .tt_booking_message_wrapper");
343		$booking_popup.removeClass("tt_hide");
344		
345		if($booking_popup.hasClass("in_iframe"))
346		{
347			var offsetTop = parent.document.body.scrollTop,
348				windowHeigh = parent.window.innerHeight,
349				popupHeight = $booking_popup_wrapper.height(),
350				marginTop;
351
352			marginTop = ((windowHeigh-popupHeight)/2 + offsetTop);
353			$booking_popup_wrapper.css({
354				'margin-top': marginTop + "px",
355			});
356		}
357	}
358	
359	function close_booking_popup()
360	{
361		var $booking_popup = $("#tt_booking_popup_message");
362		/* remove event handler, fix for bug occuring on Android devices */
363		$booking_popup.off("click touchstart", handleBookingPopupMessageClickTouch);
364		$booking_popup.addClass("tt_hide");
365		$booking_popup.find(".tt_booking_message_wrapper").css({
366			"height": "",
367			"margin-top": "",
368		});
369		if(window.location.href.indexOf("book-event-hour-")!==-1)
370			window.location.href = window.location.href.substr(0, window.location.href.indexOf("#"));
371	}
372	
373	function resize_booking_popup()
374	{
375		var $booking_popup = $("#tt_booking_popup_message");
376		var $booking_popup_wrapper = $("#tt_booking_popup_message .tt_booking_message_wrapper");
377		var popup_message_height = $booking_popup_wrapper.outerHeight();
378		var popup_message_height_auto = $booking_popup_wrapper.css("height", "").outerHeight();
379		var window_height = $(window).outerHeight();
380		var popup_message_height_new;
381		if(popup_message_height_auto+40<window_height)
382		{
383			popup_message_height_new = popup_message_height_auto;
384			$booking_popup_wrapper.css({
385				"overflow-y": ""
386			});
387		}
388		else
389		{
390			popup_message_height_new = window_height-40;
391			$booking_popup_wrapper.css({
392				"overflow-y": "scroll"
393			});
394		}
395		
396		if($booking_popup.hasClass("in_iframe"))
397		{
398			var offsetTop = parent.document.body.scrollTop,
399				windowHeigh = parent.window.innerHeight,
400				popupHeight = $booking_popup_wrapper.height(),
401				marginTop;
402
403			marginTop = ((windowHeigh-popupHeight)/2 + offsetTop);
404
405			$booking_popup_wrapper.animate({ "margin-top": marginTop + "px" }, 200);
406		}
407		
408		$booking_popup_wrapper.css("height", popup_message_height);
409		if(popup_message_height!=popup_message_height_new)
410			$booking_popup_wrapper.stop(false, true).animate({"height": popup_message_height_new}, 200);
411	}
412	$(window).resize(resize_booking_popup);
413	window.addEventListener("orientationchange", function() {
414		setTimeout(resize_booking_popup, 1);
415	});
416	
417	if(window.location.href.indexOf("book-event-hour-")!==-1)
418	{ 
419		var event_hour_id = window.location.href.substr(window.location.href.indexOf("book-event-hour-")+16);
420		if($("a.event_hour_booking.id-" + event_hour_id).eq(0).length)
421			$("a.event_hour_booking.id-" + event_hour_id).eq(0).click();
422	}
423	
424	function escape_str($text)
425	{
426		return $("<div/>").text($text).html();
427	}
428	
429	$("form.tt_generate_pdf").on("submit", function(event) {
430		var $this=$(this),
431			$timetable_copy,
432			timetable_html;
433
434		$timetable_copy = $(".tt_tabs div.ui-tabs-panel:visible").find(".tt_timetable.small").clone();
435		$timetable_copy = $this.closest(".tt_wrapper").find(".tt_tabs div.ui-tabs-panel:visible .tt_timetable.small").clone();
436		$timetable_copy.find("*").attr("style", "");	//helps to remove the colors
437		timetable_html = $timetable_copy[0].outerHTML;
438		if($("body").hasClass("rtl"))
439			timetable_html = "<div class='rtl'>" + timetable_html + "</div>";
440		$this.find("textarea[name='tt_pdf_html_content']").val(timetable_html);
441		return true;
442	});
443	
444	function in_iframe()
445	{
446		try {
447			return window.self !== window.top;
448		} catch (e) {
449			return true;
450		}
451	}
452});

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.