PageSourceSearch

https://toaf.ca/wp-content/themes/bds-child-theme/assets/scripts/custom-script.js?v=1480287567&ver=7.1.2

js toaf.ca collected 2026-10-04 00:26:02 UTC 4,700 bytes, 143 lines download raw bytes

1(function($) {
2	$(document).ready(function() {
3
4		// Announcement Bar
5		let currentScroll = 0;
6		let isScrollingDown = true;
7		var $message = $(".announcement .message");
8		
9		if(!$(".announcement").length){
10			$("html").css("--announcement-height", "0px");
11		}
12
13		for (var i = 0; i < 10; i++) {
14			$message.clone().appendTo(".announcement .wrap");
15		}
16		gsap.to(".announcement .wrap", {x: ($(".announcement .message:first-child").width()) * -1, repeat: -1, duration: 20, ease: "linear"}).totalProgress(0.5);
17		
18		// Menu toggle
19		$(".site-header .menu svg").on("click", function(){
20			$(this).parents(".site-header").toggleClass("active");
21			if($(this).hasClass("close-icon")){
22				$(".site-menu, .site-menu .sub-menu").removeClass("active");
23			}else{
24				$(".site-menu").addClass("active");
25			}
26		});
27		
28		// Sub Menu toggle
29		$(".site-menu .menu-item-has-children > .menu-link").on("click", function(){
30			$(this).siblings(".sub-menu").toggleClass("active");
31		});
32
33		// Language Switcher Dropdown
34		(function () {
35			var $html = $('html');
36			var $switcher = $('.site-header .language-switcher');
37			var $trigger = $switcher.find('.language-switcher__trigger');
38
39			function getCurrentLang() {
40				return ($html.hasClass('translated-ltr') || $html.hasClass('translated-rtl')) ? 'FR' : 'EN';
41			}
42
43			function updateUI() {
44				var lang = getCurrentLang();
45				var activeLangName = lang === 'EN' ? 'English' : 'French';
46				$trigger.text(lang);
47				$switcher.find('.language-menu a').each(function () {
48					var $a = $(this);
49					var linkLang = $a.attr('title');
50					var isActive = linkLang === activeLangName;
51					var circle = isActive
52						? '<span class="lang-dot active" style="color:red">\u25CF</span> '
53						: '<span class="lang-dot">\u25CB</span> ';
54					$a.html(circle + linkLang);
55				});
56			}
57
58			$trigger.on('click', function (e) {
59				e.stopPropagation();
60				$switcher.toggleClass('open');
61				$trigger.attr('aria-expanded', $switcher.hasClass('open'));
62			});
63
64			$(document).on('click', function () {
65				$switcher.removeClass('open');
66				$trigger.attr('aria-expanded', 'false');
67			});
68
69			$switcher.find('.language-menu a').on('click', function () {
70				$switcher.removeClass('open');
71				$trigger.attr('aria-expanded', 'false');
72			});
73
74			new MutationObserver(updateUI).observe($html[0], {
75				attributes: true,
76				attributeFilter: ['class', 'lang']
77			});
78
79			updateUI();
80		})();
81		
82		// Funders & Sponsors Sliders
83		var sliders = $.makeArray($('.sponsor-tier[data-id]'));
84		shuffleArray(sliders); // Shuffle the array to randomize starting slider
85		var activeSliderIndex = Math.floor(Math.random() * sliders.length); // Randomly choose the starting slider
86		var activeSliderImages = [];
87		var cyclesCounter = 0;
88		var totalCyclesNeeded = sliders.length - 1;
89		
90		// Initialize each slider to start at slide 1
91		sliders.forEach(function(slider) {
92				var sliderImages = $.makeArray($(slider).find('.logo'));
93				activeSliderImages.push(sliderImages);
94				TweenMax.set(sliderImages[0], { autoAlpha: 1, scale: 1 }); // Set the initial state of the first image
95				slider.played = false;
96		});
97		
98		function crossfade() {
99				var currentSliderImages = activeSliderImages[activeSliderIndex];
100		
101				TweenMax.to(currentSliderImages[0], 1, { autoAlpha: 0, scale: 0.8 });
102				TweenMax.to(currentSliderImages[1], 1, { autoAlpha: 1, scale: 1 });
103				currentSliderImages.push(currentSliderImages.shift());
104		
105				// Choose a random slider that hasn't been played yet and is not the current slider
106				var unplayedSliders = sliders.filter((slider, index) => index !== activeSliderIndex && !slider.played);
107		
108				if (unplayedSliders.length > 0) {
109						activeSliderIndex = sliders.indexOf(unplayedSliders[Math.floor(Math.random() * unplayedSliders.length)]);
110				} else {
111						sliders.forEach(slider => slider.played = false);
112						cyclesCounter++;
113						if (cyclesCounter >= totalCyclesNeeded) {
114								shuffleArray(sliders);
115								cyclesCounter = 0;
116						}
117						activeSliderIndex = 0;
118				}
119		
120				sliders[activeSliderIndex].played = true;
121		}
122		
123		// Function to shuffle an array using Fisher-Yates algorithm
124		function shuffleArray(array) {
125				for (var i = array.length - 1; i > 0; i--) {
126						var j = Math.floor(Math.random() * (i + 1));
127						[array[i], array[j]] = [array[j], array[i]];
128				}
129		}
130		
131		// Start the crossfade cycle with a specified interval
132		var cycle = setInterval(crossfade, 1800);
133
134
135		// Programming Schedule
136		if( $("body.page-programming-schedule").length ){
137			$(".page-programming-schedule .accordion .accordion-heading").on("click", function(){
138				$(this).siblings(".list-of-programs").toggleClass("active");
139			});
140		}
141
142	});
143})(jQuery);

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.