PageSourceSearch

https://cadefenseacademy.com/Resources/Ultimate/assets/js/ultimate.js

js cadefenseacademy.com collected 2026-10-08 05:30:26 UTC 15,721 bytes, 523 lines download raw bytes

1//Version 1.5 - May 9, 2023
2(function ($) {
3	"use strict";
4	$(function () {
5
6		/* =========================================== /* =========================================== /* =========================================== */
7
8		//Navigation Sticky
9		function scrolling() {
10			var navigation_position = $(".ultimate-header--nav").offset().top;
11			$(window).scroll(function () {
12				if ($(this).scrollTop() > navigation_position) {
13					$("body").addClass('is_scrolling');
14				}
15				else {
16					$("body").removeClass('is_scrolling');
17				}
18			});
19		}
20		scrolling();
21
22		$(document).on('click touchend', '.ultimate-hmbrgr', function () {
23			$('body').addClass('menu_mobile_active');
24			return false;
25		});
26
27		$(document).on('click touchend', '.close_menu', function () {
28			$('body').removeClass('menu_mobile_active');
29			return false;
30		});
31
32		//FAQ
33		$(document).on('click', '.faq--item h3', function () {
34			var faqItem = $(this).parent();
35			var box = faqItem.find('.faq--content');
36			var panel = box.find('.faq--inner');
37			var panelHeight = panel.outerHeight();
38			if (faqItem.hasClass('active')) {
39				faqItem.removeClass('active');
40				box.css({ 'max-height': 0 });
41			} else {
42				$('.faq--item').removeClass('active');
43				faqItem.addClass('active');
44				$('.faq--item .faq--content').css({ 'max-height': 0 });
45				box.css({ 'max-height': panelHeight });
46			}
47			return false;
48		});
49
50		/* =========================================== /* =========================================== /* =========================================== */
51		//Staff Multiple Slider
52		if ($('.ultimate-staff-multiple').length > 0) {
53			$('.ultimate-staff-multiple').each(function(){
54				var container = $(this).find('.swiper-container');
55				var pagination = $(this).find('.swiper-pagination');
56				var nextButton = $(this).find('.swiper-button-next');
57				var prevButton = $(this).find('.swiper-button-prev');
58				var $options = {
59					slidesPerView : 1,
60					loop: true,
61				    // pagination
62				    pagination: {
63				      el: pagination,
64				    },
65				    // Arrows
66				    navigation: {
67				      nextEl: nextButton,
68				      prevEl: prevButton,
69				    },
70					breakpoints: {
71						767: {
72							slidesPerView: 2,
73							spaceBetween: 20
74						},
75						1080: {
76							slidesPerView: 3,
77							spaceBetween: 30
78						}
79					}
80				}
81				var mySwiper = new Swiper ( container , $options );
82				mySwiper.update();
83			});
84		}
85
86		//Review Slider
87		if ($('.ultimate--reviews').length > 0) {
88			$('.ultimate--reviews').each(function () {
89				var container = $(this).find('.swiper-container');
90				var pagination = $(this).find('.swiper-pagination');
91				var nextButton = $(this).find('.swiper-button-next');
92				var prevButton = $(this).find('.swiper-button-prev');
93				if ($(this).hasClass('uReviews-1')) {
94					var $options = {
95						loop: true,
96						autoHeight: true,
97						// pagination
98						pagination: {
99							el: pagination,
100						},
101						// Arrows
102						navigation: {
103							nextEl: nextButton,
104							prevEl: prevButton,
105						},
106					}
107				}
108				if ($(this).hasClass('uReviews-2')) {
109					var $options = {
110						slidesPerView: 1,
111						loop: true,
112						autoHeight: true,
113						// pagination
114						pagination: {
115							el: pagination,
116						},
117						// Arrows
118						navigation: {
119							nextEl: nextButton,
120							prevEl: prevButton,
121						},
122						breakpoints: {
123							767: {
124								slidesPerView: 2,
125								spaceBetween: 20
126							},
127							1080: {
128								slidesPerView: 3,
129								spaceBetween: 30
130							}
131						}
132					}
133				}
134				if ($(this).hasClass('uReviews-4')) {
135					var $options = {
136						slidesPerView: 1,
137						loop: true,
138						autoHeight: true,
139						// pagination
140						pagination: {
141							el: pagination,
142						},
143						// Arrows
144						navigation: {
145							nextEl: nextButton,
146							prevEl: prevButton,
147						},
148						breakpoints: {
149							767: {
150								slidesPerView: 2,
151								spaceBetween: 20
152							},
153							1080: {
154								slidesPerView: 2,
155								spaceBetween: 30
156							}
157						}
158					}
159				}
160				var mySwiper = new Swiper(container, $options);
161			});
162		}
163
164		//Programmes Slider
165		if ($('.uPrograms-2').length > 0) {
166			$('.uPrograms-2').each(function () {
167				var container = $(this).find('.swiper-container');
168				var pagination = $(this).find('.swiper-pagination');
169				var nextButton = $(this).find('.swiper-button-next');
170				var prevButton = $(this).find('.swiper-button-prev')
171				var $options = {
172					slidesPerView: 1,
173					loop: true,
174					// pagination
175					pagination: {
176						el: pagination,
177					},
178					// Arrows
179					navigation: {
180						nextEl: nextButton,
181						prevEl: prevButton,
182					},
183					breakpoints: {
184						767: {
185							slidesPerView: 2,
186							spaceBetween: 20
187						},
188						1080: {
189							slidesPerView: 3,
190							spaceBetween: 30
191						}
192					}
193				}
194				var mySwiperProgram = new Swiper(container, $options);
195			});
196		}
197
198		//Programmes Slider Single
199		if ($('.ultimate--sliProg-single').length > 0) {
200			$('.ultimate--sliProg-single').each(function () {
201				var container = $(this).find('.swiper-container');
202				var pagination = $(this).find('.swiper-pagination');
203				var nextButton = $(this).find('.swiper-button-next');
204				var prevButton = $(this).find('.swiper-button-prev')
205				var $options = {
206					autoHeight: true,
207					slidesPerView: 1,
208					loop: true,
209					// pagination
210					pagination: {
211						el: pagination,
212					},
213					// Arrows
214					navigation: {
215						nextEl: nextButton,
216						prevEl: prevButton,
217					}
218				}
219				var mySwiperProgram = new Swiper(container, $options);
220			});
221		}
222
223		//Programmes Slider
224		if ($('.uMembership-1').length > 0) {
225			$('.uMembership-1').each(function () {
226				var container = $(this).find('.swiper-container');
227				var pagination = $(this).find('.swiper-pagination');
228				var nextButton = $(this).find('.swiper-button-next');
229				var prevButton = $(this).find('.swiper-button-prev')
230				var $options = {
231					slidesPerView: 1,
232					loop: true,
233					// pagination
234					pagination: {
235						el: pagination,
236					},
237					// Arrows
238					navigation: {
239						nextEl: nextButton,
240						prevEl: prevButton,
241					},
242					breakpoints: {
243						767: {
244							slidesPerView: 2,
245							spaceBetween: 20
246						},
247						1080: {
248							slidesPerView: 3,
249							spaceBetween: 30
250						}
251					}
252				}
253				var mySwiperProgram = new Swiper(container, $options);
254			});
255		}
256		/* =========================================== /* =========================================== /* =========================================== */
257
258
259		$.fn.is_on_screen = function () {
260			var win = $(window);
261			var viewport = {
262				top: win.scrollTop() - (win.height() / 5),
263				left: win.scrollLeft()
264			};
265			viewport.right = viewport.left + win.width();
266			viewport.bottom = viewport.top + win.height();
267
268			var bounds = this.offset();
269			bounds.right = bounds.left + this.outerWidth();
270			bounds.bottom = bounds.top + this.outerHeight();
271
272			return (!(viewport.right < bounds.left || viewport.left >
272 bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
273		};
274
275
276		/* =========================================== /* =========================================== /* =========================================== */
277
278		// Play Animation if on screen.
279		function playanim(elis) {
280			var animation = elis.data('animation');
281			var delay = elis.data('delay');
282			elis.addClass(animation);
283			if (elis.is_on_screen()) {
284				if (delay) {
285					setInterval(function () { elis.addClass("animStart"); }, delay);
286				} else {
287					elis.addClass("animStart");
288				}
289			}
290		}
291
292
293		$('*[data-animation]').each(function () {
294			playanim($(this));
295		});
296		$(window).on('load', function () {
297			$('*[data-animation]').each(function () {
298				playanim($(this));
299			});
300		});
301		$(window).on('scroll', function () {
302			$('*[data-animation]').each(function () {
303				playanim($(this));
304			});
305		});
306
307		/* =========================================== /* =========================================== /* =========================================== */
308
309
310
311		// SERVICE PARTIAL VIEWS
312		$(document).on('click', '.services_accordion_title', function(){
313			$(this).parent().toggleClass('active');
314		});
315
316		//BREAK LINE ON MOBILE
317		$(document).on('click touchend', '.ultimate--linebreak div', function () {
318			var offsetLine = $(this).offset().top;
319			$('html, body').animate({scrollTop: offsetLine}, 1000);
320			return false;
321		});
322
323		/* =========================================== /* =========================================== /* =========================================== */
324
325		//NEW CAROUSEL FOR PROGRAMS (STACK EFFECT)
326		// let touchstartX = 0;
327		// let touchstartY = 0;
328		// let touchendX = 0;
329		// let touchendY = 0;
330
331		// function handleGesture(touchstartX, touchstartY, touchendX, touchendY) {
332		//     const delx = touchendX - touchstartX;
333		//     const dely = touchendY - touchstartY;
334		//     if(Math.abs(delx) > Math.abs(dely)){
335		//         if(delx > 0){ previousSlide(); }
336		//         else { nextSlide(); }
337		//     }
338		//     else if(Math.abs(delx) < Math.abs(dely)){
339		//         if(dely > 0) return "down"
340		//         else return "up"
341		//     }
342		//     else return "tap"
343		// }
344		// const gestureZone = document.getElementById('stackSlider97Zone');
345		// if (gestureZone !== null){
346		// 	gestureZone.addEventListener('touchstart', function(event) {
347		// 		touchstartX = event.changedTouches[0].screenX;
348		// 		touchstartY = event.changedTouches[0].screenY;
349		// 	}, false);
350
351		// 	gestureZone.addEventListener('touchend', function(event) {
352		// 		touchendX = event.changedTouches[0].screenX;
353		// 		touchendY = event.changedTouches[0].screenY;
354		// 		handleGesture(touchstartX, touchstartY, touchendX, touchendY);
355		// 	}, false); 
356		// }
357
358
359		const gestureZone = document.getElementById('stackSlider97Zone');
360		if (gestureZone !== null){
361
362			let startX = 0;
363			let startY = 0;
364
365			function handleTouchStart(e) {
366			  startX = e.changedTouches[0].screenX;
367			  startY = e.changedTouches[0].screenY;
368			}
369
370			function handleTouchEnd(e) {
371			  const diffX = e.changedTouches[0].screenX - startX;
372			  const diffY = e.changedTouches[0].screenY - startY;
373			  const ratioX = Math.abs(diffX / diffY);
374			  const ratioY = Math.abs(diffY / diffX);
375			  const absDiff = Math.abs(ratioX > ratioY ? diffX : diffY);
376
377			  // Ignore small movements.
378			  if (absDiff < 100) {
379			    return;
380			  }
381
382			  if (ratioX > ratioY) {
383			    if (diffX >= 0) {
384			      previousSlide();
385			    } else {
386			      nextSlide();
387			    }
388			  } else {
389			    if (diffY >= 0) {
390			      console.log('down swipe');
391			    } else {
392			      console.log('up swipe');
393			    }
394			  }
395			}
396			gestureZone.addEventListener('touchstart', function(event) {
397				handleTouchStart(event);
398			}, false);
399			gestureZone.addEventListener('touchend', function(event) {
400				handleTouchEnd(event);
401			}, false);
402		}
403
404
405		// let touchstartX = 0;
406		// let touchstartY = 0;
407		// let touchendX = 0;
408		// let touchendY = 0;
409
410		// const gestureZone = document.getElementById('stackSlider97Zone');
411
412		// if (gestureZone !== null){
413		// 	gestureZone.addEventListener('touchstart', function(event) {
414		// 	    touchstartX = event.changedTouches[0].screenX;
415		// 	    touchstartY = event.changedTouches[0].screenY;
416		// 	}, false);
417
418		// 	gestureZone.addEventListener('touchend', function(event) {
419		// 	    touchendX = event.changedTouches[0].screenX;
420		// 	    touchendY = event.changedTouches[0].screenY;
421		// 	    handleGesture();
422		// 	}, false); 
423
424		// 	function handleGesture() {
425		// 		let yScroll = touchstartY - touchendY;
426		// 		console.log(yScroll);
427		// 		if (yScroll < 30) {
428		// 		    if (touchendX < touchstartX) {
429		// 		    	if(yScroll !== 0){
430		// 		        	nextSlide();
431		// 		    	}
432		// 		    }
433		// 		}
434		// 		if (yScroll > -30 ) {
435		// 		    if (touchendX > touchstartX) {
436		// 		    	if(yScroll !== 0){
437		// 			        previousSlide();
438		// 			    }
439		// 		    }
440		// 		}
441		// 	}
442		// }
443
444
445		$('.stackSlider97--item').first().addClass('active');
446		$('.stackSlider97--wrapper').height($('.stackSlider97--item.active .stackSlider97--itemInside').height());
447		$(window).on('resize', function(){
448			$('.stackSlider97--wrapper').height($('.stackSlider97--item.active .stackSlider97--itemInside').height());
449		});
450		$(window).on('load', function(){
451			$('.stackSlider97--wrapper').height($('.stackSlider97--item.active .stackSlider97--itemInside').height());
452		});
453		document.addEventListener('DOMContentLoaded', (event) => {
454			$('.stackSlider97--wrapper').height($('.stackSlider97--item.active .stackSlider97--itemInside').height());
455		});		
456		//Slide
457		function gotransition() {
458			if ($('.stackSlider97--item').length <= 1) return;
459			$('.stackSlider97--item.active').delay(50).insertAfter($('.stackSlider97--item').last()).removeClass('active gotransition');
460			$('.stackSlider97--item').first().addClass('active');
461			$('.stackSlider97--wrapper').height($('.stackSlider97--item.active .stackSlider97--itemInside').height());
462		}
463		function gotransitionBack() {
464			if ($('.stackSlider97--item').length <= 1) return;
465			$('.stackSlider97--item').last().delay(20).insertBefore($('.stackSlider97--item').first()).removeClass('active gotransition');
466			$('.stackSlider97--item.active').removeClass('active gotransition');
467			$('.stackSlider97--item').first().addClass('active');
468			$('.stackSlider97--wrapper').height($('.stackSlider97--item.active .stackSlider97--itemInside').height());
469		}
470
471		//Pagniation
472		let stackCounter = $('.stackSlider97--item').length;
473		for (var i = 1; i <= stackCounter; i++) {
474			$('.stackSlider97--pagination').append('<span></span>');
475		}
476		$('.stackSlider97--pagination span').first().addClass('active');
477
478		//Navigation
479		function nextSlide() {
480			if ($('.stackSlider97--item').length <= 1) return;
481			$('.stackSlider97--item.active').addClass('gotransition');
482			setTimeout(function() {
483				gotransition();
484			}, 100);
485			if( $('.stackSlider97--pagination span.active').next().length > 0 ){
486				$('.stackSlider97--pagination span.active').removeClass('active').next().addClass('active');
487			} else {
488				$('.stackSlider97--pagination span.active').removeClass('active');
489				$('.stackSlider97--pagination span').first().addClass('active');
490			}
491		}
492
493		function previousSlide() {
494			if ($('.stackSlider97--item').length <= 1) return;
495			$('.stackSlider97--item.active').addClass('gotransition');
496			setTimeout(function() {
497				gotransitionBack();
498			}, 50);
499			if( $('.stackSlider97--pagination span.active').prev().length > 0 ){
500				$('.stackSlider97--pagination span.active').removeClass('active').prev().addClass('active');
501			} else {
502				$('.stackSlider97--pagination span.active').removeClass('active');
503				$('.stackSlider97--pagination span').last().addClass('active');
504			}
505		}
506		// $(document).on('swiperight','.stackSlider97--left', function(){
507		// 	previousSlide();
508		// });
509		// $(document).on('swipeleft','.stackSlider97--right', function(){
510		// 	nextSlide();
511		// });
512		$(document).on('click','.stackSlider97--left', function(){
513			previousSlide();
514		});
515		$(document).on('click','.stackSlider97--right', function(){
516			nextSlide();
517		});
518
519
520		/* =========================================== */
521	});
522}(jQuery));
523

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.